From: David Hildenbrand <david@redhat.com>
To: peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>
Subject: Re: [PATCH] mm/memory: Fix missing pte marker for !page on pte zaps
Date: Wed, 13 Mar 2024 23:03:04 +0100 [thread overview]
Message-ID: <c04c81bc-dfc1-4dd6-972c-23c2eb8a5d0d@redhat.com> (raw)
In-Reply-To: <20240313213107.235067-1-peterx@redhat.com>
On 13.03.24 22:31, peterx@redhat.com wrote:
> From: Peter Xu <peterx@redhat.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() :)
>
> 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;
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?
Change itself looks, good. Not sure about the anon_vma example above.
Thanks!
Acked-by: David Hildenbrand <david@redhat.com>
>
> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
> Cc: David Hildenbrand <david@redhat.com>
> Fixes: 0cf18e839f64 ("mm/memory: handle !page case in zap_present_pte() separately")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> mm/memory.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index f2bc6dd15eb8..904f70b99498 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1536,7 +1536,9 @@ static inline int zap_present_ptes(struct mmu_gather *tlb,
> ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm);
> arch_check_zapped_pte(vma, ptent);
> tlb_remove_tlb_entry(tlb, pte, addr);
> - VM_WARN_ON_ONCE(userfaultfd_wp(vma));
> + if (userfaultfd_pte_wp(vma, ptent))
> + zap_install_uffd_wp_if_needed(vma, addr, pte, 1,
> + details, ptent);
> ksm_might_unmap_zero_page(mm, ptent);
> return 1;
> }
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-03-13 22:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 21:31 peterx
2024-03-13 22:03 ` David Hildenbrand [this message]
2024-03-13 22:26 ` David Hildenbrand
2024-03-13 22:26 ` Peter Xu
2024-03-13 22:29 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c04c81bc-dfc1-4dd6-972c-23c2eb8a5d0d@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=usama.anjum@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox