Skip to content

Commit 1460600

Browse files
jpemartinstorvalds
authored andcommitted
device-dax: compound devmap support
Use the newly added compound devmap facility which maps the assigned dax ranges as compound pages at a page size of @align. dax devices are created with a fixed @align (huge page size) which is enforced through as well at mmap() of the device. Faults, consequently happen too at the specified @align specified at the creation, and those don't change throughout dax device lifetime. MCEs unmap a whole dax huge page, as well as splits occurring at the configured page size. Performance measured by gup_test improves considerably for unpin_user_pages() and altmap with NVDIMMs: $ gup_test -f /dev/dax1.0 -m 16384 -r 10 -S -a -n 512 -w (pin_user_pages_fast 2M pages) put:~71 ms -> put:~22 ms [altmap] (pin_user_pages_fast 2M pages) get:~524ms put:~525 ms -> get: ~127ms put:~71ms $ gup_test -f /dev/dax1.0 -m 129022 -r 10 -S -a -n 512 -w (pin_user_pages_fast 2M pages) put:~513 ms -> put:~188 ms [altmap with -m 127004] (pin_user_pages_fast 2M pages) get:~4.1 secs put:~4.12 secs -> get:~1sec put:~563ms .. as well as unpin_user_page_range_dirty_lock() being just as effective as THP/hugetlb[0] pages. [0] https://lore.kernel.org/linux-mm/20210212130843.13865-5-joao.m.martins@oracle.com/ Link: https://lkml.kernel.org/r/20211202204422.26777-12-joao.m.martins@oracle.com Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Jane Chu <jane.chu@oracle.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Muchun Song <songmuchun@bytedance.com> Cc: Naoya Horiguchi <naoya.horiguchi@nec.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6ec228b commit 1460600

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/dax/device.c

+9
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,20 @@ static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn,
7878
{
7979
unsigned long i, nr_pages = fault_size / PAGE_SIZE;
8080
struct file *filp = vmf->vma->vm_file;
81+
struct dev_dax *dev_dax = filp->private_data;
8182
pgoff_t pgoff;
8283

84+
/* mapping is only set on the head */
85+
if (dev_dax->pgmap->vmemmap_shift)
86+
nr_pages = 1;
87+
8388
pgoff = linear_page_index(vmf->vma,
8489
ALIGN(vmf->address, fault_size));
8590

8691
for (i = 0; i < nr_pages; i++) {
8792
struct page *page = pfn_to_page(pfn_t_to_pfn(pfn) + i);
8893

94+
page = compound_head(page);
8995
if (page->mapping)
9096
continue;
9197

@@ -443,6 +449,9 @@ int dev_dax_probe(struct dev_dax *dev_dax)
443449
}
444450

445451
pgmap->type = MEMORY_DEVICE_GENERIC;
452+
if (dev_dax->align > PAGE_SIZE)
453+
pgmap->vmemmap_shift =
454+
order_base_2(dev_dax->align >> PAGE_SHIFT);
446455
addr = devm_memremap_pages(dev, pgmap);
447456
if (IS_ERR(addr))
448457
return PTR_ERR(addr);

0 commit comments

Comments
 (0)