On 20.01.22 18:48, Nadav Amit wrote: > >> On Jan 20, 2022, at 6:15 AM, David Hildenbrand <david@xxxxxxxxxx> wrote: >> >> On 17.01.22 14:31, zhangliang (AG) wrote: >>> Sure, I will do that :) >> >> I'm polishing up / testing the patches and might send something out for discussion shortly. >> Just a note that on my branch was a version with a wrong condition that should have been fixed now. >> > > Sorry for being late for the discussion. > > David, does any of it regards the lru_cache_add() reference issue that I > mentioned? [1] No, unfortunately not in that part of my work. *Maybe* we could also try to handle that reference similarly to the swapcache, but the question is if we can't wait for PageAnonExclusive. Right now I have the following in mind to get most parts working as exptected: 1. Optimize reuse logic for the swapcache as it seems to be easy 2. Streamline COW logic and remove reuse_swap_page() -- fix the CVE for THP. 3. Introduce PageAnonExclusive and allow FOLL_PIN only on PageAnonExclusive pages. 4. Convert O_DIRECT to FOLL_PIN We will never ever have to copy a page PageAnonExclusive page in the COW handler and can immediately reuse it without even locking the page. The existing reuse logic is essentially then used to reset PageAnonExclusive on a page (thus it makes sense to work on it) where the flag is not set anymore -- or on a fresh page if we have to copy. That implies that all these additional references won't care if your app doesn't fork() or KSM isn't active. Consequently, anything that read-protects anonymous pages will work as expected and should be as fast as it gets. Sounds good? At least to me. If only swap/migration entries wouldn't be harder to handle than I'd wish, that's why it's taking a little and will take a little longer. > > Seems to me that any solution should also regard this problem, or am I > missing something? The bigger picture has to handle it, yes! -- Thanks, David / dhildenb