Re: [PATCH] mm/filemap: Implement fast short reads
From: David Hildenbrand
Date: Mon Oct 27 2025 - 13:00:01 EST
On 27.10.25 17:48, Linus Torvalds wrote:
On Mon, 27 Oct 2025 at 09:06, David Hildenbrand <david@xxxxxxxxxx> wrote:
So I really wish that we can defer optimizing this to freeing folios
under RCU instead.
So just to see, I dug around when we started to do the rcu-protected
folio lookup (well, it was obviously not a folio at the time).
Mainly because we actually had a lot more of those subtle
folio_try_get() users than I expected us to have,
It goes back to July 2008 (commit e286781d5f2e: "mm: speculative page
references" being the first in the series).
I do have to say that the original naming was better: we used to call
the "try_get" operation "page_cache_get_speculative()", which made it
very clear that it was doing something speculative and different from
some of our other rcu patterns, where if it's successful it's all
good.
Because even when successful, the folio in folio_try_get() is still
speculative and needs checking.
Right, and we only access its content after verifying that (a) it is the
one we wanted to access and (b) stabilizing it, so it will stay that way.
Not all of our current users seem to re-verify the source of the folio
afterwards (deferred_split_scan() makes me go "Uhh - you seem to rely
on folio_try_get() as some kind of validity check" for example).
Note that deferred_split_scan() only operates with anon folios and has
some nasty NASTY interaction with folio freeing. :)
--
Cheers
David / dhildenb