Re: [PATCH] mm/fadvise: avoid remote LRU drain for mapped folio failures

From: David Hildenbrand (Arm)

Date: Mon May 11 2026 - 01:47:58 EST


> -long mapping_evict_folio(struct address_space *mapping, struct folio *folio)
> +static long __mapping_evict_folio(struct address_space *mapping,
> + struct folio *folio, bool *lru_refs)
> {
> + if (lru_refs)
> + *lru_refs = false;
> /* The page may have been truncated before it was locked */
> if (!mapping)
> return 0;
> @@ -331,14 +323,38 @@ long mapping_evict_folio(struct address_space *mapping, struct folio *folio)
> return 0;
> /* The refcount will be elevated if any page in the folio is mapped */
> if (folio_ref_count(folio) >
> - folio_nr_pages(folio) + folio_has_private(folio) + 1)
> + folio_nr_pages(folio) + folio_has_private(folio) + 1) {
> + /*
> + * A remote LRU drain can only help with extra references on
> + * otherwise evictable folios. Mapped folios also have an
> + * elevated refcount, but draining LRU caches cannot unmap them.
> + */
> + if (lru_refs && !folio_mapped(folio))
> + *lru_refs = true;

How can you conclude that it's a LRU refs? Could also just be something trivial
like a remaining GUP reference, or am I wrong?

--
Cheers,

David