[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210316190707.GD3420@casper.infradead.org>
Date: Tue, 16 Mar 2021 19:07:07 +0000
From: Matthew Wilcox <willy@...radead.org>
To: David Howells <dhowells@...hat.com>
Cc: Trond Myklebust <trondmy@...merspace.com>,
Anna Schumaker <anna.schumaker@...app.com>,
Steve French <sfrench@...ba.org>,
Dominique Martinet <asmadeus@...ewreck.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Christoph Hellwig <hch@....de>,
Alexander Viro <viro@...iv.linux.org.uk>, linux-mm@...ck.org,
linux-cachefs@...hat.com, linux-afs@...ts.infradead.org,
linux-nfs@...r.kernel.org, linux-cifs@...r.kernel.org,
ceph-devel@...r.kernel.org, v9fs-developer@...ts.sourceforge.net,
linux-fsdevel@...r.kernel.org, Jeff Layton <jlayton@...hat.com>,
David Wysochanski <dwysocha@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 02/28] mm: Add an unlock function for
PG_private_2/PG_fscache
On Wed, Mar 10, 2021 at 04:54:49PM +0000, David Howells wrote:
> Add a function, unlock_page_private_2(), to unlock PG_private_2 analogous
> to that of PG_lock. Add a kerneldoc banner to that indicating the example
> usage case.
This isn't a problem with this patch per se, but I'm concerned about
private2 and expected page refcounts.
static inline int is_page_cache_freeable(struct page *page)
{
/*
* A freeable page cache page is referenced only by the caller
* that isolated the page, the page cache and optional buffer
* heads at page->private.
*/
int page_cache_pins = thp_nr_pages(page);
return page_count(page) - page_has_private(page) == 1 + page_cache_pins;
}
static inline int page_has_private(struct page *page)
{
return !!(page->flags & PAGE_FLAGS_PRIVATE);
}
#define PAGE_FLAGS_PRIVATE \
(1UL << PG_private | 1UL << PG_private_2)
So ... a page with both flags cleared should have a refcount of N.
A page with one or both flags set should have a refcount of N+1.
How is a poor filesystem supposed to make that true? Also btrfs has this
problem since it uses private_2 for its own purposes.
Powered by blists - more mailing lists