> On Sep 27, 2021, at 5:45 AM, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote: > > On Mon, Sep 27, 2021 at 05:33:39AM -0700, Nadav Amit wrote: >> >> >>> On Sep 27, 2021, at 4:55 AM, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote: >>> >>> On Mon, Sep 27, 2021 at 03:11:20AM -0700, Nadav Amit wrote: >>>> >>>>> On Sep 27, 2021, at 2:08 AM, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote: >>>>> >>>>> On Sun, Sep 26, 2021 at 09:12:52AM -0700, Nadav Amit wrote: >>>>>> From: Nadav Amit <namit@xxxxxxxxxx> >>>>>> >>>>>> The comment in madvise_dontneed_free() says that vma splits that occur >>>>>> while the mmap-lock is dropped, during userfaultfd_remove(), should be >>>>>> handled correctly, but nothing in the code indicates that it is so: prev >>>>>> is invalidated, and do_madvise() will therefore continue to update VMAs >>>>>> from the "obsolete" end (i.e., the one before the split). >>>>>> >> [snip] >> Perhaps adding this one on top of yours? I can test it when I wake up. >> It is cleaner, but I am not sure if I am missing something. > > It should work. > > BTW, shouldn't we bring madvise_willneed() and madvise_remove() to the > same scheme? Even for consistency you are right. My only problem is that I am afraid to backport such a change. For MADV_DONTNEED, I saw an explicit assumption. I can do it all in one patch if we agree that none of it goes into stable (which I clumsily forgot to cc, but might find the patch and backport it).