Re: [PATCH 3/6] userfaultfd: use userfaultfd_*() helpers instead of open coded flag tests
flat view
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Date: 2026-08-25 11:26:49
Also in:
linux-doc, linux-fsdevel, linux-mm, lkml
On Tue, Aug 25, 2026 at 02:19:52PM +0300, Mike Rapoport wrote:
quoted
quoted
+/* + * Don't do fault around for WP, RWP or MINOR registered uffd range. For + * MINOR registered range, fault around will be a total disaster and ptes can + * be installed without notifications; for WP it should mostly be fine as long + * as the fault around checks for pte_none() before the installation, however + * to be super safe we just forbid it; for RWP, pre-faulted neighbours would + * be indistinguishable from accessed pages in PAGEMAP_SCAN (PAGE_IS_ACCESSED) + * and pollute the tracked working set, so each page must be populated by its + * own fault. + */ +static inline bool uffd_disable_fault_around(struct vm_area_struct *vma) +{ + return userfaultfd_minor(vma) || userfaultfd_wp(vma) || + userfaultfd_rwp(vma);This is changing the logic. Before we were testing only the flags, now we have: static inline bool userfaultfd_rwp(const struct vm_area_struct *vma) { /* * Callers gate PAGE_NONE usage on this; PAGE_NONE is a BUILD_BUG() * without CONFIG_ARCH_HAS_PTE_PROTNONE, so fold to false. */ if (!IS_ENABLED(CONFIG_ARCH_HAS_PTE_PROTNONE)) return false; return vma_test_single_mask(vma, VMA_UFFD_RWP); } I.e. adding in a CONFIG_ARCH_HAS_PTE_PROTNONE check.Without CONFIG_ARCH_HAS_PTE_PROTNONE VMA_UFFD_RWP is hardwired to VM_NONE so it's functionally the same ;-)
Well then you're explicitly removing logic and not mentioning it anywhere with a NFC commit. So please say so in the commit message.
quoted
BTW side-note these: static inline bool userfaultfd_missing(const struct vm_area_struct *vma) { return vma_test_any_mask(vma, VMA_UFFD_MISSING); } static inline bool userfaultfd_wp(const struct vm_area_struct *vma) { return vma_test_any_mask(vma, VMA_UFFD_WP); } static inline bool userfaultfd_minor(const struct vm_area_struct *vma) { return vma_test_any_mask(vma, VMA_UFFD_MINOR); } Should all use vma_test_single_mask() really :)These are changed anyway in a later patch.
Yup, but you (potentially) break one of them. Will comment there.
quoted
-- Cheers, Lorenzo-- Sincerely yours, Mike.
-- Cheers, Lorenzo