On 8/7/26 23:52, Ackerley Tng via B4 Relay wrote: > From: "David Hildenbrand (Arm)" <[email protected]> > > KVM with guest_memfd wants to remove any folio references due to LRU > caches, as it really must only allow to convert folios from shared to > private when there are no unexpected folio references (e.g., from GUP > references). > > So, to drive the refcount down, it needs a way to flush the LRU caches. > Let's factor out what we have in lru_cache_drain_for_folio(). Document > it, and also mention that concurrent folio (un)mapping might, in theory, > miss detecting LRU cache references. Keep obtaining the expected refcount > twice to minimize the possibility. For the current and future user that > should work, and we don't really have a better alternative: we could > detect if the mapcount changed, but it would still be racy and add more > complexity with questionable benefit. > > Maybe there is a chance to avoid the draining entirely in the future, > by avoiding extra references from the LRU cache: Hugh thinks there might > be a way. But for the time being, this handling is unfortunately > required. > > Make folio_may_be_lru_cached() accept a const pointer so > lru_cache_drain_for_folio() can accept a const pointer as well. > > Signed-off-by: David Hildenbrand (Arm) <[email protected]> > Signed-off-by: Ackerley Tng <[email protected]> > ---
If all goes well, this patch should go into 7.3-rc1. So once you rebase, you'd get it for free :) -- Cheers, David
