[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y6XJwvjKyTgRIiI3@infradead.org>
Date: Fri, 23 Dec 2022 07:31:14 -0800
From: Christoph Hellwig <hch@...radead.org>
To: David Howells <dhowells@...hat.com>
Cc: Matthew Wilcox <willy@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Steve French <sfrench@...ba.org>,
Shyam Prasad N <nspmangalore@...il.com>,
Rohith Surabattula <rohiths.msft@...il.com>,
Dave Wysochanski <dwysocha@...hat.com>,
Dominique Martinet <asmadeus@...ewreck.org>,
Ilya Dryomov <idryomov@...il.com>, linux-cachefs@...hat.com,
linux-cifs@...r.kernel.org, linux-afs@...ts.infradead.org,
v9fs-developer@...ts.sourceforge.net, ceph-devel@...r.kernel.org,
linux-nfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, Jeff Layton <jlayton@...nel.org>,
linux-erofs@...ts.ozlabs.org, linux-ext4@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 3/3] mm: Make filemap_release_folio() better inform
shrink_folio_list()
On Thu, Dec 22, 2022 at 03:02:29PM +0000, David Howells wrote:
> Make filemap_release_folio() return one of three values:
>
> (0) FILEMAP_CANT_RELEASE_FOLIO
>
> Couldn't release the folio's private data, so the folio can't itself
> be released.
>
> (1) FILEMAP_RELEASED_FOLIO
>
> The private data on the folio was released and the folio can be
> released.
>
> (2) FILEMAP_FOLIO_HAD_NO_PRIVATE
These names read really odd, due to the different placementments
of FOLIO, the present vs past tense and the fact that 2 also released
the folio, and the reliance of callers that one value of an enum
must be 0, while no unprecedented, is a bit ugly.
But do we even need them? What abut just open coding
filemap_release_folio (which is a mostly trivial function) in
shrink_folio_list, which is the only place that cares?
if (folio_has_private(folio) && folio_needs_release(folio)) {
if (folio_test_writeback(folio))
goto activate_locked;
if (mapping && mapping->a_ops->release_folio) {
if (!mapping->a_ops->release_folio(folio, gfp))
goto activate_locked;
} else {
if (!try_to_free_buffers(folio))
goto activate_locked;
}
if (!mapping && folio_ref_count(folio) == 1) {
...
alternatively just keep using filemap_release_folio and just add the
folio_needs_release in the first branch. That duplicates the test,
but makes the change a one-liner.
Powered by blists - more mailing lists