[PATCH 02/12] mm: Convert pXd_devmap checks to vma_is_dax
David Hildenbrand
david at redhat.com
Fri May 30 19:37:21 AEST 2025
On 29.05.25 08:32, Alistair Popple wrote:
> Currently dax is the only user of pmd and pud mapped ZONE_DEVICE
> pages. Therefore page walkers that want to exclude DAX pages can check
> pmd_devmap or pud_devmap. However soon dax will no longer set PFN_DEV,
> meaning dax pages are mapped as normal pages.
>
> Ensure page walkers that currently use pXd_devmap to skip DAX pages
> continue to do so by adding explicit checks of the VMA instead.
>
> Signed-off-by: Alistair Popple <apopple at nvidia.com>
> ---
> fs/userfaultfd.c | 2 +-
> mm/hmm.c | 2 +-
> mm/userfaultfd.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index 22f4bf9..de671d3 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -304,7 +304,7 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx,
> goto out;
>
> ret = false;
> - if (!pmd_present(_pmd) || pmd_devmap(_pmd))
> + if (!pmd_present(_pmd) || vma_is_dax(vmf->vma))
> goto out;
>
> if (pmd_trans_huge(_pmd)) {
> diff --git a/mm/hmm.c b/mm/hmm.c
> index 082f7b7..db12c0a 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -429,7 +429,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end,
> return hmm_vma_walk_hole(start, end, -1, walk);
> }
>
> - if (pud_leaf(pud) && pud_devmap(pud)) {
> + if (pud_leaf(pud) && vma_is_dax(walk->vma)) {
> unsigned long i, npages, pfn;
> unsigned int required_fault;
> unsigned long *hmm_pfns;
> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> index e0db855..133f750 100644
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -1791,7 +1791,7 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start,
>
> ptl = pmd_trans_huge_lock(src_pmd, src_vma);
> if (ptl) {
> - if (pmd_devmap(*src_pmd)) {
> + if (vma_is_dax(src_vma)) {
> spin_unlock(ptl);
> err = -ENOENT;
> break;
I assume we could also just refuse dax folios, right?
If we decide to check VMAs, we should probably check earlier.
But I wonder, what about anonymous non-dax pages in COW mappings? Is it
possible? Not supported?
If supported, checking the actual folio would be the right thing to do.
--
Cheers,
David / dhildenb
More information about the Linuxppc-dev
mailing list