lkml.org 
[lkml]   [2020]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 18/25] mm: Allow large pages to be added to the page cache
On Sun, May 3, 2020 at 8:10 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Apr 29, 2020 at 06:36:50AM -0700, Matthew Wilcox wrote:
> > @@ -886,7 +906,7 @@ static int __add_to_page_cache_locked(struct page *page,
> > /* Leave page->index set: truncation relies upon it */
> > if (!huge)
> > mem_cgroup_cancel_charge(page, memcg, false);
> > - put_page(page);
> > + page_ref_sub(page, nr);
> > return xas_error(&xas);
> > }
> > ALLOW_ERROR_INJECTION(__add_to_page_cache_locked, ERRNO);
>
> This is wrong. page_ref_sub() will not call __put_page() if the refcount
> gets to zero. What do people prefer?
>
> - put_page(page);
>
> (a)
> + put_thp(page);
>
> (b)
> + put_page_nr(page, nr);
>
> (c)
> + if (page_ref_sub_return(page, nr) == 0)
> + __put_page(page);

b or c IMHO. The shmem uses page_ref_add/page_ref_sub so we'd better
follow it. If go with b, it sounds better to add get_page_nr() as
well.

>

\
 
 \ /
  Last update: 2020-05-06 20:33    [W:0.083 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site