Re: [PATCH RFC 4/5] mm/vmscan: be more careful when releasing FS metadata if buffer_heads_over_limit

From: Jan Kara

Date: Wed Nov 25 2026 - 03:45:26 EST


On Thu 19-11-26 20:10:47, Pedro Falcato wrote:
> Namely, don't call ->release_folio() for mapped or referenced folios.
> Since this is the active list, there's no actual point in doing
> unmapping. In fact, that would be counterproductive for active folios.
>
> So, gate on !mapped && may_release_folio.
>
> Reported-by: David Hildenbrand <david@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: d824ec2a1546 ("mm: do not reclaim private data from pinned page")
> Signed-off-by: Pedro Falcato <pfalcato@xxxxxxx>

This is OK with me but so feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Just given buffer_heads_over_limit is a HIGHMEM thing and given how much we
care (not) about HIGHMEM, maybe just completely ripping out the whole
buffer_heads_over_limit logic is a better "solution"? I mean it's a crude
heuristic anyway and for struct buffer_head to occupy significant portion
of ZONE_NORMAL, you'd have to have several GB of pagecache with buffers
which means the machine has to have quite some highmem which makes the
setup even more dubious...

Honza

> ---
> mm/vmscan.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index d80bbb607a15..986742d7fb6a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2217,7 +2217,10 @@ static void shrink_active_list(unsigned long nr_to_scan,
> if (unlikely(buffer_heads_over_limit)) {
> if (folio_needs_release(folio) &&
> folio_trylock(folio)) {
> - filemap_release_folio(folio, 0);
> + if (!folio_mapped(folio) &&
> + filemap_may_release_folio(folio, 1)) {
> + filemap_release_folio(folio, 0);
> + }
> folio_unlock(folio);
> }
> }
>
> --
> 2.56.1
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR