On Monday, 15 November 2021 6:55:03 PM AEDT Peter Xu wrote: [...] > +/* > + * Returns true if this is a swap pte and was uffd-wp wr-protected in either > + * forms (pte marker or a normal swap pte), false otherwise. > + */ > +static inline bool pte_swp_uffd_wp_any(pte_t pte) > +{ > +#ifdef CONFIG_PTE_MARKER_UFFD_WP > + if (!is_swap_pte(pte)) > + return false; > + > + if (pte_swp_uffd_wp(pte)) > + return true; If I'm not mistaken normal swap uffd-wp ptes can still exist when CONFIG_PTE_MARKER_UFFD_WP=n so shouldn't this be outside the #ifdef protection? In fact we could drop the #ifdef entirely here as it is safe to call is_pte_marker_uffd_wp() without CONFIG_PTE_MARKER_UFFD_WP. > + > + if (is_pte_marker_uffd_wp(pte)) > + return true; > +#endif > + return false; > +} > + > #endif /* _LINUX_USERFAULTFD_K_H */ > diff --git a/mm/Kconfig b/mm/Kconfig > index 66f23c6c2032..f01c8e0afadf 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -904,6 +904,15 @@ config PTE_MARKER > help > Allows to create marker PTEs for file-backed memory. > > +config PTE_MARKER_UFFD_WP > + bool "Marker PTEs support for userfaultfd write protection" > + depends on PTE_MARKER && HAVE_ARCH_USERFAULTFD_WP > + > + help > + Allows to create marker PTEs for userfaultfd write protection > + purposes. It is required to enable userfaultfd write protection on > + file-backed memory types like shmem and hugetlbfs. > + > source "mm/damon/Kconfig" > > endmenu >