From: Peter Xu <peterx@redhat.com>
To: James Houghton <jthoughton@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Nikita Kalyazin <kalyazin@amazon.com>,
Hugh Dickins <hughd@google.com>,
Oscar Salvador <osalvador@suse.de>,
Michal Hocko <mhocko@suse.com>,
David Hildenbrand <david@redhat.com>,
Muchun Song <muchun.song@linux.dev>,
Andrea Arcangeli <aarcange@redhat.com>,
Ujwal Kundur <ujwal.kundur@gmail.com>,
Suren Baghdasaryan <surenb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Mike Rapoport <rppt@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Axel Rasmussen <axelrasmussen@google.com>
Subject: Re: [PATCH 4/4] mm: Apply vm_uffd_ops API to core mm
Date: Wed, 25 Jun 2025 17:21:15 -0400 [thread overview]
Message-ID: <aFxoSzdDGRkYLyr2@x1.local> (raw)
In-Reply-To: <CADrL8HVZccikHRZ+PP4EfKQBkgXZ0E9S3GFtwWVYLD2NMhg7EA@mail.gmail.com>
On Wed, Jun 25, 2025 at 01:31:49PM -0700, James Houghton wrote:
> > -static inline bool vma_can_userfault(struct vm_area_struct *vma,
> > - unsigned long vm_flags,
> > - bool wp_async)
> > +static inline const vm_uffd_ops *vma_get_uffd_ops(struct vm_area_struct *vma)
> > {
> > - vm_flags &= __VM_UFFD_FLAGS;
> > -
> > - if (vma->vm_flags & VM_DROPPABLE)
> > - return false;
> > -
> > - if ((vm_flags & VM_UFFD_MINOR) &&
> > - (!is_vm_hugetlb_page(vma) && !vma_is_shmem(vma)))
> > - return false;
> > -
> > - /*
> > - * If wp async enabled, and WP is the only mode enabled, allow any
> > - * memory type.
> > - */
> > - if (wp_async && (vm_flags == VM_UFFD_WP))
> > - return true;
> > -
> > -#ifndef CONFIG_PTE_MARKER_UFFD_WP
> > - /*
> > - * If user requested uffd-wp but not enabled pte markers for
> > - * uffd-wp, then shmem & hugetlbfs are not supported but only
> > - * anonymous.
> > - */
> > - if ((vm_flags & VM_UFFD_WP) && !vma_is_anonymous(vma))
> > - return false;
> > -#endif
>
> Hi Peter,
>
> Thanks for this cleanup!
>
> It looks like the above two checks, the wp-async one and the PTE
> marker check, have been reordered in this patch. Does this result in a
> functional difference?
>
> The rest of this series looks fine to me. :)
Thanks for the very careful review, James!
Yes that's a small tweak I did when moving. I don't expect to have any
functional change. Maybe I should at least mention that in the commit log.
Here I did the movement because fundamentally wp_async depends on the pte
markers, so it may be slightly more intuitive to check pte markers first,
rejecting any form of file wr-protect traps. Otherwise it may looks like
we could return the true for wp_async==true too early. In reality IIUC it
can't happen.
For example, currently userfaultfd_api() has:
#ifndef CONFIG_PTE_MARKER_UFFD_WP
uffdio_api.features &= ~UFFD_FEATURE_WP_HUGETLBFS_SHMEM;
uffdio_api.features &= ~UFFD_FEATURE_WP_UNPOPULATED;
uffdio_api.features &= ~UFFD_FEATURE_WP_ASYNC;
#endif
So when wp_async can be true above, pte markers must be compiled.. IOW,
above code clip should work identically with below lines:
#ifdef CONFIG_PTE_MARKER_UFFD_WP
if (wp_async && (vm_flags == VM_UFFD_WP))
return true;
#endif
#ifndef CONFIG_PTE_MARKER_UFFD_WP
if ((vm_flags & VM_UFFD_WP) && !vma_is_anonymous(vma))
return false;
#endif
Then it means both chunks of code cannot be compiled together. The order
shouldn't matter.
But maybe I should just move it back as before, to save the explain and
confusions. Let me know if you have any preference.
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2025-06-25 21:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 19:03 [PATCH 0/4] mm/userfaultfd: modulize memory types Peter Xu
2025-06-20 19:03 ` [PATCH 1/4] mm: Introduce vm_uffd_ops API Peter Xu
2025-06-22 7:28 ` Mike Rapoport
2025-06-23 13:36 ` Peter Xu
2025-06-23 8:25 ` David Hildenbrand
2025-06-23 13:59 ` Peter Xu
2025-06-23 16:50 ` David Hildenbrand
2025-06-23 17:20 ` Peter Xu
2025-06-23 17:25 ` David Hildenbrand
2025-06-23 17:56 ` Peter Xu
2025-06-20 19:03 ` [PATCH 2/4] mm/shmem: Support " Peter Xu
2025-06-20 19:03 ` [PATCH 3/4] mm/hugetlb: " Peter Xu
2025-06-20 19:03 ` [PATCH 4/4] mm: Apply vm_uffd_ops API to core mm Peter Xu
2025-06-22 19:09 ` kernel test robot
2025-06-23 18:12 ` Peter Xu
2025-06-25 20:31 ` James Houghton
2025-06-25 21:21 ` Peter Xu [this message]
2025-06-25 21:52 ` James Houghton
2025-06-25 16:56 ` [PATCH 0/4] mm/userfaultfd: modulize memory types Nikita Kalyazin
2025-06-25 20:17 ` Peter Xu
2025-06-26 16:09 ` Nikita Kalyazin
2025-06-27 13:51 ` Peter Xu
2025-06-27 16:59 ` Nikita Kalyazin
2025-06-27 18:46 ` Peter Xu
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=aFxoSzdDGRkYLyr2@x1.local \
--to=peterx@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=jthoughton@google.com \
--cc=kalyazin@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=ujwal.kundur@gmail.com \
--cc=vbabka@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.