diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2025-02-18 15:22:05 -0700 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2025-02-27 11:55:54 -0700 |
commit | 62fb8adc43afad5fa1c9cadc6f3a8e9fb72af194 (patch) | |
tree | cd05cf84cfb8eb48ea77606a747110ece1d05ee7 /mm/memory.c | |
parent | 0635559233434a337aa1c20d53abae18b3663796 (diff) |
mm: Provide address mask in struct follow_pfnmap_args
follow_pfnmap_start() walks the page table for a given address and
fills out the struct follow_pfnmap_args in pfnmap_args_setup().
The address mask of the page table level is already provided to this
latter function for calculating the pfn. This address mask can also
be useful for the caller to determine the extent of the contiguous
mapping.
For example, vfio-pci now supports huge_fault for pfnmaps and is able
to insert pud and pmd mappings. When we DMA map these pfnmaps, ex.
PCI MMIO BARs, we iterate follow_pfnmap_start() to get each pfn to test
for a contiguous pfn range. Providing the mapping address mask allows
us to skip the extent of the mapping level. Assuming a 1GB pud level
and 4KB page size, iterations are reduced by a factor of 256K. In wall
clock time, mapping a 32GB PCI BAR is reduced from ~1s to <1ms.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: linux-mm@kvack.org
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Tested-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20250218222209.1382449-6-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c index b4d3d4893267..68aa0f11633e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6488,6 +6488,7 @@ static inline void pfnmap_args_setup(struct follow_pfnmap_args *args, args->lock = lock; args->ptep = ptep; args->pfn = pfn_base + ((args->address & ~addr_mask) >> PAGE_SHIFT); + args->addr_mask = addr_mask; args->pgprot = pgprot; args->writable = writable; args->special = special; |