[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZfIoFP4lGXW3el8b@x1n>
Date: Wed, 13 Mar 2024 18:26:28 -0400
From: Peter Xu <peterx@...hat.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Muhammad Usama Anjum <usama.anjum@...labora.com>
Subject: Re: [PATCH] mm/memory: Fix missing pte marker for !page on pte zaps
On Wed, Mar 13, 2024 at 11:03:04PM +0100, David Hildenbrand wrote:
> On 13.03.24 22:31, peterx@...hat.com wrote:
> > From: Peter Xu <peterx@...hat.com>
> >
> > Commit 0cf18e839f64 of large folio zap work broke uffd-wp. Now mm's uffd
> > unit test "wp-unpopulated" will trigger this WARN_ON_ONCE().
>
> Good that I added the WARN_ON_ONCE() :)
To be explict, VM_WARN_ON_ONCE. :) And that's my guess that you didn't hit
it when you posted the series and did the tests, as I know latest distros
like Fedora dropped DEBUG_VM, so maybe you had your base config out of
there (but I normally have it irrelevant of that).
>
> >
> > The WARN_ON_ONCE() asserts that an VMA cannot be registered with
> > userfaultfd-wp if it contains a !normal page, but it's actually possible.
> > One example is an anonymous vma, register with uffd-wp, read anything will
> > install a zero page. Then when zap on it, this should trigger.
>
> Are you sure? zap_install_uffd_wp_if_needed() contains right at the start:
>
> /* Zap on anonymous always means dropping everything */
> if (vma_is_anonymous(vma))
> return;
My example is not exactly how the test failed, but should be a simpler
version of it. To trigger this warning I don't think it requires the zero
page to be wr-protected at all or have any pte marker involved.
UFFDIO_REGISTER should suffice, afaiu (feel free to read the example above
again; there's no mention of ioctl(UFFDIO_WRITEPROTECT)).
>
> So if that's the case the unit test triggers, I'm confused.
>
> >
> > What's more, removing that WARN_ON_ONCE may not be enough either, because
> > we should also not rely on "whether it's a normal page" to decide whether
> > pte marker is needed. For example, one can register wr-protect over some
> > DAX regions to track writes when UFFD_FEATURE_WP_ASYNC enabled, in which
> > case it can have page==NULL for a devmap but we may want to keep the marker
> > around.
>
> I thought uffd-wp was limited to specific backends only. But looks like that
> changed with UFFD_FEATURE_WP_ASYNC, I guess?
Correct. That was also what the new PAGEMAP ioctl relies on.
>
>
> Change itself looks, good. Not sure about the anon_vma example above.
>
> Thanks!
>
> Acked-by: David Hildenbrand <david@...hat.com>
Thanks,
--
Peter Xu
Powered by blists - more mailing lists