get_user_pages() for dax pte and pmd mappings
Subsystems (43)
v2 cover get_user_pages() for dax pte and pmd mappings
Changes since v1: [1]
1/ Rebase on latest -next (20151209). Fixed up PHYSICAL_PAGE_MASK, but
no other major collisions.
2/ Decreased the transfer size in "dax: increase granularity of
dax_clear_blocks() operations" to get the max latency to reschedule under 1ms and average latency under 150us. (Andrew)
3/ Add cc's for x86 maintainers
4/ Add Tested-by: Logan Gunthorpe
This update, as before, passes the ndctl [2] and nvml [3] test suites.
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-December/003213.html
[2]: https://github.com/pmem/ndctl
[3]: https://github.com/pmem/nvml
A git tree of this set is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm libnvdimm-pending
---
Summary:
To date, we have implemented two I/O usage models for persistent memory, PMEM (a persistent "ram disk") and DAX (mmap persistent memory into userspace). This series adds a third, DAX-GUP, that allows DAX mappings to be the target of direct-i/o. It allows userspace to coordinate DMA/RDMA from/to persistent memory.
The implementation leverages the ZONE_DEVICE mm-zone that went into 4.3-rc1 (also discussed at kernel summit) to flag pages that are owned and dynamically mapped by a device driver. The pmem driver, after mapping a persistent memory range into the system memmap via devm_memremap_pages(), arranges for DAX to distinguish pfn-only versus page-backed pmem-pfns via flags in the new pfn_t type.
The DAX code, upon seeing a PFN_DEV+PFN_MAP flagged pfn, flags the resulting pte(s) inserted into the process page tables with a new _PAGE_DEVMAP flag. Later, when get_user_pages() is walking ptes it keys off _PAGE_DEVMAP to pin the device hosting the page range active. Finally, get_page() and put_page() are modified to take references against the device driver established page mapping.
Finally, this need for "struct page" for persistent memory requires memory capacity to store the memmap array. Given the memmap array for a large pool of persistent may exhaust available DRAM introduce a mechanism to allocate the memmap from persistent memory. The new "struct vmem_altmap *" parameter to devm_memremap_pages() enables arch_add_memory() to use reserved pmem capacity rather than the page allocator.
---
Dan Williams (23):
pmem, dax: clean up clear_pmem()
dax: increase granularity of dax_clear_blocks() operations
dax: guarantee page aligned results from bdev_direct_access()
dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
um: kill pfn_t
kvm: rename pfn_t to kvm_pfn_t
mm, dax, pmem: introduce pfn_t
mm: introduce find_dev_pagemap()
x86, mm: introduce vmem_altmap to augment vmemmap_populate() libnvdimm, pfn, pmem: allocate memmap array in persistent memory
avr32: convert to asm-generic/memory_model.h
hugetlb: fix compile error on tile
frv: fix compiler warning from definition of __pmd() x86, mm: introduce _PAGE_DEVMAP
mm, dax, gpu: convert vm_insert_mixed to pfn_t
mm, dax: convert vmf_insert_pfn_pmd() to pfn_t
list: introduce list_del_poison()
libnvdimm, pmem: move request_queue allocation earlier in probe mm, dax, pmem: introduce {get|put}_dev_pagemap() for dax-gup mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd
mm, x86: get_user_pages() for dax mappings
dax: provide diagnostics for pmd mapping failures
dax: re-enable dax pmd mappings
Ross Zwisler (1):
mm, dax: fix livelock, allow dax pmd mappings to become writeable
Toshi Kani (1):
dax: Split pmd map when fallback on COW
arch/alpha/include/asm/pgtable.h | 1 arch/arm/include/asm/kvm_mmu.h | 5 - arch/arm/kvm/mmu.c | 10 + arch/arm64/include/asm/kvm_mmu.h | 3 arch/avr32/include/asm/page.h | 8 - arch/frv/include/asm/page.h | 2 arch/ia64/include/asm/page.h | 1 arch/ia64/include/asm/pgtable.h | 1 arch/m68k/include/asm/page_mm.h | 1 arch/m68k/include/asm/page_no.h | 1 arch/mips/include/asm/kvm_host.h | 6 - arch/mips/kvm/emulate.c | 2 arch/mips/kvm/tlb.c | 14 + arch/mn10300/include/asm/page.h | 1 arch/parisc/include/asm/pgtable.h | 1 arch/powerpc/include/asm/kvm_book3s.h | 4 arch/powerpc/include/asm/kvm_ppc.h | 2 arch/powerpc/include/asm/pgtable.h | 1 arch/powerpc/kvm/book3s.c | 6 - arch/powerpc/kvm/book3s_32_mmu_host.c | 2 arch/powerpc/kvm/book3s_64_mmu_host.c | 2 arch/powerpc/kvm/e500.h | 2 arch/powerpc/kvm/e500_mmu_host.c | 8 - arch/powerpc/kvm/trace_pr.h | 2 arch/powerpc/sysdev/axonram.c | 8 - arch/sh/include/asm/pgtable-3level.h | 1 arch/sparc/include/asm/pgtable_64.h | 2 arch/tile/include/asm/pgtable.h | 1 arch/um/include/asm/page.h | 7 - arch/um/include/asm/pgtable-3level.h | 5 - arch/um/include/asm/pgtable.h | 2 arch/x86/include/asm/pgtable.h | 26 +++ arch/x86/include/asm/pgtable_types.h | 7 + arch/x86/include/asm/pmem.h | 7 - arch/x86/kvm/iommu.c | 11 + arch/x86/kvm/mmu.c | 37 ++-- arch/x86/kvm/mmu_audit.c | 2 arch/x86/kvm/paging_tmpl.h | 6 - arch/x86/kvm/vmx.c | 2 arch/x86/kvm/x86.c | 2 arch/x86/mm/gup.c | 56 +++++- arch/x86/mm/init_64.c | 32 +++ arch/x86/mm/pat.c | 4 drivers/block/brd.c | 4 drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 drivers/gpu/drm/gma500/framebuffer.c | 3 drivers/gpu/drm/msm/msm_gem.c | 3 drivers/gpu/drm/omapdrm/omap_gem.c | 6 - drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 drivers/nvdimm/pfn_devs.c | 3 drivers/nvdimm/pmem.c | 70 +++++-- drivers/s390/block/dcssblk.c | 10 - fs/Kconfig | 3 fs/block_dev.c | 15 +- fs/dax.c | 290 +++++++++++++++++++---------- include/asm-generic/pgtable.h | 10 + include/linux/blkdev.h | 19 ++ include/linux/huge_mm.h | 15 +- include/linux/hugetlb.h | 1 include/linux/io.h | 15 -- include/linux/kvm_host.h | 37 ++-- include/linux/kvm_types.h | 2 include/linux/list.h | 17 ++ include/linux/memory_hotplug.h | 3 include/linux/mm.h | 310 ++++++++++++++++++++++++++++++- include/linux/mm_types.h | 5 + include/linux/pfn.h | 9 + kernel/memremap.c | 188 ++++++++++++++++++- lib/list_debug.c | 4 mm/gup.c | 18 ++ mm/huge_memory.c | 131 +++++++++---- mm/memory.c | 25 +-- mm/memory_hotplug.c | 66 +++++-- mm/mprotect.c | 5 - mm/page_alloc.c | 10 + mm/pgtable-generic.c | 2 mm/sparse-vmemmap.c | 37 ++++ mm/sparse.c | 8 + mm/swap.c | 15 ++ virt/kvm/kvm_main.c | 47 ++--- 80 files changed, 1300 insertions(+), 416 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 1/25 pmem, dax: clean up clear_pmem()
Both, __dax_pmd_fault, and clear_pmem() were taking special steps to clear memory a page at a time to take advantage of non-temporal clear_page() implementations. However, x86_64 does not use non-temporal instructions for clear_page(), and arch_clear_pmem() was always incurring the cost of __arch_wb_cache_pmem().
Clean up the assumption that doing clear_pmem() a page at a time is more performant.
--- arch/x86/include/asm/pmem.h | 7 +------ fs/dax.c | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/pmem.h +1 -6
@@ -132,12 +132,7 @@ static inline void arch_clear_pmem(void __pmem *addr, size_t size) {void *vaddr = (void __force *)addr; -/* TODO: implement the zeroing via non-temporal writes */ -if (size ==PAGE_SIZE && ((unsigned long )vaddr & ~PAGE_MASK ) ==0 ) -clear_page (vaddr); -else -memset (vaddr,0 , size); - +memset (vaddr,0 , size);__arch_wb_cache_pmem (vaddr, size); }
fs/dax.c +1 -3
@@ -641,9 +641,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, goto fallback;if (buffer_unwritten (&bh) ||buffer_new (&bh)) { -int i; -for (i =0 ; i <PTRS_PER_PMD ; i++) -clear_pmem (kaddr + i *PAGE_SIZE ,PAGE_SIZE ); +clear_pmem (kaddr,PMD_SIZE );wmb_pmem ();count_vm_event (PGMAJFAULT );mem_cgroup_count_vm_event (vma->vm_mm,PGMAJFAULT );
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 2/25 dax: increase granularity of dax_clear_blocks() operations
In reply to Dan Williamsdax_clear_blocks is currently performing a cond_resched() after every PAGE_SIZE memset. We need not check so frequently, for example md-raid only calls cond_resched() at stripe granularity. Also, in preparation for introducing a dax_map_atomic() operation that temporarily pins a dax mapping move the call to cond_resched() to the outer loop.
The worst case latency between calls to cond_resched() after this change is 500us the average latency is 133us. This is up from a 10us max and 4us average.
--- fs/dax.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
fs/dax.c +8 -14
@@ -28,6 +28,7 @@#include <linux/sched.h> #include <linux/uio.h> #include <linux/vmstat.h> +#include <linux/sizes.h> /* * dax_clear_blocks() is called from within transaction context from XFS,
@@ -43,24 +44,17 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)do { void __pmem *addr;unsigned long pfn; -long count; +long count, sz; count =bdev_direct_access (bdev, sector, &addr, &pfn, size);if (count <0 )return count; -BUG_ON (size < count); -while (count >0 ) { -unsigned pgsz =PAGE_SIZE -offset_in_page (addr); -if (pgsz > count) - pgsz = count; -clear_pmem (addr, pgsz); - addr += pgsz; - size -= pgsz; - count -= pgsz; -BUG_ON (pgsz &511 ); - sector += pgsz /512 ; -cond_resched (); - } + sz =min_t (long, count,SZ_128K ); +clear_pmem (addr, sz); + size -= sz; +BUG_ON (sz &511 ); + sector += sz /512 ; +cond_resched (); }while (size);wmb_pmem ();
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 3/25 dax: guarantee page aligned results from bdev_direct_access()
In reply to Dan WilliamsIf a ->direct_access() implementation ever returns a map count less than PAGE_SIZE, catch the error in bdev_direct_access(). This simplifies error checking in upper layers.
--- fs/block_dev.c | 2 ++ fs/dax.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
fs/block_dev.c +2 -0
@@ -489,6 +489,8 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector, avail = ops->direct_access (bdev, sector, addr, pfn);if (!avail)return -ERANGE ; +if (avail >0 && avail & ~PAGE_MASK ) +return -ENXIO ;return min (avail, size); }EXPORT_SYMBOL_GPL (bdev_direct_access);
fs/dax.c +0 -1
@@ -52,7 +52,6 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) sz =min_t (long, count,SZ_128K );clear_pmem (addr, sz); size -= sz; -BUG_ON (sz &511 ); sector += sz /512 ;cond_resched (); }while (size);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 4/25 dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
In reply to Dan WilliamsThe DAX implementation needs to protect new calls to ->direct_access() and usage of its return value against the driver for the underlying block device being disabled. Use blk_queue_enter()/blk_queue_exit() to hold off blk_cleanup_queue() from proceeding, or otherwise fail new mapping requests if the request_queue is being torn down.
This also introduces blk_dax_ctl to simplify the interface from fs/dax.c through dax_map_atomic() to bdev_direct_access().
--- fs/block_dev.c | 13 +-- fs/dax.c | 208 ++++++++++++++++++++++++++++++------------------ include/linux/blkdev.h | 17 +++- 3 files changed, 150 insertions(+), 88 deletions(-)
fs/block_dev.c +5 -8
@@ -450,10 +450,7 @@ EXPORT_SYMBOL_GPL(bdev_write_page);/** * bdev_direct_access() - Get the address for directly-accessibly memory * @bdev: The device containing the memory -* @sector: The offset within the device -* @addr: Where to put the address of the memory -* @pfn: The Page Frame Number for the memory -* @size: The number of bytes requested +* @dax: control and output parameters for ->direct_access * * If a block device is made up of directly addressable memory, this function * will tell the caller the PFN and the address of the memory. The address
@@ -464,10 +461,10 @@ EXPORT_SYMBOL_GPL(bdev_write_page);* Return: negative errno if an error occurs, otherwise the number of bytes * accessible at this address. */ -long bdev_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **addr, unsigned long *pfn, long size) +long bdev_direct_access (struct block_device *bdev,struct blk_dax_ctl *dax) { -long avail; +sector_t sector = dax->sector; +long avail, size = dax->size;const struct block_device_operations *ops = bdev->bd_disk->fops;/*
@@ -486,7 +483,7 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector, sector +=get_start_sect (bdev);if (sector % (PAGE_SIZE /512 ))return -EINVAL ; - avail = ops->direct_access (bdev, sector, addr, pfn); + avail = ops->direct_access (bdev, sector, &dax->addr, &dax->pfn);if (!avail)return -ERANGE ;if (avail >0 && avail & ~PAGE_MASK )
fs/dax.c +130 -78
373 lines not on this page · raw message
include/linux/blkdev.h +15 -2
@@ -1616,6 +1616,20 @@ static inline bool integrity_req_gap_front_merge(struct request *req,#endif /* CONFIG_BLK_DEV_INTEGRITY */ +/** +* struct blk_dax_ctl - control and output parameters for ->direct_access +* @sector: (input) offset relative to a block_device +* @addr: (output) kernel virtual address for @sector populated by driver +* @pfn: (output) page frame number for @addr populated by driver +* @size: (input) number of bytes requested +*/ +struct blk_dax_ctl { +sector_t sector; + void __pmem *addr; +long size; +unsigned long pfn; +}; +struct block_device_operations {int (*open) (struct block_device *,fmode_t );void (*release) (struct gendisk *,fmode_t );
@@ -1642,8 +1656,7 @@ extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,extern int bdev_read_page (struct block_device *,sector_t ,struct page *);extern int bdev_write_page (struct block_device *,sector_t ,struct page *,struct writeback_control *); -extern long bdev_direct_access (struct block_device *,sector_t , - void __pmem **addr, unsigned long *pfn, long size); +extern long bdev_direct_access (struct block_device *,struct blk_dax_ctl *);#else /* CONFIG_BLOCK */ struct block_device ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 4/25 dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
The DAX implementation needs to protect new calls to ->direct_access() and usage of its return value against the driver for the underlying block device being disabled. Use blk_queue_enter()/blk_queue_exit() to hold off blk_cleanup_queue() from proceeding, or otherwise fail new mapping requests if the request_queue is being torn down.
This also introduces blk_dax_ctl to simplify the interface from fs/dax.c through dax_map_atomic() to bdev_direct_access().
---
Changes since v2:
Rebase on latest -next to pick up new definition of blk_queue_enter.
fs/block_dev.c | 13 +-- fs/dax.c | 208 ++++++++++++++++++++++++++++++------------------ include/linux/blkdev.h | 17 +++- 3 files changed, 150 insertions(+), 88 deletions(-)
fs/block_dev.c +5 -8
@@ -450,10 +450,7 @@ EXPORT_SYMBOL_GPL(bdev_write_page);/** * bdev_direct_access() - Get the address for directly-accessibly memory * @bdev: The device containing the memory -* @sector: The offset within the device -* @addr: Where to put the address of the memory -* @pfn: The Page Frame Number for the memory -* @size: The number of bytes requested +* @dax: control and output parameters for ->direct_access * * If a block device is made up of directly addressable memory, this function * will tell the caller the PFN and the address of the memory. The address
@@ -464,10 +461,10 @@ EXPORT_SYMBOL_GPL(bdev_write_page);* Return: negative errno if an error occurs, otherwise the number of bytes * accessible at this address. */ -long bdev_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **addr, unsigned long *pfn, long size) +long bdev_direct_access (struct block_device *bdev,struct blk_dax_ctl *dax) { -long avail; +sector_t sector = dax->sector; +long avail, size = dax->size;const struct block_device_operations *ops = bdev->bd_disk->fops;/*
@@ -486,7 +483,7 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector, sector +=get_start_sect (bdev);if (sector % (PAGE_SIZE /512 ))return -EINVAL ; - avail = ops->direct_access (bdev, sector, addr, pfn); + avail = ops->direct_access (bdev, sector, &dax->addr, &dax->pfn);if (!avail)return -ERANGE ;if (avail >0 && avail & ~PAGE_MASK )
fs/dax.c +130 -78
373 lines not on this page · raw message
include/linux/blkdev.h +15 -2
@@ -1616,6 +1616,20 @@ static inline bool integrity_req_gap_front_merge(struct request *req,#endif /* CONFIG_BLK_DEV_INTEGRITY */ +/** +* struct blk_dax_ctl - control and output parameters for ->direct_access +* @sector: (input) offset relative to a block_device +* @addr: (output) kernel virtual address for @sector populated by driver +* @pfn: (output) page frame number for @addr populated by driver +* @size: (input) number of bytes requested +*/ +struct blk_dax_ctl { +sector_t sector; + void __pmem *addr; +long size; +unsigned long pfn; +}; +struct block_device_operations {int (*open) (struct block_device *,fmode_t );void (*release) (struct gendisk *,fmode_t );
@@ -1642,8 +1656,7 @@ extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,extern int bdev_read_page (struct block_device *,sector_t ,struct page *);extern int bdev_write_page (struct block_device *,sector_t ,struct page *,struct writeback_control *); -extern long bdev_direct_access (struct block_device *,sector_t , - void __pmem **addr, unsigned long *pfn, long size); +extern long bdev_direct_access (struct block_device *,struct blk_dax_ctl *);#else /* CONFIG_BLOCK */ struct block_device ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v3 04/25] dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
Quoted 9 lines · Dan Williams
The DAX implementation needs to protect new calls to ->direct_access() and usage of its return value against the driver for the underlying block device being disabled. Use blk_queue_enter()/blk_queue_exit() to hold off
blk_cleanup_queue()from proceeding, or otherwise fail new mapping requests if therequest_queueis being torn down.This also introduces
blk_dax_ctlto simplify the interface fromfs/dax.cthroughdax_map_atomic()tobdev_direct_access().
Quoted 8 lines
Cc Jan Kara <[email protected]>Cc Jens Axboe <[email protected]>Cc Dave Chinner <[email protected]>Cc Ross Zwisler <[email protected]>Cc Matthew Wilcox <[email protected]>[willy: fix read() of a hole]Reviewed-by Jeff Moyer <[email protected]>Signed-off-by Dan Williams <[email protected]>
<>
Quoted 13 lines
fs/dax.c +2
-5@@ -308,20 +351,18 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, goto out; } - error =bdev_direct_access (bh->b_bdev, sector, &addr, &pfn, bh->b_size); -if (error <0 ) - goto out; -if (error <PAGE_SIZE ) { - error = -EIO ; +if (dax_map_atomic (bdev, &dax) <0 ) { + error =PTR_ERR (dax.addr); goto out; }
fs/dax.c static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, · line 365
Quoted 10 lines
fs/dax.c +3
-2if (buffer_unwritten (bh) ||buffer_new (bh)) { -clear_pmem (addr,PAGE_SIZE ); +clear_pmem (dax.addr,PAGE_SIZE );wmb_pmem (); } +dax_unmap_atomic (bdev, &dax); - error =vm_insert_mixed (vma, vaddr, pfn); + error =vm_insert_mixed (vma, vaddr, dax.pfn);
Since we're still using the contents of the struct blk_dax_ctl as an argument to vm_insert_mixed(), shouldn't dax_unmap_atomic() be after this call?
Unless there is some reason to protect dax.addr with a blk queue reference, but not dax.pfn?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v3 04/25] dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
Quoted 40 lines · Ross Zwisler
Quoted 9 lines · Dan Williams
The DAX implementation needs to protect new calls to ->direct_access() and usage of its return value against the driver for the underlying block device being disabled. Use blk_queue_enter()/blk_queue_exit() to hold off
blk_cleanup_queue()from proceeding, or otherwise fail new mapping requests if therequest_queueis being torn down.This also introduces
blk_dax_ctlto simplify the interface fromfs/dax.cthroughdax_map_atomic()tobdev_direct_access().Quoted 8 lines
Cc Jan Kara <[email protected]>Cc Jens Axboe <[email protected]>Cc Dave Chinner <[email protected]>Cc Ross Zwisler <[email protected]>Cc Matthew Wilcox <[email protected]>[willy: fix read() of a hole]Reviewed-by Jeff Moyer <[email protected]>Signed-off-by Dan Williams <[email protected]><>
Quoted 21 lines
fs/dax.c +4
-6@@ -308,20 +351,18 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, goto out; } - error =bdev_direct_access (bh->b_bdev, sector, &addr, &pfn, bh->b_size); -if (error <0 ) - goto out; -if (error <PAGE_SIZE ) { - error = -EIO ; +if (dax_map_atomic (bdev, &dax) <0 ) { + error =PTR_ERR (dax.addr); goto out; }if (buffer_unwritten (bh) ||buffer_new (bh)) { -clear_pmem (addr,PAGE_SIZE ); +clear_pmem (dax.addr,PAGE_SIZE );wmb_pmem (); } +dax_unmap_atomic (bdev, &dax);
Quoted 8 lines
fs/dax.c static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, · line 365
Quoted 2 lines
fs/dax.c +1
-1- error =vm_insert_mixed (vma, vaddr, pfn); + error =vm_insert_mixed (vma, vaddr, dax.pfn);Since we're still using the contents of the struct
blk_dax_ctlas an argument tovm_insert_mixed(), shouldn'tdax_unmap_atomic()be after this call?Unless there is some reason to protect dax.addr with a blk queue reference, but not dax.pfn?
dax_map_atomic only protects dax.addr which is valid only while the driver is active. dax.pfn is always valid as long as the memory physically exists or is known to reference the same sector of the device.
After the block_device is torn down the pfn may no longer be valid (think brd with dynamically allocated pages, or hot remove of pmem). This is the rationale for this other pending patch series [1] to go shoot down all mappings to a pfn at del_gendisk() time. It relies on dax_map_atomic() to prevent any new mapping requests from succeeding after the shoot down has taken place.
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-December/003065.html
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 5/25 mm, dax: fix livelock, allow dax pmd mappings to become writeable
In reply to Dan WilliamsFrom: Ross Zwisler <[email protected]>
Prior to this change DAX PMD mappings that were made read-only were never able to be made writable again. This is because the code in insert_pfn_pmd() that calls pmd_mkdirty() and pmd_mkwrite() would skip these calls if the PMD already existed in the page table.
Instead, if we are doing a write always mark the PMD entry as dirty and writeable. Without this code we can get into a condition where we mark the PMD as read-only, and then on a subsequent write fault we get into an infinite loop of PMD faults where we try unsuccessfully to make the PMD writeable.
--- mm/huge_memory.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
mm/huge_memory.c +6 -8
@@ -967,15 +967,13 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,spinlock_t *ptl; ptl =pmd_lock (mm, pmd); -if (pmd_none (*pmd)) { - entry =pmd_mkhuge (pfn_pmd (pfn, prot)); -if (write) { - entry =pmd_mkyoung (pmd_mkdirty (entry)); - entry =maybe_pmd_mkwrite (entry, vma); - } -set_pmd_at (mm, addr, pmd, entry); -update_mmu_cache_pmd (vma, addr, pmd); + entry =pmd_mkhuge (pfn_pmd (pfn, prot)); +if (write) { + entry =pmd_mkyoung (pmd_mkdirty (entry)); + entry =maybe_pmd_mkwrite (entry, vma); } +set_pmd_at (mm, addr, pmd, entry); +update_mmu_cache_pmd (vma, addr, pmd);spin_unlock (ptl); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 6/25 dax: Split pmd map when fallback on COW
In reply to Dan WilliamsFrom: Toshi Kani <[email protected]>
An infinite loop of PMD faults was observed when attempted to mlock() a private read-only PMD mmap'd range of a DAX file.
__dax_pmd_fault() simply returns with VM_FAULT_FALLBACK when falling back to PTE on COW. However, __handle_mm_fault() returns without falling back to handle_pte_fault() because a PMD map is present in this case.
Change __dax_pmd_fault() to split the PMD map, if present, before returning with VM_FAULT_FALLBACK.
--- fs/dax.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/dax.c +3 -1
@@ -578,8 +578,10 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,return VM_FAULT_FALLBACK ;/* Fall back to PTEs if we're going to COW */ -if (write && !(vma->vm_flags &VM_SHARED )) +if (write && !(vma->vm_flags &VM_SHARED )) { +split_huge_pmd (vma, pmd, address);return VM_FAULT_FALLBACK ; + }/* If the PMD would extend outside the VMA */ if (pmd_addr < vma->vm_start)return VM_FAULT_FALLBACK ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 7/25 um: kill pfn_t
In reply to Dan WilliamsThe core has developed a need for a "pfn_t" type [1]. Convert the usage of pfn_t by usermode-linux to an unsigned long, and update pfn_to_phys() to drop its expectation of a typed pfn.
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-September/002199.html
--- arch/um/include/asm/page.h | 7 +++---- arch/um/include/asm/pgtable-3level.h | 4 ++-- arch/um/include/asm/pgtable.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-)
arch/um/include/asm/page.h +3 -4
@@ -18,6 +18,7 @@struct page ; +#include <linux/pfn.h> #include <linux/types.h> #include <asm/vm-flags.h>
@@ -52,7 +53,6 @@ typedef struct { unsigned long pgd; } pgd_t;#define pmd_val (x) ((x).pmd)#define __pmd (x) ((pmd_t) { (x) } ) -typedef unsigned long long pfn_t ;typedef unsigned long long phys_t ;#else
@@ -76,7 +76,6 @@ typedef struct { unsigned long pmd; } pmd_t;#define pte_is_zero (p) (!((p).pte & ~_PAGE_NEWPAGE))#define pte_set_val (p, phys, prot) (p).pte = (phys | pgprot_val(prot)) -typedef unsigned long pfn_t ;typedef unsigned long phys_t ;#endif
@@ -109,8 +108,8 @@ extern unsigned long uml_physmem;#define __pa (virt) to_phys((void *) (unsigned long) (virt))#define __va (phys) to_virt((unsigned long) (phys)) -#define phys_to_pfn (p) ((pfn_t) ((p) >> PAGE_SHIFT)) -#define pfn_to_phys (pfn) ((phys_t) ((pfn) << PAGE_SHIFT)) +#define phys_to_pfn (p) ((p) >> PAGE_SHIFT) +#define pfn_to_phys (pfn) PFN_PHYS(pfn)#define pfn_valid (pfn) ((pfn) < max_mapnr)#define virt_addr_valid (v) pfn_valid(phys_to_pfn(__pa(v)))
arch/um/include/asm/pgtable-3level.h +2 -2
@@ -98,7 +98,7 @@ static inline unsigned long pte_pfn(pte_t pte)return phys_to_pfn (pte_val (pte)); } -static inline pte_t pfn_pte (pfn_t page_nr,pgprot_t pgprot) +static inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) {pte_t pte;phys_t phys =pfn_to_phys (page_nr);
@@ -107,7 +107,7 @@ static inline pte_t pfn_pte(pfn_t page_nr, pgprot_t pgprot)return pte; } -static inline pmd_t pfn_pmd (pfn_t page_nr,pgprot_t pgprot) +static inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot) {return __pmd ((page_nr <<PAGE_SHIFT ) |pgprot_val (pgprot)); }
arch/um/include/asm/pgtable.h +1 -1
@@ -271,7 +271,7 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b)#define phys_to_page (phys) pfn_to_page(phys_to_pfn(phys))#define __virt_to_page (virt) phys_to_page(__pa(virt)) -#define page_to_phys (page) pfn_to_phys((pfn_t) page_to_pfn(page)) +#define page_to_phys (page) pfn_to_phys(page_to_pfn(page))#define virt_to_page (addr) __virt_to_page((const unsigned long) addr)#define mk_pte (page, pgprot) \
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 8/25 kvm: rename pfn_t to kvm_pfn_t
In reply to Dan WilliamsThe core has developed a need for a "pfn_t" type [1]. Move the existing pfn_t in KVM to kvm_pfn_t [2].
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-September/002199.html
[2]: https://lists.01.org/pipermail/linux-nvdimm/2015-September/002218.html
--- arch/arm/include/asm/kvm_mmu.h | 5 ++-- arch/arm/kvm/mmu.c | 10 ++++--- arch/arm64/include/asm/kvm_mmu.h | 3 +- arch/mips/include/asm/kvm_host.h | 6 ++-- arch/mips/kvm/emulate.c | 2 + arch/mips/kvm/tlb.c | 14 +++++----- arch/powerpc/include/asm/kvm_book3s.h | 4 +-- arch/powerpc/include/asm/kvm_ppc.h | 2 + arch/powerpc/kvm/book3s.c | 6 ++-- arch/powerpc/kvm/book3s_32_mmu_host.c | 2 + arch/powerpc/kvm/book3s_64_mmu_host.c | 2 + arch/powerpc/kvm/e500.h | 2 + arch/powerpc/kvm/e500_mmu_host.c | 8 +++--- arch/powerpc/kvm/trace_pr.h | 2 + arch/x86/kvm/iommu.c | 11 ++++---- arch/x86/kvm/mmu.c | 37 +++++++++++++------------- arch/x86/kvm/mmu_audit.c | 2 + arch/x86/kvm/paging_tmpl.h | 6 ++-- arch/x86/kvm/vmx.c | 2 + arch/x86/kvm/x86.c | 2 + include/linux/kvm_host.h | 37 +++++++++++++------------- include/linux/kvm_types.h | 2 + virt/kvm/kvm_main.c | 47 +++++++++++++++++---------------- 23 files changed, 110 insertions(+), 104 deletions(-)
arch/arm/include/asm/kvm_mmu.h +3 -2
@@ -182,7 +182,8 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)return (vcpu->arch.cp15[c1_SCTLR] &0b101 ) ==0b101 ; } -static inline void __coherent_cache_guest_page (struct kvm_vcpu *vcpu,pfn_t pfn, +static inline void __coherent_cache_guest_page (struct kvm_vcpu *vcpu, +kvm_pfn_t pfn,unsigned long size,bool ipa_uncached) {
@@ -246,7 +247,7 @@ static inline void __kvm_flush_dcache_pte(pte_t pte)static inline void __kvm_flush_dcache_pmd (pmd_t pmd) {unsigned long size =PMD_SIZE ; -pfn_t pfn =pmd_pfn (pmd); +kvm_pfn_t pfn =pmd_pfn (pmd);while (size) {void *va =kmap_atomic_pfn (pfn);
arch/arm/kvm/mmu.c +5 -5
@@ -992,9 +992,9 @@ out:return ret; } -static bool transparent_hugepage_adjust (pfn_t *pfnp,phys_addr_t *ipap) +static bool transparent_hugepage_adjust (kvm_pfn_t *pfnp,phys_addr_t *ipap) { -pfn_t pfn = *pfnp; +kvm_pfn_t pfn = *pfnp;gfn_t gfn = *ipap >>PAGE_SHIFT ;if (PageTransCompound (pfn_to_page (pfn))) {
@@ -1201,7 +1201,7 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,kvm_mmu_write_protect_pt_masked (kvm, slot, gfn_offset, mask); } -static void coherent_cache_guest_page (struct kvm_vcpu *vcpu,pfn_t pfn, +static void coherent_cache_guest_page (struct kvm_vcpu *vcpu,kvm_pfn_t pfn,unsigned long size,bool uncached) {__coherent_cache_guest_page (vcpu, pfn, size, uncached);
@@ -1218,7 +1218,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,struct kvm *kvm = vcpu->kvm;struct kvm_mmu_memory_cache *memcache = &vcpu->arch.mmu_page_cache;struct vm_area_struct *vma; -pfn_t pfn; +kvm_pfn_t pfn;pgprot_t mem_type =PAGE_S2 ;bool fault_ipa_uncached;bool logging_active =memslot_is_logging (memslot);
@@ -1346,7 +1346,7 @@ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) {pmd_t *pmd;pte_t *pte; -pfn_t pfn; +kvm_pfn_t pfn;bool pfn_valid = false;trace_kvm_access_fault (fault_ipa);
arch/arm64/include/asm/kvm_mmu.h +2 -1
@@ -230,7 +230,8 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)return (vcpu_sys_reg (vcpu,SCTLR_EL1 ) &0b101 ) ==0b101 ; } -static inline void __coherent_cache_guest_page (struct kvm_vcpu *vcpu,pfn_t pfn, +static inline void __coherent_cache_guest_page (struct kvm_vcpu *vcpu, +kvm_pfn_t pfn,unsigned long size,bool ipa_uncached) {
arch/mips/include/asm/kvm_host.h +3 -3
@@ -101,9 +101,9 @@#define CAUSEF_DC (_ULCAST_(1) << 27)extern atomic_t kvm_mips_instance; -extern pfn_t (*kvm_mips_gfn_to_pfn) (struct kvm *kvm,gfn_t gfn); -extern void (*kvm_mips_release_pfn_clean) (pfn_t pfn); -extern bool (*kvm_mips_is_error_pfn) (pfn_t pfn); +extern kvm_pfn_t (*kvm_mips_gfn_to_pfn)(struct kvm *kvm,gfn_t gfn); +extern void (*kvm_mips_release_pfn_clean)(kvm_pfn_t pfn); +extern bool (*kvm_mips_is_error_pfn)(kvm_pfn_t pfn);struct kvm_vm_stat {u32 remote_tlb_flush;
arch/mips/kvm/emulate.c +1 -1
@@ -1525,7 +1525,7 @@ int kvm_mips_sync_icache(unsigned long va, struct kvm_vcpu *vcpu)struct kvm *kvm = vcpu->kvm;unsigned long pa;gfn_t gfn; -pfn_t pfn; +kvm_pfn_t pfn; gfn = va >>PAGE_SHIFT ;
arch/mips/kvm/tlb.c +7 -7
@@ -38,13 +38,13 @@ atomic_t kvm_mips_instance;EXPORT_SYMBOL (kvm_mips_instance);/* These function pointers are initialized once the KVM module is loaded */ -pfn_t (*kvm_mips_gfn_to_pfn)(struct kvm *kvm,gfn_t gfn); +kvm_pfn_t (*kvm_mips_gfn_to_pfn)(struct kvm *kvm,gfn_t gfn);EXPORT_SYMBOL (kvm_mips_gfn_to_pfn); -void (*kvm_mips_release_pfn_clean)(pfn_t pfn); +void (*kvm_mips_release_pfn_clean)(kvm_pfn_t pfn);EXPORT_SYMBOL (kvm_mips_release_pfn_clean); -bool (*kvm_mips_is_error_pfn)(pfn_t pfn); +bool (*kvm_mips_is_error_pfn)(kvm_pfn_t pfn);EXPORT_SYMBOL (kvm_mips_is_error_pfn);uint32_t kvm_mips_get_kernel_asid (struct kvm_vcpu *vcpu)
@@ -144,7 +144,7 @@ EXPORT_SYMBOL(kvm_mips_dump_guest_tlbs);static int kvm_mips_map_page (struct kvm *kvm,gfn_t gfn) {int srcu_idx, err =0 ; -pfn_t pfn; +kvm_pfn_t pfn;if (kvm->arch.guest_pmap[gfn] !=KVM_INVALID_PAGE )return 0 ;
@@ -262,7 +262,7 @@ int kvm_mips_handle_kseg0_tlb_fault(unsigned long badvaddr, struct kvm_vcpu *vcpu) {gfn_t gfn; -pfn_t pfn0, pfn1; +kvm_pfn_t pfn0, pfn1;unsigned long vaddr =0 ;unsigned long entryhi =0 , entrylo0 =0 , entrylo1 =0 ;int even;
@@ -313,7 +313,7 @@ EXPORT_SYMBOL(kvm_mips_handle_kseg0_tlb_fault);int kvm_mips_handle_commpage_tlb_fault (unsigned long badvaddr,struct kvm_vcpu *vcpu) { -pfn_t pfn0, pfn1; +kvm_pfn_t pfn0, pfn1;unsigned long flags, old_entryhi =0 , vaddr =0 ;unsigned long entrylo0 =0 , entrylo1 =0 ;
@@ -360,7 +360,7 @@ int kvm_mips_handle_mapped_seg_tlb_fault(struct kvm_vcpu *vcpu, {unsigned long entryhi =0 , entrylo0 =0 , entrylo1 =0 ;struct kvm *kvm = vcpu->kvm; -pfn_t pfn0, pfn1; +kvm_pfn_t pfn0, pfn1;if ((tlb->tlb_hi &VPN2_MASK ) ==0 ) { pfn0 =0 ;
arch/powerpc/include/asm/kvm_book3s.h +2 -2
@@ -154,8 +154,8 @@ extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, bool upper, u32 val);extern void kvmppc_giveup_ext (struct kvm_vcpu *vcpu,ulong msr);extern int kvmppc_emulate_paired_single (struct kvm_run *run,struct kvm_vcpu *vcpu); -extern pfn_t kvmppc_gpa_to_pfn (struct kvm_vcpu *vcpu,gpa_t gpa,bool writing, -bool *writable); +extern kvm_pfn_t kvmppc_gpa_to_pfn (struct kvm_vcpu *vcpu,gpa_t gpa, +bool writing,bool *writable);extern void kvmppc_add_revmap_chain (struct kvm *kvm,struct revmap_entry *rev,unsigned long *rmap,long pte_index,int realmode);extern void kvmppc_update_rmap_change (unsigned long *rmap,unsigned long psize);
arch/powerpc/include/asm/kvm_ppc.h +1 -1
@@ -515,7 +515,7 @@ void kvmppc_claim_lpid(long lpid);void kvmppc_free_lpid (long lpid);void kvmppc_init_lpid (unsigned long nr_lpids); -static inline void kvmppc_mmu_flush_icache (pfn_t pfn) +static inline void kvmppc_mmu_flush_icache (kvm_pfn_t pfn) {struct page *page;/*
arch/powerpc/kvm/book3s.c +3 -3
@@ -366,7 +366,7 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu) }EXPORT_SYMBOL_GPL (kvmppc_core_prepare_to_enter); -pfn_t kvmppc_gpa_to_pfn (struct kvm_vcpu *vcpu,gpa_t gpa,bool writing, +kvm_pfn_t kvmppc_gpa_to_pfn (struct kvm_vcpu *vcpu,gpa_t gpa,bool writing,bool *writable) {ulong mp_pa = vcpu->arch.magic_page_pa &KVM_PAM ;
@@ -379,9 +379,9 @@ pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa, bool writing, gpa &= ~0xFFFULL ;if (unlikely (mp_pa) &&unlikely ((gpa &KVM_PAM ) == mp_pa)) {ulong shared_page = ((ulong )vcpu->arch.shared) &PAGE_MASK ; -pfn_t pfn; +kvm_pfn_t pfn; - pfn = (pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ; + pfn = (kvm_pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ;get_page (pfn_to_page (pfn));if (writable) *writable = true;
arch/powerpc/kvm/book3s_32_mmu_host.c +1 -1
@@ -142,7 +142,7 @@ extern char etext[];int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte,bool iswrite) { -pfn_t hpaddr; +kvm_pfn_t hpaddr;u64 vpn;u64 vsid;struct kvmppc_sid_map *map;
arch/powerpc/kvm/book3s_64_mmu_host.c +1 -1
@@ -83,7 +83,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte, bool iswrite) {unsigned long vpn; -pfn_t hpaddr; +kvm_pfn_t hpaddr;ulong hash, hpteg;u64 vsid;int ret;
arch/powerpc/kvm/e500.h +1 -1
@@ -41,7 +41,7 @@ enum vcpu_ftr {#define E500_TLB_MAS2_ATTR (0x7f)struct tlbe_ref { -pfn_t pfn;/* valid only for TLB0, except briefly */ +kvm_pfn_t pfn;/* valid only for TLB0, except briefly */ unsigned int flags;/* E500_TLB_* */ };
arch/powerpc/kvm/e500_mmu_host.c +4 -4
@@ -163,9 +163,9 @@ void kvmppc_map_magic(struct kvm_vcpu *vcpu)struct kvm_book3e_206_tlb_entry magic;ulong shared_page = ((ulong )vcpu->arch.shared) &PAGE_MASK ;unsigned int stid; -pfn_t pfn; +kvm_pfn_t pfn; - pfn = (pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ; + pfn = (kvm_pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ;get_page (pfn_to_page (pfn));preempt_disable ();
@@ -246,7 +246,7 @@ static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe)static inline void kvmppc_e500_ref_setup (struct tlbe_ref *ref,struct kvm_book3e_206_tlb_entry *gtlbe, -pfn_t pfn,unsigned int wimg) +kvm_pfn_t pfn,unsigned int wimg) { ref->pfn = pfn; ref->flags =E500_TLB_VALID ;
@@ -309,7 +309,7 @@ static void kvmppc_e500_setup_stlbe( int tsize, struct tlbe_ref *ref, u64 gvaddr, struct kvm_book3e_206_tlb_entry *stlbe) { - pfn_t pfn = ref->pfn; + kvm_pfn_t pfn = ref->pfn;u32 pr = vcpu->arch.shared->msr &MSR_PR ;BUG_ON (!(ref->flags &E500_TLB_VALID ));
arch/powerpc/kvm/trace_pr.h +1 -1
@@ -30,7 +30,7 @@ TRACE_EVENT(kvm_book3s_reenter,#ifdef CONFIG_PPC_BOOK3S_64 TRACE_EVENT(kvm_book3s_64_mmu_map, - TP_PROTO(int rflags, ulong hpteg, ulong va, pfn_t hpaddr, + TP_PROTO(int rflags, ulong hpteg, ulong va, kvm_pfn_t hpaddr, struct kvmppc_pte *orig_pte), TP_ARGS(rflags, hpteg, va, hpaddr, orig_pte),
arch/x86/kvm/iommu.c +6 -5
@@ -43,11 +43,11 @@ static int kvm_iommu_unmap_memslots(struct kvm *kvm);static void kvm_iommu_put_pages (struct kvm *kvm,gfn_t base_gfn,unsigned long npages); -static pfn_t kvm_pin_pages (struct kvm_memory_slot *slot,gfn_t gfn, +static kvm_pfn_t kvm_pin_pages (struct kvm_memory_slot *slot,gfn_t gfn,unsigned long npages) {gfn_t end_gfn; -pfn_t pfn; +kvm_pfn_t pfn; pfn =gfn_to_pfn_memslot (slot, gfn); end_gfn = gfn + npages;
@@ -62,7 +62,8 @@ static pfn_t kvm_pin_pages(struct kvm_memory_slot *slot, gfn_t gfn,return pfn; } -static void kvm_unpin_pages (struct kvm *kvm,pfn_t pfn,unsigned long npages) +static void kvm_unpin_pages (struct kvm *kvm,kvm_pfn_t pfn, +unsigned long npages) {unsigned long i;
@@ -73,7 +74,7 @@ static void kvm_unpin_pages(struct kvm *kvm, pfn_t pfn, unsigned long npages)int kvm_iommu_map_pages (struct kvm *kvm,struct kvm_memory_slot *slot) {gfn_t gfn, end_gfn; -pfn_t pfn; +kvm_pfn_t pfn;int r =0 ;struct iommu_domain *domain = kvm->arch.iommu_domain;int flags;
@@ -275,7 +276,7 @@ static void kvm_iommu_put_pages(struct kvm *kvm, {struct iommu_domain *domain;gfn_t end_gfn, gfn; -pfn_t pfn; +kvm_pfn_t pfn;u64 phys; domain = kvm->arch.iommu_domain;
arch/x86/kvm/mmu.c +19 -18
@@ -259,7 +259,7 @@ static unsigned get_mmio_spte_access(u64 spte) }static bool set_mmio_spte (struct kvm_vcpu *vcpu,u64 *sptep,gfn_t gfn, -pfn_t pfn,unsigned access) +kvm_pfn_t pfn,unsigned access) {if (unlikely (is_noslot_pfn (pfn))) {mark_mmio_spte (vcpu, sptep, gfn, access);
@@ -320,7 +320,7 @@ static int is_last_spte(u64 pte, int level)return 0 ; } -static pfn_t spte_to_pfn (u64 pte) +static kvm_pfn_t spte_to_pfn (u64 pte) {return (pte &PT64_BASE_ADDR_MASK ) >>PAGE_SHIFT ; }
@@ -582,7 +582,7 @@ static bool mmu_spte_update(u64 *sptep, u64 new_spte)*/ static int mmu_spte_clear_track_bits (u64 *sptep) { -pfn_t pfn; +kvm_pfn_t pfn;u64 old_spte = *sptep;if (!spte_has_volatile_bits (old_spte))
@@ -1372,7 +1372,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,int need_flush =0 ;u64 new_spte;pte_t *ptep = (pte_t *)data; -pfn_t new_pfn; +kvm_pfn_t new_pfn;WARN_ON (pte_huge (*ptep)); new_pfn =pte_pfn (*ptep);
@@ -2458,7 +2458,7 @@ static int mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,return 0 ; } -static bool kvm_is_mmio_pfn (pfn_t pfn) +static bool kvm_is_mmio_pfn (kvm_pfn_t pfn) {if (pfn_valid (pfn))return !is_zero_pfn (pfn) &&PageReserved (pfn_to_page (pfn));
@@ -2468,7 +2468,7 @@ static bool kvm_is_mmio_pfn(pfn_t pfn)static int set_spte (struct kvm_vcpu *vcpu,u64 *sptep,unsigned pte_access,int level, -gfn_t gfn,pfn_t pfn,bool speculative, +gfn_t gfn,kvm_pfn_t pfn,bool speculative,bool can_unsync,bool host_writable) {u64 spte;
@@ -2547,7 +2547,7 @@ done: }static bool mmu_set_spte (struct kvm_vcpu *vcpu,u64 *sptep,unsigned pte_access, -int write_fault,int level,gfn_t gfn,pfn_t pfn, +int write_fault,int level,gfn_t gfn,kvm_pfn_t pfn,bool speculative,bool host_writable) {int was_rmapped =0 ;
@@ -2610,7 +2610,7 @@ static bool mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, unsigned pte_access,return emulate; } -static pfn_t pte_prefetch_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn, +static kvm_pfn_t pte_prefetch_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn,bool no_dirty_log) {struct kvm_memory_slot *slot;
@@ -2692,7 +2692,7 @@ static void direct_pte_prefetch(struct kvm_vcpu *vcpu, u64 *sptep) }static int __direct_map (struct kvm_vcpu *vcpu,int write,int map_writable, -int level,gfn_t gfn,pfn_t pfn,bool prefault) +int level,gfn_t gfn,kvm_pfn_t pfn,bool prefault) {struct kvm_shadow_walk_iterator iterator;struct kvm_mmu_page *sp;
@@ -2740,7 +2740,7 @@ static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct *send_sig_info (SIGBUS , &info, tsk); } -static int kvm_handle_bad_page (struct kvm_vcpu *vcpu,gfn_t gfn,pfn_t pfn) +static int kvm_handle_bad_page (struct kvm_vcpu *vcpu,gfn_t gfn,kvm_pfn_t pfn) {/* * Do not cache the mmio info caused by writing the readonly gfn
@@ -2760,9 +2760,10 @@ static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, pfn_t pfn) }static void transparent_hugepage_adjust (struct kvm_vcpu *vcpu, -gfn_t *gfnp,pfn_t *pfnp,int *levelp) +gfn_t *gfnp,kvm_pfn_t *pfnp, +int *levelp) { -pfn_t pfn = *pfnp; +kvm_pfn_t pfn = *pfnp;gfn_t gfn = *gfnp;int level = *levelp;
@@ -2801,7 +2802,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu, }static bool handle_abnormal_pfn (struct kvm_vcpu *vcpu,gva_t gva,gfn_t gfn, -pfn_t pfn,unsigned access,int *ret_val) +kvm_pfn_t pfn,unsigned access,int *ret_val) {bool ret = true;
@@ -2955,7 +2956,7 @@ exit: }static bool try_async_pf (struct kvm_vcpu *vcpu,bool prefault,gfn_t gfn, -gva_t gva,pfn_t *pfn,bool write,bool *writable); +gva_t gva,kvm_pfn_t *pfn,bool write,bool *writable);static void make_mmu_pages_available (struct kvm_vcpu *vcpu); static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,
@@ -2964,7 +2965,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,int r;int level;bool force_pt_level = false; -pfn_t pfn; +kvm_pfn_t pfn;unsigned long mmu_seq;bool map_writable, write = error_code &PFERR_WRITE_MASK ;
@@ -3418,7 +3419,7 @@ static bool can_do_async_pf(struct kvm_vcpu *vcpu) }static bool try_async_pf (struct kvm_vcpu *vcpu,bool prefault,gfn_t gfn, -gva_t gva,pfn_t *pfn,bool write,bool *writable) +gva_t gva,kvm_pfn_t *pfn,bool write,bool *writable) {struct kvm_memory_slot *slot;bool async;
@@ -3456,7 +3457,7 @@ check_hugepage_cache_consistency(struct kvm_vcpu *vcpu, gfn_t gfn, int level)static int tdp_page_fault (struct kvm_vcpu *vcpu,gva_t gpa,u32 error_code,bool prefault) { -pfn_t pfn; +kvm_pfn_t pfn;int r;int level;bool force_pt_level;
@@ -4607,7 +4608,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,u64 *sptep;struct rmap_iterator iter;int need_tlb_flush =0 ; -pfn_t pfn; +kvm_pfn_t pfn;struct kvm_mmu_page *sp; restart:
arch/x86/kvm/mmu_audit.c +1 -1
@@ -97,7 +97,7 @@ static void audit_mappings(struct kvm_vcpu *vcpu, u64 *sptep, int level) {struct kvm_mmu_page *sp;gfn_t gfn; -pfn_t pfn; +kvm_pfn_t pfn;hpa_t hpa; sp =page_header (__pa (sptep));
arch/x86/kvm/paging_tmpl.h +3 -3
@@ -456,7 +456,7 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, {unsigned pte_access;gfn_t gfn; -pfn_t pfn; +kvm_pfn_t pfn;if (FNAME (prefetch_invalid_gpte)(vcpu, sp, spte, gpte))return false;
@@ -551,7 +551,7 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw,static int FNAME (fetch )(struct kvm_vcpu *vcpu,gva_t addr,struct guest_walker *gw,int write_fault,int hlevel, -pfn_t pfn,bool map_writable,bool prefault) +kvm_pfn_t pfn,bool map_writable,bool prefault) {struct kvm_mmu_page *sp =NULL ;struct kvm_shadow_walk_iterator it;
@@ -694,7 +694,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code,int user_fault = error_code &PFERR_USER_MASK ;struct guest_walker walker;int r; -pfn_t pfn; +kvm_pfn_t pfn;int level =PT_PAGE_TABLE_LEVEL ;bool force_pt_level = false;unsigned long mmu_seq;
arch/x86/kvm/vmx.c +1 -1
@@ -4185,7 +4185,7 @@ out:static int init_rmode_identity_map (struct kvm *kvm) {int i, idx, r =0 ; -pfn_t identity_map_pfn; +kvm_pfn_t identity_map_pfn;u32 tmp;if (!enable_ept)
arch/x86/kvm/x86.c +1 -1
@@ -5129,7 +5129,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, int emulation_type) {gpa_t gpa = cr2; -pfn_t pfn; +kvm_pfn_t pfn;if (emulation_type &EMULTYPE_NO_REEXECUTE )return false;
include/linux/kvm_host.h +19 -18
@@ -66,7 +66,7 @@* error pfns indicate that the gfn is in slot but faild to * translate it to pfn on host. */ -static inline bool is_error_pfn (pfn_t pfn) +static inline bool is_error_pfn (kvm_pfn_t pfn) {return !!(pfn &KVM_PFN_ERR_MASK ); }
@@ -76,13 +76,13 @@ static inline bool is_error_pfn(pfn_t pfn)* translated to pfn - it is not in slot or failed to * translate it to pfn. */ -static inline bool is_error_noslot_pfn (pfn_t pfn) +static inline bool is_error_noslot_pfn (kvm_pfn_t pfn) {return !!(pfn &KVM_PFN_ERR_NOSLOT_MASK ); }/* noslot pfn indicates that the gfn is not in slot. */ -static inline bool is_noslot_pfn (pfn_t pfn) +static inline bool is_noslot_pfn (kvm_pfn_t pfn) {return pfn ==KVM_PFN_NOSLOT ; }
@@ -614,19 +614,20 @@ void kvm_release_page_clean(struct page *page);void kvm_release_page_dirty (struct page *page);void kvm_set_page_accessed (struct page *page); -pfn_t gfn_to_pfn_atomic (struct kvm *kvm,gfn_t gfn); -pfn_t gfn_to_pfn (struct kvm *kvm,gfn_t gfn); -pfn_t gfn_to_pfn_prot (struct kvm *kvm,gfn_t gfn,bool write_fault, +kvm_pfn_t gfn_to_pfn_atomic (struct kvm *kvm,gfn_t gfn); +kvm_pfn_t gfn_to_pfn (struct kvm *kvm,gfn_t gfn); +kvm_pfn_t gfn_to_pfn_prot (struct kvm *kvm,gfn_t gfn,bool write_fault,bool *writable); -pfn_t gfn_to_pfn_memslot (struct kvm_memory_slot *slot,gfn_t gfn); -pfn_t gfn_to_pfn_memslot_atomic (struct kvm_memory_slot *slot,gfn_t gfn); -pfn_t __gfn_to_pfn_memslot (struct kvm_memory_slot *slot,gfn_t gfn,bool atomic, -bool *async,bool write_fault,bool *writable); +kvm_pfn_t gfn_to_pfn_memslot (struct kvm_memory_slot *slot,gfn_t gfn); +kvm_pfn_t gfn_to_pfn_memslot_atomic (struct kvm_memory_slot *slot,gfn_t gfn); +kvm_pfn_t __gfn_to_pfn_memslot (struct kvm_memory_slot *slot,gfn_t gfn, +bool atomic,bool *async,bool write_fault, +bool *writable); -void kvm_release_pfn_clean (pfn_t pfn); -void kvm_set_pfn_dirty (pfn_t pfn); -void kvm_set_pfn_accessed (pfn_t pfn); -void kvm_get_pfn (pfn_t pfn); +void kvm_release_pfn_clean (kvm_pfn_t pfn); +void kvm_set_pfn_dirty (kvm_pfn_t pfn); +void kvm_set_pfn_accessed (kvm_pfn_t pfn); +void kvm_get_pfn (kvm_pfn_t pfn);int kvm_read_guest_page (struct kvm *kvm,gfn_t gfn,void *data,int offset,int len);
@@ -652,8 +653,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn);struct kvm_memslots *kvm_vcpu_memslots (struct kvm_vcpu *vcpu);struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot (struct kvm_vcpu *vcpu,gfn_t gfn); -pfn_t kvm_vcpu_gfn_to_pfn_atomic (struct kvm_vcpu *vcpu,gfn_t gfn); -pfn_t kvm_vcpu_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn); +kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic (struct kvm_vcpu *vcpu,gfn_t gfn); +kvm_pfn_t kvm_vcpu_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn);unsigned long kvm_vcpu_gfn_to_hva (struct kvm_vcpu *vcpu,gfn_t gfn);unsigned long kvm_vcpu_gfn_to_hva_prot (struct kvm_vcpu *vcpu,gfn_t gfn,bool *writable);
@@ -836,7 +837,7 @@ void kvm_arch_sync_events(struct kvm *kvm);int kvm_cpu_has_pending_timer (struct kvm_vcpu *vcpu);void kvm_vcpu_kick (struct kvm_vcpu *vcpu); -bool kvm_is_reserved_pfn (pfn_t pfn); +bool kvm_is_reserved_pfn (kvm_pfn_t pfn);struct kvm_irq_ack_notifier {struct hlist_node link;
@@ -990,7 +991,7 @@ static inline gfn_t gpa_to_gfn(gpa_t gpa)return (gfn_t)(gpa >>PAGE_SHIFT ); } -static inline hpa_t pfn_to_hpa (pfn_t pfn) +static inline hpa_t pfn_to_hpa (kvm_pfn_t pfn) {return (hpa_t )pfn <<PAGE_SHIFT ; }
include/linux/kvm_types.h +1 -1
@@ -53,7 +53,7 @@ typedef unsigned long hva_t;typedef u64 hpa_t ;typedef u64 hfn_t ; -typedef hfn_t pfn_t ; +typedef hfn_t kvm_pfn_t ;struct gfn_to_hva_cache {u64 generation;
virt/kvm/kvm_main.c +24 -23
170 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 9/25 mm, dax, pmem: introduce pfn_t
In reply to Dan WilliamsFor the purpose of communicating the optional presence of a 'struct page' for the pfn returned from ->direct_access(), introduce a type that encapsulates a page-frame-number plus flags. These flags contain the historical "page_link" encoding for a scatterlist entry, but can also denote "device memory". Where "device memory" is a set of pfns that are not part of the kernel's linear mapping by default, but are accessed via the same memory controller as ram.
The motivation for this new type is large capacity persistent memory that needs struct page entries in the 'memmap' to support 3rd party DMA (i.e. O_DIRECT I/O with a persistent memory source/target). However, we also need it in support of maintaining a list of mapped inodes which need to be unmapped at driver teardown or freeze_bdev() time.
--- arch/powerpc/sysdev/axonram.c | 8 ++--- drivers/block/brd.c | 4 +- drivers/nvdimm/pmem.c | 12 +++++-- drivers/s390/block/dcssblk.c | 10 ++---- fs/dax.c | 10 ++++-- include/linux/blkdev.h | 4 +- include/linux/mm.h | 66 +++++++++++++++++++++++++++++++++++++++++ include/linux/pfn.h | 9 ++++++ 8 files changed, 100 insertions(+), 23 deletions(-)
arch/powerpc/sysdev/axonram.c +3 -5
@@ -142,15 +142,13 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)*/ static long axon_ram_direct_access (struct block_device *device,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct axon_ram_bank *bank = device->bd_disk->private_data;loff_t offset = (loff_t )sector <<AXON_RAM_SECTOR_SHIFT ; -void *addr = (void *)(bank->ph_addr + offset); - - *kaddr = (void __pmem *)addr; - *pfn =virt_to_phys (addr) >>PAGE_SHIFT ; + *kaddr = (void __pmem __force *) bank->io_addr + offset; + *pfn =phys_to_pfn_t (bank->ph_addr + offset,PFN_DEV );return bank->size - offset; }
drivers/block/brd.c +2 -2
@@ -378,7 +378,7 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector,#ifdef CONFIG_BLK_DEV_RAM_DAX static long brd_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct brd_device *brd = bdev->bd_disk->private_data;struct page *page;
@@ -389,7 +389,7 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector,if (!page)return -ENOSPC ; *kaddr = (void __pmem *)page_address(page); - *pfn =page_to_pfn (page); + *pfn =page_to_pfn_t (page);return PAGE_SIZE ; }
drivers/nvdimm/pmem.c +8 -4
@@ -39,6 +39,7 @@ struct pmem_device {phys_addr_t phys_addr;/* when non-zero this device is hosting a 'pfn' instance */ phys_addr_t data_offset; +unsigned long pfn_flags; void __pmem *virt_addr;size_t size; };
@@ -101,13 +102,13 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, }static long pmem_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct pmem_device *pmem = bdev->bd_disk->private_data;resource_size_t offset = sector *512 + pmem->data_offset; *kaddr = pmem->virt_addr + offset; - *pfn = (pmem->phys_addr + offset) >>PAGE_SHIFT ; + *pfn =phys_to_pfn_t (pmem->phys_addr + offset, pmem->pfn_flags);return pmem->size - offset; }
@@ -140,9 +141,11 @@ static struct pmem_device *pmem_alloc(struct device *dev,return ERR_PTR (-EBUSY ); } -if (pmem_should_map_pages (dev)) + pmem->pfn_flags =PFN_DEV ; +if (pmem_should_map_pages (dev)) { pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res); -else + pmem->pfn_flags |=PFN_MAP ; + }else pmem->virt_addr = (void __pmem *) devm_memremap(dev, pmem->phys_addr, pmem->size,ARCH_MEMREMAP_PMEM );
@@ -353,6 +356,7 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns) pmem =dev_get_drvdata (dev);devm_memunmap (dev, (void __force *) pmem->virt_addr); pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res); + pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr); goto err;
drivers/s390/block/dcssblk.c +4 -6
@@ -30,7 +30,7 @@ static void dcssblk_release(struct gendisk *disk, fmode_t mode);static blk_qc_t dcssblk_make_request (struct request_queue *q,struct bio *bio);static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, - void __pmem **kaddr, unsigned long *pfn); + void __pmem **kaddr, pfn_t *pfn);static char dcssblk_segments[DCSSBLK_PARM_LEN ] ="\0" ;
@@ -883,20 +883,18 @@ fail:static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct dcssblk_dev_info *dev_info;unsigned long offset, dev_sz; -void *addr; dev_info = bdev->bd_disk->private_data;if (!dev_info)return -ENODEV ; dev_sz = dev_info->end - dev_info->start; offset = secnum *512 ; - addr = (void *) (dev_info->start + offset); - *pfn =virt_to_phys (addr) >>PAGE_SHIFT ; - *kaddr = (void __pmem *) addr; + *kaddr = (void __pmem *) (dev_info->start + offset); + *pfn =phys_to_pfn_t (dev_info->start + offset,PFN_DEV );return dev_sz - offset; }
fs/dax.c +6 -4
@@ -362,7 +362,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, }dax_unmap_atomic (bdev, &dax); - error =vm_insert_mixed (vma, vaddr, dax.pfn); + error =vm_insert_mixed (vma, vaddr,pfn_t_to_pfn (dax.pfn)); out:i_mmap_unlock_read (mapping);
@@ -667,7 +667,8 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, result =VM_FAULT_SIGBUS ; goto out; } -if ((length <PMD_SIZE ) || (dax.pfn &PG_PMD_COLOUR )) { +if (length <PMD_SIZE + || (pfn_t_to_pfn (dax.pfn) &PG_PMD_COLOUR )) {dax_unmap_atomic (bdev, &dax); goto fallback; }
@@ -676,7 +677,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,* TODO: teach vmf_insert_pfn_pmd() to support * 'pte_special' for pmds */ -if (pfn_valid (dax.pfn)) { +if (pfn_t_has_page (dax.pfn)) {dax_unmap_atomic (bdev, &dax); goto fallback; }
@@ -690,7 +691,8 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, }dax_unmap_atomic (bdev, &dax); - result |=vmf_insert_pfn_pmd (vma, address, pmd, dax.pfn, write); + result |=vmf_insert_pfn_pmd (vma, address, pmd, +pfn_t_to_pfn (dax.pfn), write); } out:
include/linux/blkdev.h +2 -2
@@ -1627,7 +1627,7 @@ struct blk_dax_ctl {sector_t sector; void __pmem *addr;long size; -unsigned long pfn; +pfn_t pfn; };struct block_device_operations {
@@ -1637,7 +1637,7 @@ struct block_device_operations {int (*ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long );int (*compat_ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long ); long (*direct_access)(struct block_device *, sector_t, void __pmem **, -unsigned long *pfn); +pfn_t *);unsigned int (*check_events) (struct gendisk *disk,unsigned int clearing);/* ->media_changed() is DEPRECATED, use ->check_events() instead */
include/linux/mm.h +66 -0
72 lines not on this page · raw message
include/linux/pfn.h +9 -0
@@ -3,6 +3,15 @@#ifndef __ASSEMBLY__#include <linux/types.h> + +/* +* pfn_t: encapsulates a page-frame number that is optionally backed +* by memmap (struct page). Whether a pfn_t has a 'struct page' +* backing is indicated by flags in the high bits of the value. +*/ +typedef struct { +unsigned long val; +}pfn_t ;#endif #define PFN_ALIGN (x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 9/25 mm, dax, pmem: introduce pfn_t
For the purpose of communicating the optional presence of a 'struct page' for the pfn returned from ->direct_access(), introduce a type that encapsulates a page-frame-number plus flags. These flags contain the historical "page_link" encoding for a scatterlist entry, but can also denote "device memory". Where "device memory" is a set of pfns that are not part of the kernel's linear mapping by default, but are accessed via the same memory controller as ram.
The motivation for this new type is large capacity persistent memory that needs struct page entries in the 'memmap' to support 3rd party DMA (i.e. O_DIRECT I/O with a persistent memory source/target). However, we also need it in support of maintaining a list of mapped inodes which need to be unmapped at driver teardown or freeze_bdev() time.
---
Changes since v2:
Moved phys_to_pfn_t() out of line so it can be overridden for new unit tests in development.
arch/powerpc/sysdev/axonram.c | 8 ++--- drivers/block/brd.c | 4 +-- drivers/nvdimm/pmem.c | 12 +++++--- drivers/s390/block/dcssblk.c | 10 +++---- fs/dax.c | 10 ++++--- include/linux/blkdev.h | 4 +-- include/linux/mm.h | 63 +++++++++++++++++++++++++++++++++++++++++ include/linux/pfn.h | 9 ++++++ kernel/memremap.c | 6 ++++ 9 files changed, 103 insertions(+), 23 deletions(-)
arch/powerpc/sysdev/axonram.c +3 -5
@@ -142,15 +142,13 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)*/ static long axon_ram_direct_access (struct block_device *device,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct axon_ram_bank *bank = device->bd_disk->private_data;loff_t offset = (loff_t )sector <<AXON_RAM_SECTOR_SHIFT ; -void *addr = (void *)(bank->ph_addr + offset); - - *kaddr = (void __pmem *)addr; - *pfn =virt_to_phys (addr) >>PAGE_SHIFT ; + *kaddr = (void __pmem __force *) bank->io_addr + offset; + *pfn =phys_to_pfn_t (bank->ph_addr + offset,PFN_DEV );return bank->size - offset; }
drivers/block/brd.c +2 -2
@@ -378,7 +378,7 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector,#ifdef CONFIG_BLK_DEV_RAM_DAX static long brd_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct brd_device *brd = bdev->bd_disk->private_data;struct page *page;
@@ -389,7 +389,7 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector,if (!page)return -ENOSPC ; *kaddr = (void __pmem *)page_address(page); - *pfn =page_to_pfn (page); + *pfn =page_to_pfn_t (page);return PAGE_SIZE ; }
drivers/nvdimm/pmem.c +8 -4
@@ -39,6 +39,7 @@ struct pmem_device {phys_addr_t phys_addr;/* when non-zero this device is hosting a 'pfn' instance */ phys_addr_t data_offset; +unsigned long pfn_flags; void __pmem *virt_addr;size_t size; };
@@ -101,13 +102,13 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, }static long pmem_direct_access (struct block_device *bdev,sector_t sector, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct pmem_device *pmem = bdev->bd_disk->private_data;resource_size_t offset = sector *512 + pmem->data_offset; *kaddr = pmem->virt_addr + offset; - *pfn = (pmem->phys_addr + offset) >>PAGE_SHIFT ; + *pfn =phys_to_pfn_t (pmem->phys_addr + offset, pmem->pfn_flags);return pmem->size - offset; }
@@ -140,9 +141,11 @@ static struct pmem_device *pmem_alloc(struct device *dev,return ERR_PTR (-EBUSY ); } -if (pmem_should_map_pages (dev)) + pmem->pfn_flags =PFN_DEV ; +if (pmem_should_map_pages (dev)) { pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res); -else + pmem->pfn_flags |=PFN_MAP ; + }else pmem->virt_addr = (void __pmem *) devm_memremap(dev, pmem->phys_addr, pmem->size,ARCH_MEMREMAP_PMEM );
@@ -353,6 +356,7 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns) pmem =dev_get_drvdata (dev);devm_memunmap (dev, (void __force *) pmem->virt_addr); pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res); + pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr); goto err;
drivers/s390/block/dcssblk.c +4 -6
@@ -30,7 +30,7 @@ static void dcssblk_release(struct gendisk *disk, fmode_t mode);static blk_qc_t dcssblk_make_request (struct request_queue *q,struct bio *bio);static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, - void __pmem **kaddr, unsigned long *pfn); + void __pmem **kaddr, pfn_t *pfn);static char dcssblk_segments[DCSSBLK_PARM_LEN ] ="\0" ;
@@ -883,20 +883,18 @@ fail:static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, - void __pmem **kaddr, unsigned long *pfn) + void __pmem **kaddr, pfn_t *pfn) {struct dcssblk_dev_info *dev_info;unsigned long offset, dev_sz; -void *addr; dev_info = bdev->bd_disk->private_data;if (!dev_info)return -ENODEV ; dev_sz = dev_info->end - dev_info->start; offset = secnum *512 ; - addr = (void *) (dev_info->start + offset); - *pfn =virt_to_phys (addr) >>PAGE_SHIFT ; - *kaddr = (void __pmem *) addr; + *kaddr = (void __pmem *) (dev_info->start + offset); + *pfn =phys_to_pfn_t (dev_info->start + offset,PFN_DEV );return dev_sz - offset; }
fs/dax.c +6 -4
@@ -362,7 +362,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, }dax_unmap_atomic (bdev, &dax); - error =vm_insert_mixed (vma, vaddr, dax.pfn); + error =vm_insert_mixed (vma, vaddr,pfn_t_to_pfn (dax.pfn)); out:i_mmap_unlock_read (mapping);
@@ -667,7 +667,8 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, result =VM_FAULT_SIGBUS ; goto out; } -if ((length <PMD_SIZE ) || (dax.pfn &PG_PMD_COLOUR )) { +if (length <PMD_SIZE + || (pfn_t_to_pfn (dax.pfn) &PG_PMD_COLOUR )) {dax_unmap_atomic (bdev, &dax); goto fallback; }
@@ -676,7 +677,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,* TODO: teach vmf_insert_pfn_pmd() to support * 'pte_special' for pmds */ -if (pfn_valid (dax.pfn)) { +if (pfn_t_has_page (dax.pfn)) {dax_unmap_atomic (bdev, &dax); goto fallback; }
@@ -690,7 +691,8 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, }dax_unmap_atomic (bdev, &dax); - result |=vmf_insert_pfn_pmd (vma, address, pmd, dax.pfn, write); + result |=vmf_insert_pfn_pmd (vma, address, pmd, +pfn_t_to_pfn (dax.pfn), write); } out:
include/linux/blkdev.h +2 -2
@@ -1627,7 +1627,7 @@ struct blk_dax_ctl {sector_t sector; void __pmem *addr;long size; -unsigned long pfn; +pfn_t pfn; };struct block_device_operations {
@@ -1637,7 +1637,7 @@ struct block_device_operations {int (*ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long );int (*compat_ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long ); long (*direct_access)(struct block_device *, sector_t, void __pmem **, -unsigned long *pfn); +pfn_t *);unsigned int (*check_events) (struct gendisk *disk,unsigned int clearing);/* ->media_changed() is DEPRECATED, use ->check_events() instead */
include/linux/mm.h +63 -0
69 lines not on this page · raw message
include/linux/pfn.h +9 -0
@@ -3,6 +3,15 @@#ifndef __ASSEMBLY__#include <linux/types.h> + +/* +* pfn_t: encapsulates a page-frame number that is optionally backed +* by memmap (struct page). Whether a pfn_t has a 'struct page' +* backing is indicated by flags in the high bits of the value. +*/ +typedef struct { +unsigned long val; +}pfn_t ;#endif #define PFN_ALIGN (x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
kernel/memremap.c +6 -0
@@ -147,6 +147,12 @@ void devm_memunmap(struct device *dev, void *addr) }EXPORT_SYMBOL (devm_memunmap); +pfn_t phys_to_pfn_t (dma_addr_t addr,unsigned long flags) +{ +return __pfn_to_pfn_t (addr >>PAGE_SHIFT , flags); +} +EXPORT_SYMBOL (phys_to_pfn_t); + #ifdef CONFIG_ZONE_DEVICE struct page_map { struct resource res;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 10/25 mm: introduce find_dev_pagemap()
In reply to Dan WilliamsThere are several scenarios where we need to retrieve and update metadata associated with a given devm_memremap_pages() mapping, and the only lookup key available is a pfn in the range:
1/ We want to augment vmemmap_populate() (called via arch_add_memory())
to allocate memmap storage from pre-allocated pages reserved by the device driver. At vmemmap_alloc_block_buf() time it grabs device pages rather than page allocator pages. This is in support of devm_memremap_pages() mappings where the memmap is too large to fit in main memory (i.e. large persistent memory devices).
2/ Taking a reference against the mapping when inserting device pages
into the address_space radix of a given inode. This facilitates unmap_mapping_range() and truncate_inode_pages() operations when the driver is tearing down the mapping.
3/ get_user_pages() operations on ZONE_DEVICE memory require taking a
reference against the mapping so that the driver teardown path can revoke and drain usage of device pages.
--- include/linux/io.h | 15 --------- include/linux/mm.h | 33 ++++++++++++++++++++ kernel/memremap.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 109 insertions(+), 23 deletions(-)
include/linux/io.h +0 -15
@@ -90,21 +90,6 @@ void devm_memunmap(struct device *dev, void *addr);void *__devm_memremap_pages (struct device *dev,struct resource *res); -#ifdef CONFIG_ZONE_DEVICE -void *devm_memremap_pages (struct device *dev,struct resource *res); -#else -static inline void *devm_memremap_pages (struct device *dev,struct resource *res) -{ -/* -* Fail attempts to call devm_memremap_pages() without -* ZONE_DEVICE support enabled, this requires callers to fall -* back to plain devm_memremap() based on config -*/ -WARN_ON_ONCE (1 ); -return ERR_PTR (-ENXIO ); -} -#endif -/* * Some systems do not have legacy ISA devices. * /dev/port is not a valid interface on these systems.
include/linux/mm.h +33 -0
@@ -674,6 +674,39 @@ static inline enum zone_type page_zonenum(const struct page *page)return (page->flags >>ZONES_PGSHIFT ) &ZONES_MASK ; } +struct resource ; +struct device ; +/** +* struct dev_pagemap - metadata for ZONE_DEVICE mappings +* @dev: host device of the mapping for debug +*/ +struct dev_pagemap { +/* TODO: vmem_altmap and percpu_ref count */ +struct device *dev; +}; + +#ifdef CONFIG_ZONE_DEVICE +void *devm_memremap_pages (struct device *dev,struct resource *res); +struct dev_pagemap *find_dev_pagemap (resource_size_t phys); +#else +static inline void *devm_memremap_pages (struct device *dev, +struct resource *res) +{ +/* +* Fail attempts to call devm_memremap_pages() without +* ZONE_DEVICE support enabled, this requires callers to fall +* back to plain devm_memremap() based on config +*/ +WARN_ON_ONCE (1 ); +return ERR_PTR (-ENXIO ); +} + +static inline struct dev_pagemap *find_dev_pagemap (resource_size_t phys) +{ +return NULL ; +} +#endif +#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP )#define SECTION_IN_PAGE_FLAGS #endif
kernel/memremap.c +76 -8
122 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 10/25 mm: introduce find_dev_pagemap()
There are several scenarios where we need to retrieve and update metadata associated with a given devm_memremap_pages() mapping, and the only lookup key available is a pfn in the range:
1/ We want to augment vmemmap_populate() (called via arch_add_memory())
to allocate memmap storage from pre-allocated pages reserved by the device driver. At vmemmap_alloc_block_buf() time it grabs device pages rather than page allocator pages. This is in support of devm_memremap_pages() mappings where the memmap is too large to fit in main memory (i.e. large persistent memory devices).
2/ Taking a reference against the mapping when inserting device pages
into the address_space radix of a given inode. This facilitates unmap_mapping_range() and truncate_inode_pages() operations when the driver is tearing down the mapping.
3/ get_user_pages() operations on ZONE_DEVICE memory require taking a
reference against the mapping so that the driver teardown path can revoke and drain usage of device pages.
---
Changes since v2:
No changes, just a reflow of the patch to fixup the context differences
from: "[-mm PATCH v3 09/25] mm, dax, pmem: introduce pfn_t"
include/linux/io.h | 15 --------- include/linux/mm.h | 33 ++++++++++++++++++++ kernel/memremap.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 109 insertions(+), 23 deletions(-)
include/linux/io.h +0 -15
@@ -90,21 +90,6 @@ void devm_memunmap(struct device *dev, void *addr);void *__devm_memremap_pages (struct device *dev,struct resource *res); -#ifdef CONFIG_ZONE_DEVICE -void *devm_memremap_pages (struct device *dev,struct resource *res); -#else -static inline void *devm_memremap_pages (struct device *dev,struct resource *res) -{ -/* -* Fail attempts to call devm_memremap_pages() without -* ZONE_DEVICE support enabled, this requires callers to fall -* back to plain devm_memremap() based on config -*/ -WARN_ON_ONCE (1 ); -return ERR_PTR (-ENXIO ); -} -#endif -/* * Some systems do not have legacy ISA devices. * /dev/port is not a valid interface on these systems.
include/linux/mm.h +33 -0
@@ -674,6 +674,39 @@ static inline enum zone_type page_zonenum(const struct page *page)return (page->flags >>ZONES_PGSHIFT ) &ZONES_MASK ; } +struct resource ; +struct device ; +/** +* struct dev_pagemap - metadata for ZONE_DEVICE mappings +* @dev: host device of the mapping for debug +*/ +struct dev_pagemap { +/* TODO: vmem_altmap and percpu_ref count */ +struct device *dev; +}; + +#ifdef CONFIG_ZONE_DEVICE +void *devm_memremap_pages (struct device *dev,struct resource *res); +struct dev_pagemap *find_dev_pagemap (resource_size_t phys); +#else +static inline void *devm_memremap_pages (struct device *dev, +struct resource *res) +{ +/* +* Fail attempts to call devm_memremap_pages() without +* ZONE_DEVICE support enabled, this requires callers to fall +* back to plain devm_memremap() based on config +*/ +WARN_ON_ONCE (1 ); +return ERR_PTR (-ENXIO ); +} + +static inline struct dev_pagemap *find_dev_pagemap (resource_size_t phys) +{ +return NULL ; +} +#endif +#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP )#define SECTION_IN_PAGE_FLAGS #endif
kernel/memremap.c +76 -8
122 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 11/25 x86, mm: introduce vmem_altmap to augment vmemmap_populate()
In reply to Dan WilliamsIn support of providing struct page for large persistent memory capacities, use struct vmem_altmap to change the default policy for allocating memory for the memmap array. The default vmemmap_populate() allocates page table storage area from the page allocator. Given persistent memory capacities relative to DRAM it may not be feasible to store the memmap in 'System Memory'. Instead vmem_altmap represents pre-allocated "device pages" to satisfy vmemmap_alloc_block_buf() requests.
--- arch/m68k/include/asm/page_mm.h | 1 arch/m68k/include/asm/page_no.h | 1 arch/mn10300/include/asm/page.h | 1 arch/x86/mm/init_64.c | 32 +++++++++++--- drivers/nvdimm/pmem.c | 6 ++- include/linux/memory_hotplug.h | 3 + include/linux/mm.h | 92 +++++++++++++++++++++++++++++++++++++-- kernel/memremap.c | 61 +++++++++++++++++++++++++- mm/memory_hotplug.c | 66 ++++++++++++++++++++-------- mm/page_alloc.c | 10 ++++ mm/sparse-vmemmap.c | 37 +++++++++++++++- mm/sparse.c | 8 ++- 12 files changed, 277 insertions(+), 41 deletions(-)
arch/m68k/include/asm/page_mm.h +1 -0
@@ -122,6 +122,7 @@ static inline void *__va(unsigned long x)*/ #define virt_to_pfn (kaddr) (__pa(kaddr) >> PAGE_SHIFT)#define pfn_to_virt (pfn) __va((pfn) << PAGE_SHIFT) +#define __pfn_to_phys (pfn) PFN_PHYS(pfn)extern int m68k_virt_to_node_shift;
arch/m68k/include/asm/page_no.h +1 -0
@@ -21,6 +21,7 @@ extern unsigned long memory_end;#define virt_to_pfn (kaddr) (__pa(kaddr) >> PAGE_SHIFT)#define pfn_to_virt (pfn) __va((pfn) << PAGE_SHIFT) +#define __pfn_to_phys (pfn) PFN_PHYS(pfn)#define virt_to_page (addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))#define page_to_virt (page) __va(((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET))
arch/mn10300/include/asm/page.h +1 -0
@@ -107,6 +107,7 @@ static inline int get_order(unsigned long size)#define pfn_to_kaddr (pfn) __va((pfn) << PAGE_SHIFT)#define pfn_to_page (pfn) (mem_map + ((pfn) - __pfn_disp))#define page_to_pfn (page) ((unsigned long)((page) - mem_map) + __pfn_disp) +#define __pfn_to_phys (pfn) PFN_PHYS(pfn)#define pfn_valid (pfn) \ ({ \
arch/x86/mm/init_64.c +25 -7
@@ -714,6 +714,12 @@ static void __meminit free_pagetable(struct page *page, int order) {unsigned long magic;unsigned int nr_pages =1 << order; +struct vmem_altmap *altmap =to_vmem_altmap ((unsigned long ) page); + +if (altmap) { +vmem_altmap_free (altmap, nr_pages); +return ; + }/* bootmem page has reserved flag */ if (PageReserved (page)) {
@@ -1018,13 +1024,19 @@ int __ref arch_remove_memory(u64 start, u64 size) {unsigned long start_pfn = start >>PAGE_SHIFT ;unsigned long nr_pages = size >>PAGE_SHIFT ; +struct page *page =pfn_to_page (start_pfn); +struct vmem_altmap *altmap;struct zone *zone;int ret; - zone =page_zone (pfn_to_page (start_pfn)); -kernel_physical_mapping_remove (start, start + size); +/* With altmap the first mapped page is offset from @start */ + altmap =to_vmem_altmap ((unsigned long ) page); +if (altmap) + page +=vmem_altmap_offset (altmap); + zone =page_zone (page); ret =__remove_pages (zone, start_pfn, nr_pages);WARN_ON_ONCE (ret); +kernel_physical_mapping_remove (start, start + size);return ret; }
@@ -1236,7 +1248,7 @@ static void __meminitdata *p_start, *p_end;static int __meminitdata node_start;static int __meminit vmemmap_populate_hugepages (unsigned long start, -unsigned long end,int node) +unsigned long end,int node,struct vmem_altmap *altmap) {unsigned long addr;unsigned long next;
@@ -1259,7 +1271,7 @@ static int __meminit vmemmap_populate_hugepages(unsigned long start,if (pmd_none (*pmd)) {void *p; - p =vmemmap_alloc_block_buf (PMD_SIZE , node); + p =__vmemmap_alloc_block_buf (PMD_SIZE , node, altmap);if (p) {pte_t entry;
@@ -1280,7 +1292,8 @@ static int __meminit vmemmap_populate_hugepages(unsigned long start, addr_end = addr +PMD_SIZE ; p_end = p +PMD_SIZE ;continue ; - } + }else if (altmap) +return -ENOMEM ;/* no fallback */ }else if (pmd_large (*pmd)) {vmemmap_verify ((pte_t *)pmd, node, addr, next);continue ;
@@ -1294,11 +1307,16 @@ static int __meminit vmemmap_populate_hugepages(unsigned long start,int __meminit vmemmap_populate (unsigned long start,unsigned long end,int node) { +struct vmem_altmap *altmap =to_vmem_altmap (start);int err;if (cpu_has_pse) - err =vmemmap_populate_hugepages (start, end, node); -else + err =vmemmap_populate_hugepages (start, end, node, altmap); +else if (altmap) { +pr_err_once ("%s: no cpu support for altmap allocations\n" , + __func__); + err = -ENOMEM ; + }else err =vmemmap_populate_basepages (start, end, node);if (!err)sync_global_pgds (start, end -1 ,0 );
drivers/nvdimm/pmem.c +4 -2
@@ -143,7 +143,8 @@ static struct pmem_device *pmem_alloc(struct device *dev, pmem->pfn_flags =PFN_DEV ;if (pmem_should_map_pages (dev)) { - pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res); + pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res, +NULL ); pmem->pfn_flags |=PFN_MAP ; }else pmem->virt_addr = (void __pmem *) devm_memremap(dev,
@@ -355,7 +356,8 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)/* establish pfn range for lookup, and switch to direct map */ pmem =dev_get_drvdata (dev);devm_memunmap (dev, (void __force *) pmem->virt_addr); - pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res); + pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res, +NULL ); pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr);
include/linux/memory_hotplug.h +2 -1
@@ -275,7 +275,8 @@ extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);extern bool is_memblock_offlined (struct memory_block *mem);extern void remove_memory (int nid,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn); -extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms); +extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms, +unsigned long map_offset);extern struct page *sparse_decode_mem_map (unsigned long coded_mem_map,unsigned long pnum);
include/linux/mm.h +88 -4
121 lines not on this page · raw message
kernel/memremap.c +59 -2
105 lines not on this page · raw message
mm/memory_hotplug.c +47 -19
103 lines not on this page · raw message
mm/page_alloc.c +9 -1
@@ -4502,8 +4502,9 @@ static inline unsigned long wait_table_bits(unsigned long size)void __meminit memmap_init_zone (unsigned long size,int nid,unsigned long zone,unsigned long start_pfn,enum memmap_context context) { -pg_data_t *pgdat =NODE_DATA (nid); +struct vmem_altmap *altmap =to_vmem_altmap (__pfn_to_phys (start_pfn));unsigned long end_pfn = start_pfn + size; +pg_data_t *pgdat =NODE_DATA (nid);unsigned long pfn;struct zone *z;unsigned long nr_initialised =0 ;
@@ -4511,6 +4512,13 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,if (highest_memmap_pfn < end_pfn -1 ) highest_memmap_pfn = end_pfn -1 ; +/* +* Honor reservation requested by the driver for this ZONE_DEVICE +* memory +*/ +if (altmap && start_pfn == altmap->base_pfn) + start_pfn += altmap->reserve; + z = &pgdat->node_zones[zone];for (pfn = start_pfn; pfn < end_pfn; pfn++) {/*
mm/sparse-vmemmap.c +35 -2
@@ -70,7 +70,7 @@ void * __meminit vmemmap_alloc_block(unsigned long size, int node) }/* need to make sure size is all the same during early stage */ -void *__meminit vmemmap_alloc_block_buf (unsigned long size,int node) +static void *__meminit alloc_block_buf (unsigned long size,int node) {void *ptr;
@@ -87,6 +87,39 @@ void * __meminit vmemmap_alloc_block_buf(unsigned long size, int node)return ptr; } +static void *__meminit altmap_alloc_block_buf (unsigned long size, +struct vmem_altmap *altmap) +{ +unsigned long pfn, nr_pfns; +void *ptr; + +if (size & ~PAGE_MASK ) { +pr_warn_once ("%s: allocations must be multiple of PAGE_SIZE (%ld)\n" , + __func__, size); +return NULL ; + } + + nr_pfns = size >>PAGE_SHIFT ; + pfn =vmem_altmap_alloc (altmap, nr_pfns); +if (pfn <ULONG_MAX ) + ptr =__va (__pfn_to_phys (pfn)); +else + ptr =NULL ; +pr_debug ("%s: pfn: %#lx alloc: %ld align: %ld nr: %#lx\n" , + __func__, pfn, altmap->alloc, altmap->align, nr_pfns); + +return ptr; +} + +/* need to make sure size is all the same during early stage */ +void *__meminit __vmemmap_alloc_block_buf (unsigned long size,int node, +struct vmem_altmap *altmap) +{ +if (altmap) +return altmap_alloc_block_buf (size, altmap); +return alloc_block_buf (size, node); +} +void __meminit vmemmap_verify (pte_t *pte,int node,unsigned long start,unsigned long end) {
@@ -103,7 +136,7 @@ pte_t * __meminit vmemmap_pte_populate(pmd_t *pmd, unsigned long addr, int node)pte_t *pte =pte_offset_kernel (pmd, addr);if (pte_none (*pte)) {pte_t entry; -void *p =vmemmap_alloc_block_buf (PAGE_SIZE , node); +void *p =alloc_block_buf (PAGE_SIZE , node);if (!p)return NULL ; entry =pfn_pte (__pa (p) >>PAGE_SHIFT ,PAGE_KERNEL );
mm/sparse.c +5 -3
@@ -748,7 +748,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)if (!memmap)return ; -for (i =0 ; i <PAGES_PER_SECTION ; i++) { +for (i =0 ; i < nr_pages; i++) {if (PageHWPoison (&memmap[i])) {atomic_long_sub (1 , &num_poisoned_pages);ClearPageHWPoison (&memmap[i]);
@@ -788,7 +788,8 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)free_map_bootmem (memmap); } -void sparse_remove_one_section (struct zone *zone,struct mem_section *ms) +void sparse_remove_one_section (struct zone *zone,struct mem_section *ms, +unsigned long map_offset) {struct page *memmap =NULL ;unsigned long *usemap =NULL , flags;
@@ -804,7 +805,8 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms) }pgdat_resize_unlock (pgdat, &flags); -clear_hwpoisoned_pages (memmap,PAGES_PER_SECTION ); +clear_hwpoisoned_pages (memmap + map_offset, +PAGES_PER_SECTION - map_offset);free_section_usemap (memmap, usemap); }#endif /* CONFIG_MEMORY_HOTREMOVE */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v2 11/25] x86, mm: introduce vmem_altmap to augment vmemmap_populate()
Quoted 17 lines · Dan Williams
In support of providing struct page for large persistent memory capacities, use struct
vmem_altmapto change the default policy for allocating memory for the memmap array. The defaultvmemmap_populate()allocates page table storage area from the page allocator. Given persistent memory capacities relative to DRAM it may not be feasible to store the memmap in 'System Memory'. Insteadvmem_altmaprepresents pre-allocated "device pages" to satisfyvmemmap_alloc_block_buf()requests.Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Dave Hansen <[email protected]>Cc Andrew Morton <[email protected]>Reported-by kbuild test robot <[email protected]>Signed-off-by Dan Williams <[email protected]>
Quoted 14 lines
--- arch/m68k/include/asm/page_mm.h | 1 arch/m68k/include/asm/page_no.h | 1 arch/mn10300/include/asm/page.h | 1 arch/x86/mm/init_64.c | 32 +++++++++++--- drivers/nvdimm/pmem.c | 6 ++- include/linux/memory_hotplug.h | 3 + include/linux/mm.h | 92 +++++++++++++++++++++++++++++++++++++-- kernel/memremap.c | 61 +++++++++++++++++++++++++- mm/memory_hotplug.c | 66 ++++++++++++++++++++-------- mm/page_alloc.c | 10 ++++ mm/sparse-vmemmap.c | 37 +++++++++++++++- mm/sparse.c | 8 ++- 12 files changed, 277 insertions(+), 41 deletions(-)
Ingo, since you've shown interest in the nvdimm enabling in the past, may I ask to look over the x86 touches in this set? I believe Andrew is waiting on Acked-by's to move this forward.
These patches:
[-mm PATCH v2 11/25] x86, mm: introduce vmem_altmap to augment vmemmap_populate()
[-mm PATCH v2 16/25] x86, mm: introduce _PAGE_DEVMAP [-mm PATCH v2 23/25] mm, x86: get_user_pages() for dax mappings
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [-mm PATCH v2 11/25] x86, mm: introduce vmem_altmap to augment vmemmap_populate()
In reply to Dan WilliamsQuoted 9 lines · On Wed, 09 Dec 2015 18:38:12 -0800 Dan Williams <[email protected]>…
In support of providing struct page for large persistent memory capacities, use struct
vmem_altmapto change the default policy for allocating memory for the memmap array. The defaultvmemmap_populate()allocates page table storage area from the page allocator. Given persistent memory capacities relative to DRAM it may not be feasible to store the memmap in 'System Memory'. Insteadvmem_altmaprepresents pre-allocated "device pages" to satisfyvmemmap_alloc_block_buf()requests.
Quoted 3 lines
...
include/linux/mm.h | 92 +++++++++++++++++++++++++++++++++++++--
mm.h is getting ridiculously huge and these additions look to be fairly standalone. Perhaps you could take a look at creating a vmem_altmap.h sometime if feeling bored?
Quoted 13 lines
include/linux/mm.h +13
-0+ +/** +* vmem_altmap_alloc - allocate pages from the vmem_altmap reservation +* @altmap - reserved page pool for the allocation +* @nr_pfns - size (in pages) of the allocation +* +* Allocations are aligned to the size of the request +*/ +static inline unsigned long vmem_altmap_alloc (struct vmem_altmap *altmap, +unsigned long nr_pfns) +{ +unsigned long pfn =vmem_altmap_next_pfn (altmap); +unsigned long nr_align;
include/linux/mm.h static inline enum zone_type page_zonenum(const struct page *page) · line 737
Quoted 10 lines
include/linux/mm.h +10
-0+ + nr_align =1UL <<find_first_bit (&nr_pfns,BITS_PER_LONG ); + nr_align =ALIGN (pfn, nr_align) - pfn; + +if (nr_pfns + nr_align >vmem_altmap_nr_free (altmap)) +return ULONG_MAX ; + altmap->alloc += nr_pfns; + altmap->align += nr_align; +return pfn + nr_align; +}
This look pretty large for an inline. But it has only one callsite so it doesn't matter. But if it only has one callsite, why is it in .h?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v2 11/25] x86, mm: introduce vmem_altmap to augment vmemmap_populate()
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Wed, 09 Dec 2015 18:38:12 -0800 Dan Williams <[email protected]>…
In support of providing struct page for large persistent memory capacities, use struct
vmem_altmapto change the default policy for allocating memory for the memmap array. The defaultvmemmap_populate()allocates page table storage area from the page allocator. Given persistent memory capacities relative to DRAM it may not be feasible to store the memmap in 'System Memory'. Insteadvmem_altmaprepresents pre-allocated "device pages" to satisfyvmemmap_alloc_block_buf()requests.
Quoted 8 lines
Quoted 3 lines
...
include/linux/mm.h | 92 +++++++++++++++++++++++++++++++++++++--
mm.his getting ridiculously huge and these additions look to be fairly standalone. Perhaps you could take a look at creating avmem_altmap.hsometime if feeling bored?
Will do, and the pfn_t inlines can also move out.
Quoted 18 lines
Quoted 18 lines
include/linux/mm.h +18
-0+ +/** +* vmem_altmap_alloc - allocate pages from the vmem_altmap reservation +* @altmap - reserved page pool for the allocation +* @nr_pfns - size (in pages) of the allocation +* +* Allocations are aligned to the size of the request +*/ +static inline unsigned long vmem_altmap_alloc (struct vmem_altmap *altmap, +unsigned long nr_pfns) +{ +unsigned long pfn =vmem_altmap_next_pfn (altmap); +unsigned long nr_align; + + nr_align =1UL <<find_first_bit (&nr_pfns,BITS_PER_LONG ); + nr_align =ALIGN (pfn, nr_align) - pfn; + +if (nr_pfns + nr_align >vmem_altmap_nr_free (altmap))
Quoted 8 lines
include/linux/mm.h static inline enum zone_type page_zonenum(const struct page *page) · line 737
Quoted 5 lines
include/linux/mm.h +5
-0+return ULONG_MAX ; + altmap->alloc += nr_pfns; + altmap->align += nr_align; +return pfn + nr_align; +}This look pretty large for an inline. But it has only one callsite so it doesn't matter. But if it only has one callsite, why is it in .h?
I'll move it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 12/25 libnvdimm, pfn, pmem: allocate memmap array in persistent memory
In reply to Dan WilliamsUse the new vmem_altmap capability to enable the pmem driver to arrange for a struct page memmap to be established in persistent memory.
--- arch/ia64/include/asm/page.h | 1 + drivers/nvdimm/pfn_devs.c | 3 +-- drivers/nvdimm/pmem.c | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-)
arch/ia64/include/asm/page.h +1 -0
@@ -105,6 +105,7 @@ extern struct page *vmem_map;#ifdef CONFIG_DISCONTIGMEM # define page_to_pfn (page) ((unsigned long) (page - vmem_map))# define pfn_to_page (pfn) (vmem_map + (pfn)) +# define __pfn_to_phys (pfn) PFN_PHYS(pfn)#else # include <asm-generic/memory_model.h> #endif
drivers/nvdimm/pfn_devs.c +1 -2
@@ -83,8 +83,7 @@ static ssize_t mode_store(struct device *dev,if (strncmp (buf,"pmem\n" , n) ==0 ||strncmp (buf,"pmem" , n) ==0 ) { -/* TODO: allocate from PMEM support */ - rc = -ENOTTY ; + nd_pfn->mode =PFN_MODE_PMEM ; }else if (strncmp (buf,"ram\n" , n) ==0 ||strncmp (buf,"ram" , n) ==0 ) nd_pfn->mode =PFN_MODE_RAM ;
drivers/nvdimm/pmem.c +17 -2
@@ -315,12 +315,16 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)struct nd_namespace_io *nsio =to_nd_namespace_io (&ndns->dev);struct nd_pfn *nd_pfn =to_nd_pfn (ndns->claim);struct device *dev = &nd_pfn->dev; -struct vmem_altmap *altmap;struct nd_region *nd_region; +struct vmem_altmap *altmap;struct nd_pfn_sb *pfn_sb;struct pmem_device *pmem;phys_addr_t offset;int rc; +struct vmem_altmap __altmap = { + .base_pfn =__phys_to_pfn (nsio->res.start), + .reserve =__phys_to_pfn (SZ_8K ), + };if (!nd_pfn->uuid || !nd_pfn->ndns)return -ENODEV ;
@@ -348,6 +352,17 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)return -EINVAL ; nd_pfn->npfns =le64_to_cpu (pfn_sb->npfns); altmap =NULL ; + }else if (nd_pfn->mode ==PFN_MODE_PMEM ) { + nd_pfn->npfns = (resource_size (&nsio->res) - offset) + /PAGE_SIZE ; +if (le64_to_cpu (nd_pfn->pfn_sb->npfns) > nd_pfn->npfns) +dev_info (&nd_pfn->dev, +"number of pfns truncated from %lld to %ld\n" , +le64_to_cpu (nd_pfn->pfn_sb->npfns), + nd_pfn->npfns); + altmap = & __altmap; + altmap->free =__phys_to_pfn (offset -SZ_8K ); + altmap->alloc =0 ; }else { rc = -ENXIO ; goto err;
@@ -357,7 +372,7 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns) pmem =dev_get_drvdata (dev);devm_memunmap (dev, (void __force *) pmem->virt_addr); pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res, -NULL ); + altmap); pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 13/25 avr32: convert to asm-generic/memory_model.h
In reply to Dan WilliamsSwitch avr32/include/asm/page.h to use the common defintions for pfn_to_page(), page_to_pfn(), and ARCH_PFN_OFFSET.
--- arch/avr32/include/asm/page.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/avr32/include/asm/page.h +4 -4
@@ -83,11 +83,9 @@ static inline int get_order(unsigned long size)#ifndef CONFIG_NEED_MULTIPLE_NODES -#define PHYS_PFN_OFFSET (CONFIG_PHYS_OFFSET >> PAGE_SHIFT) +#define ARCH_PFN_OFFSET (CONFIG_PHYS_OFFSET >> PAGE_SHIFT) -#define pfn_to_page (pfn) (mem_map + ((pfn) - PHYS_PFN_OFFSET)) -#define page_to_pfn (page) ((unsigned long)((page) - mem_map) + PHYS_PFN_OFFSET) -#define pfn_valid (pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) +#define pfn_valid (pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (ARCH_PFN_OFFSET + max_mapnr))#endif /* CONFIG_NEED_MULTIPLE_NODES */ #define virt_to_page (kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
@@ -101,4 +99,6 @@ static inline int get_order(unsigned long size)*/ #define HIGHMEM_START 0x20000000UL +#include <asm-generic/memory_model.h> +#endif /* __ASM_AVR32_PAGE_H */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 14/25 hugetlb: fix compile error on tile
In reply to Dan WilliamsInlude asm/pgtable.h to get the definition for pud_t to fix:
include/linux/hugetlb.h:203:29: error: unknown type name 'pud_t'
--- include/linux/hugetlb.h | 1 + 1 file changed, 1 insertion(+)
include/linux/hugetlb.h +1 -0
@@ -8,6 +8,7 @@#include <linux/cgroup.h> #include <linux/list.h> #include <linux/kref.h> +#include <asm/pgtable.h> struct ctl_table ;struct user_struct ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 15/25 frv: fix compiler warning from definition of __pmd()
In reply to Dan WilliamsTake into account that the pmd_t type is a array inside a struct, so it needs two levels of brackets to initialize. Otherwise, a usage of __pmd generates a warning:
include/linux/mm.h:986:2: warning: missing braces around initializer [-Wmissing-braces]
--- arch/frv/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/frv/include/asm/page.h +1 -1
@@ -31,7 +31,7 @@ typedef struct page *pgtable_t;#define pgprot_val (x) ((x).pgprot)#define __pte (x) ((pte_t) { (x) } ) -#define __pmd (x) ((pmd_t) { (x) } ) +#define __pmd (x) ((pmd_t) { { (x) } } )#define __pud (x) ((pud_t) { (x) } )#define __pgd (x) ((pgd_t) { (x) } )#define __pgprot (x) ((pgprot_t) { (x) } )
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 16/25 x86, mm: introduce _PAGE_DEVMAP
In reply to Dan Williams_PAGE_DEVMAP is a hardware-unused pte bit that will later be used in the get_user_pages() path to identify pfns backed by the dynamic allocation established by devm_memremap_pages. Upon seeing that bit the gup path will lookup and pin the allocation while the pages are in use.
Since the _PAGE_DEVMAP bit is > 32 it must be cast to u64 instead of a pteval_t to allow pmd_flags() usage in the realmode boot code to build.
--- arch/x86/include/asm/pgtable_types.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/pgtable_types.h +6 -1
@@ -24,7 +24,9 @@#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SOFTW1#define _PAGE_BIT_HIDDEN _PAGE_BIT_SOFTW3/* hidden by kmemcheck */ #define _PAGE_BIT_SOFT_DIRTY _PAGE_BIT_SOFTW3/* software dirty tracking */ -#define _PAGE_BIT_NX 63/* No execute: only valid after cpuid check */ +#define _PAGE_BIT_SOFTW4 58/* available for programmer */ +#define _PAGE_BIT_DEVMAP _PAGE_BIT_SOFTW4 +#define _PAGE_BIT_NX 63/* No execute: only valid after cpuid check */ /* If _PAGE_BIT_PRESENT is clear, we use these: */ /* - if the user mapped it with PROT_NONE; pte_present gives true */
@@ -83,8 +85,11 @@#if defined(CONFIG_X86_64 ) || defined(CONFIG_X86_PAE )#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) +#define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) +#define __HAVE_ARCH_PTE_DEVMAP#else #define _PAGE_NX (_AT(pteval_t, 0)) +#define _PAGE_DEVMAP (_AT(pteval_t, 0))#endif #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 17/25 mm, dax, gpu: convert vm_insert_mixed to pfn_t
In reply to Dan WilliamsConvert the raw unsigned long 'pfn' argument to pfn_t for the purpose of evaluating the PFN_MAP and PFN_DEV flags. When both are set it triggers _PAGE_DEVMAP to be set in the resulting pte.
There are no functional changes to the gpu drivers as a result of this conversion.
This uncovered several architectures with no local definition for pfn_pte(), in response pfn_t_pte() is only defined when an arch opts-in by "#define pfn_pte pfn_pte".
--- arch/alpha/include/asm/pgtable.h | 1 + arch/parisc/include/asm/pgtable.h | 1 + arch/powerpc/include/asm/pgtable.h | 1 + arch/sparc/include/asm/pgtable_64.h | 1 + arch/tile/include/asm/pgtable.h | 1 + arch/um/include/asm/pgtable-3level.h | 1 + arch/x86/include/asm/pgtable.h | 12 +++++++++++ drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++- drivers/gpu/drm/gma500/framebuffer.c | 3 ++- drivers/gpu/drm/msm/msm_gem.c | 3 ++- drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++- fs/dax.c | 2 +- include/linux/mm.h | 33 ++++++++++++++++++++++++++++++- mm/memory.c | 15 ++++++++------ 15 files changed, 72 insertions(+), 14 deletions(-)
arch/alpha/include/asm/pgtable.h +1 -0
@@ -216,6 +216,7 @@ extern unsigned long __zero_page(void); })#endif +#define pfn_pte pfn_pteextern inline pte_t pfn_pte (unsigned long physpfn,pgprot_t pgprot) {pte_t pte;pte_val (pte) = (PHYS_TWIDDLE (physpfn) <<32 ) |pgprot_val (pgprot);return pte; }
arch/parisc/include/asm/pgtable.h +1 -0
@@ -395,6 +395,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long pfn,pgprot_t pgprot) {pte_t pte;
arch/powerpc/include/asm/pgtable.h +1 -0
@@ -67,6 +67,7 @@ static inline int pte_present(pte_t pte)* Even if PTEs can be unsigned long long, a PFN is always an unsigned * long for now. */ +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long pfn,pgprot_t pgprot) {return __pte (((pte_basic_t)(pfn) <<PTE_RPN_SHIFT ) |pgprot_val (pgprot)); }
arch/sparc/include/asm/pgtable_64.h +1 -0
@@ -234,6 +234,7 @@ extern struct page *mem_map_zero;* the first physical page in the machine is at some huge physical address, * such as 4GB. This is common on a partitioned E10000, for example. */ +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long pfn,pgprot_t prot) {unsigned long paddr = pfn <<PAGE_SHIFT ;
arch/tile/include/asm/pgtable.h +1 -0
@@ -275,6 +275,7 @@ static inline unsigned long pte_pfn(pte_t pte)extern pgprot_t set_remote_cache_cpu (pgprot_t prot,int cpu);extern int get_remote_cache_cpu (pgprot_t prot); +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long pfn,pgprot_t prot) {return hv_pte_set_pa (prot,PFN_PHYS (pfn));
arch/um/include/asm/pgtable-3level.h +1 -0
@@ -98,6 +98,7 @@ static inline unsigned long pte_pfn(pte_t pte)return phys_to_pfn (pte_val (pte)); } +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) {pte_t pte;
arch/x86/include/asm/pgtable.h +12 -0
@@ -247,6 +247,11 @@ static inline pte_t pte_mkspecial(pte_t pte)return pte_set_flags (pte, _PAGE_SPECIAL); } +static inline pte_t pte_mkdevmap (pte_t pte) +{ +return pte_set_flags (pte, _PAGE_SPECIAL|_PAGE_DEVMAP); +} +static inline pmd_t pmd_set_flags (pmd_t pmd,pmdval_t set) {pmdval_t v =native_pmd_val (pmd);
@@ -348,6 +353,7 @@ static inline pgprotval_t massage_pgprot(pgprot_t pgprot)return protval; } +#define pfn_pte pfn_ptestatic inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) { return __pte(((phys_addr_t)page_nr << PAGE_SHIFT) |
@@ -462,6 +468,12 @@ static inline int pte_present(pte_t a)return pte_flags (a) & (_PAGE_PRESENT | _PAGE_PROTNONE); } +#define pte_devmap pte_devmap +static inline int pte_devmap (pte_t a) +{ +return (pte_flags (a) & _PAGE_DEVMAP) == _PAGE_DEVMAP; +} +#define pte_accessible pte_accessiblestatic inline bool pte_accessible (struct mm_struct *mm,pte_t a) {
drivers/gpu/drm/exynos/exynos_drm_gem.c +2 -1
@@ -490,7 +490,8 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) } pfn =page_to_pfn (exynos_gem->pages[page_offset]); - ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, pfn); + ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, +pfn_to_pfn_t (pfn,PFN_DEV )); out:switch (ret) {
drivers/gpu/drm/gma500/framebuffer.c +2 -1
@@ -132,7 +132,8 @@ static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)for (i =0 ; i < page_num; i++) { pfn = (phys_addr >>PAGE_SHIFT ); - ret =vm_insert_mixed (vma, address, pfn); + ret =vm_insert_mixed (vma, address, +__pfn_to_pfn_t (pfn,PFN_DEV ));if (unlikely ((ret == -EBUSY ) || (ret !=0 && i >0 )))break ;else if (unlikely (ret !=0 )) {
drivers/gpu/drm/msm/msm_gem.c +2 -1
@@ -222,7 +222,8 @@ int msm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)VERB ("Inserting %p pfn %lx, pa %lx" , vmf->virtual_address, pfn, pfn <<PAGE_SHIFT ); - ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, pfn); + ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, +pfn_to_pfn_t (pfn,PFN_DEV )); out_unlock:mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/omapdrm/omap_gem.c +4 -2
@@ -385,7 +385,8 @@ static int fault_1d(struct drm_gem_object *obj,VERB ("Inserting %p pfn %lx, pa %lx" , vmf->virtual_address, pfn, pfn <<PAGE_SHIFT ); -return vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, pfn); +return vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, +pfn_to_pfn_t (pfn,PFN_DEV )); }/* Special handling for the case of faulting in 2d tiled buffers */
@@ -478,7 +479,8 @@ static int fault_2d(struct drm_gem_object *obj, pfn, pfn << PAGE_SHIFT);for (i = n; i >0 ; i--) { -vm_insert_mixed (vma, (unsigned long )vaddr, pfn); +vm_insert_mixed (vma, (unsigned long )vaddr, +pfn_to_pfn_t (pfn,PFN_DEV )); pfn += usergart[fmt].stride_pfn; vaddr +=PAGE_SIZE * m; }
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -1
@@ -229,7 +229,8 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) }if (vma->vm_flags &VM_MIXEDMAP ) - ret =vm_insert_mixed (&cvma, address, pfn); + ret =vm_insert_mixed (&cvma, address, +__pfn_to_pfn_t (pfn,PFN_DEV ));else ret =vm_insert_pfn (&cvma, address, pfn);
fs/dax.c +1 -1
@@ -362,7 +362,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, }dax_unmap_atomic (bdev, &dax); - error =vm_insert_mixed (vma, vaddr,pfn_t_to_pfn (dax.pfn)); + error =vm_insert_mixed (vma, vaddr, dax.pfn); out:i_mmap_unlock_read (mapping);
include/linux/mm.h +32 -1
@@ -1060,6 +1060,33 @@ static inline pfn_t page_to_pfn_t(struct page *page)return pfn_to_pfn_t (page_to_pfn (page)); } +static inline int pfn_t_valid (pfn_t pfn) +{ +return pfn_valid (pfn_t_to_pfn (pfn)); +} + +#ifdef pfn_pte +static inline pte_t pfn_t_pte (pfn_t pfn,pgprot_t pgprot) +{ +return pfn_pte (pfn_t_to_pfn (pfn), pgprot); +} +#endif + +#ifdef __HAVE_ARCH_PTE_DEVICE +static inline bool pfn_t_devmap (pfn_t pfn) +{ +const unsigned long flags =PFN_DEV |PFN_MAP ; + +return (pfn.val & flags) == flags; +} +#else +static inline bool pfn_t_devmap (pfn_t pfn) +{ +return false; +} +pte_t pte_mkdevmap (pte_t pte); +#endif +/* * Some inline functions in vmstat.h depend on page_zone() */
@@ -1851,6 +1878,10 @@ static inline void pgtable_pmd_page_dtor(struct page *page) {}#endif +#ifndef pte_devmap +#define pte_devmap (x) (0) +#endif +static inline spinlock_t *pmd_lock (struct mm_struct *mm,pmd_t *pmd) {spinlock_t *ptl =pmd_lockptr (mm, pmd);
@@ -2270,7 +2301,7 @@ int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *);int vm_insert_pfn (struct vm_area_struct *vma,unsigned long addr,unsigned long pfn);int vm_insert_mixed (struct vm_area_struct *vma,unsigned long addr, -unsigned long pfn); +pfn_t pfn);int vm_iomap_memory (struct vm_area_struct *vma,phys_addr_t start,unsigned long len);
mm/memory.c +9 -6
@@ -1500,7 +1500,7 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,EXPORT_SYMBOL (vm_insert_page);static int insert_pfn (struct vm_area_struct *vma,unsigned long addr, -unsigned long pfn,pgprot_t prot) +pfn_t pfn,pgprot_t prot) {struct mm_struct *mm = vma->vm_mm;int retval;
@@ -1516,7 +1516,10 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, goto out_unlock;/* Ok, finally just insert the thing.. */ - entry =pte_mkspecial (pfn_pte (pfn, prot)); +if (pfn_t_devmap (pfn)) + entry =pte_mkdevmap (pfn_t_pte (pfn, prot)); +else + entry =pte_mkspecial (pfn_t_pte (pfn, prot));set_pte_at (mm, addr, pte, entry);update_mmu_cache (vma, addr, pte);/* XXX: why not for insert_page? */
@@ -1566,14 +1569,14 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,if (track_pfn_insert (vma, &pgprot, pfn))return -EINVAL ; - ret =insert_pfn (vma, addr, pfn, pgprot); + ret =insert_pfn (vma, addr,__pfn_to_pfn_t (pfn,PFN_DEV ), pgprot);return ret; }EXPORT_SYMBOL (vm_insert_pfn);int vm_insert_mixed (struct vm_area_struct *vma,unsigned long addr, -unsigned long pfn) +pfn_t pfn) {BUG_ON (!(vma->vm_flags &VM_MIXEDMAP ));
@@ -1587,10 +1590,10 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,* than insert_pfn). If a zero_pfn were inserted into a VM_MIXEDMAP * without pte special, it would there be refcounted as a normal page. */ -if (!HAVE_PTE_SPECIAL &&pfn_valid (pfn)) { +if (!HAVE_PTE_SPECIAL &&pfn_t_valid (pfn)) {struct page *page; - page =pfn_to_page (pfn); + page =pfn_t_to_page (pfn);return insert_page (vma, addr, page, vma->vm_page_prot); }return insert_pfn (vma, addr, pfn, vma->vm_page_prot);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 18/25 mm, dax: convert vmf_insert_pfn_pmd() to pfn_t
In reply to Dan WilliamsSimilar to the conversion of vm_insert_mixed() use pfn_t in the vmf_insert_pfn_pmd() to tag the resulting pte with _PAGE_DEVICE when the pfn is backed by a devm_memremap_pages() mapping.
--- arch/sparc/include/asm/pgtable_64.h | 1 + arch/x86/include/asm/pgtable.h | 6 ++++++ arch/x86/mm/pat.c | 4 ++-- drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- drivers/gpu/drm/msm/msm_gem.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 4 ++-- fs/dax.c | 2 +- include/asm-generic/pgtable.h | 6 ++++-- include/linux/huge_mm.h | 2 +- include/linux/mm.h | 10 +++++++++- mm/huge_memory.c | 10 ++++++---- mm/memory.c | 2 +- 12 files changed, 35 insertions(+), 16 deletions(-)
arch/sparc/include/asm/pgtable_64.h +1 -0
@@ -245,6 +245,7 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define pfn_pmd pfn_pmdstatic inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot) {pte_t pte =pfn_pte (page_nr, pgprot);
arch/x86/include/asm/pgtable.h +6 -0
@@ -286,6 +286,11 @@ static inline pmd_t pmd_mkdirty(pmd_t pmd)return pmd_set_flags (pmd, _PAGE_DIRTY | _PAGE_SOFT_DIRTY); } +static inline pmd_t pmd_mkdevmap (pmd_t pmd) +{ +return pmd_set_flags (pmd, _PAGE_DEVMAP); +} +static inline pmd_t pmd_mkhuge (pmd_t pmd) {return pmd_set_flags (pmd, _PAGE_PSE);
@@ -360,6 +365,7 @@ static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) massage_pgprot(pgprot)); } +#define pfn_pmd pfn_pmdstatic inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot) { return __pmd(((phys_addr_t)page_nr << PAGE_SHIFT) |
arch/x86/mm/pat.c +2 -2
@@ -949,7 +949,7 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, }int track_pfn_insert (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn) +pfn_t pfn) {enum page_cache_mode pcm;
@@ -957,7 +957,7 @@ int track_pfn_insert(struct vm_area_struct *vma, pgprot_t *prot,return 0 ;/* Set prot based on lookup */ - pcm =lookup_memtype ((resource_size_t )pfn <<PAGE_SHIFT ); + pcm =lookup_memtype (pfn_t_to_phys (pfn)); *prot =__pgprot ((pgprot_val (vma->vm_page_prot) & (~_PAGE_CACHE_MASK)) |cachemode2protval (pcm));
drivers/gpu/drm/exynos/exynos_drm_gem.c +1 -1
@@ -491,7 +491,7 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn =page_to_pfn (exynos_gem->pages[page_offset]); ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, -pfn_to_pfn_t (pfn,PFN_DEV )); +__pfn_to_pfn_t (pfn,PFN_DEV )); out:switch (ret) {
drivers/gpu/drm/msm/msm_gem.c +1 -1
@@ -223,7 +223,7 @@ int msm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn, pfn << PAGE_SHIFT); ret =vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, -pfn_to_pfn_t (pfn,PFN_DEV )); +__pfn_to_pfn_t (pfn,PFN_DEV )); out_unlock:mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/omapdrm/omap_gem.c +2 -2
@@ -386,7 +386,7 @@ static int fault_1d(struct drm_gem_object *obj, pfn, pfn << PAGE_SHIFT);return vm_insert_mixed (vma, (unsigned long )vmf->virtual_address, -pfn_to_pfn_t (pfn,PFN_DEV )); +__pfn_to_pfn_t (pfn,PFN_DEV )); }/* Special handling for the case of faulting in 2d tiled buffers */
@@ -480,7 +480,7 @@ static int fault_2d(struct drm_gem_object *obj,for (i = n; i >0 ; i--) {vm_insert_mixed (vma, (unsigned long )vaddr, -pfn_to_pfn_t (pfn,PFN_DEV )); +__pfn_to_pfn_t (pfn,PFN_DEV )); pfn += usergart[fmt].stride_pfn; vaddr +=PAGE_SIZE * m; }
fs/dax.c +1 -1
@@ -692,7 +692,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,dax_unmap_atomic (bdev, &dax); result |=vmf_insert_pfn_pmd (vma, address, pmd, -pfn_t_to_pfn (dax.pfn), write); + dax.pfn, write); } out:
include/asm-generic/pgtable.h +4 -2
@@ -1,6 +1,8 @@#ifndef _ASM_GENERIC_PGTABLE_H#define _ASM_GENERIC_PGTABLE_H +#include <linux/pfn.h> +#ifndef __ASSEMBLY__#ifdef CONFIG_MMU
@@ -549,7 +551,7 @@ static inline int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot,* by vm_insert_pfn(). */ static inline int track_pfn_insert (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn) +pfn_t pfn) {return 0 ; }
@@ -577,7 +579,7 @@ extern int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size);extern int track_pfn_insert (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn); +pfn_t pfn);extern int track_pfn_copy (struct vm_area_struct *vma);extern void untrack_pfn (struct vm_area_struct *vma,unsigned long pfn,unsigned long size);
include/linux/huge_mm.h +1 -1
@@ -37,7 +37,7 @@ extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, pgprot_t newprot, int prot_numa);int vmf_insert_pfn_pmd (struct vm_area_struct *,unsigned long addr,pmd_t *, -unsigned long pfn,bool write); +pfn_t pfn,bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG ,
include/linux/mm.h +9 -1
@@ -1072,7 +1072,14 @@ static inline pte_t pfn_t_pte(pfn_t pfn, pgprot_t pgprot) }#endif -#ifdef __HAVE_ARCH_PTE_DEVICE +#ifdef pfn_pmd +static inline pmd_t pfn_t_pmd (pfn_t pfn,pgprot_t pgprot) +{ +return pfn_pmd (pfn_t_to_pfn (pfn), pgprot); +} +#endif + +#ifdef __HAVE_ARCH_PTE_DEVMAPstatic inline bool pfn_t_devmap (pfn_t pfn) {const unsigned long flags =PFN_DEV |PFN_MAP ;
@@ -1085,6 +1092,7 @@ static inline bool pfn_t_devmap(pfn_t pfn) return false; }pte_t pte_mkdevmap (pte_t pte); +pmd_t pmd_mkdevmap (pmd_t pmd);#endif /*
mm/huge_memory.c +6 -4
@@ -960,14 +960,16 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, }static void insert_pfn_pmd (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmd,unsigned long pfn,pgprot_t prot,bool write) +pmd_t *pmd,pfn_t pfn,pgprot_t prot,bool write) {struct mm_struct *mm = vma->vm_mm;pmd_t entry;spinlock_t *ptl; ptl =pmd_lock (mm, pmd); - entry =pmd_mkhuge (pfn_pmd (pfn, prot)); + entry =pmd_mkhuge (pfn_t_pmd (pfn, prot)); +if (pfn_t_devmap (pfn)) + entry =pmd_mkdevmap (entry);if (write) { entry =pmd_mkyoung (pmd_mkdirty (entry)); entry =maybe_pmd_mkwrite (entry, vma);
@@ -978,7 +980,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, }int vmf_insert_pfn_pmd (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmd,unsigned long pfn,bool write) +pmd_t *pmd,pfn_t pfn,bool write) {pgprot_t pgprot = vma->vm_page_prot;/*
@@ -990,7 +992,7 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,BUG_ON ((vma->vm_flags & (VM_PFNMAP |VM_MIXEDMAP )) == (VM_PFNMAP |VM_MIXEDMAP ));BUG_ON ((vma->vm_flags &VM_PFNMAP ) &&is_cow_mapping (vma->vm_flags)); -BUG_ON ((vma->vm_flags &VM_MIXEDMAP ) &&pfn_valid (pfn)); +BUG_ON (!pfn_t_devmap (pfn));if (addr < vma->vm_start || addr >= vma->vm_end)return VM_FAULT_SIGBUS ;
mm/memory.c +1 -1
@@ -1566,7 +1566,7 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,if (addr < vma->vm_start || addr >= vma->vm_end)return -EFAULT ; -if (track_pfn_insert (vma, &pgprot, pfn)) +if (track_pfn_insert (vma, &pgprot,__pfn_to_pfn_t (pfn,PFN_DEV )))return -EINVAL ; ret =insert_pfn (vma, addr,__pfn_to_pfn_t (pfn,PFN_DEV ), pgprot);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 19/25 list: introduce list_del_poison()
In reply to Dan WilliamsZONE_DEVICE pages always have an elevated count and will never be on an lru reclaim list. That space in 'struct page' can be redirected for other uses, but for safety introduce a poison value that will always trip __list_add() to assert. This allows half of the struct list_head storage to be reclaimed with some assurance to back up the assumption that the page count never goes to zero and a list_add() is never attempted.
--- include/linux/list.h | 17 +++++++++++++++++ lib/list_debug.c | 4 ++++ 2 files changed, 21 insertions(+)
include/linux/list.h +17 -0
@@ -108,9 +108,26 @@ static inline void list_del(struct list_head *entry) entry->next =LIST_POISON1 ; entry->prev = LIST_POISON2; } + +#define list_del_poison list_del#else extern void __list_del_entry (struct list_head *entry);extern void list_del (struct list_head *entry); +extern struct list_head list_force_poison; + +/** +* list_del_poison - poison an entry to always assert on list_add +* @entry: the element to delete and poison +* +* Note: the assertion on list_add() only occurs when CONFIG_DEBUG_LIST=y, +* otherwise this is identical to list_del() +*/ +static inline void list_del_poison (struct list_head *entry) +{ +__list_del (entry->prev, entry->next); + entry->next = &list_force_poison; + entry->prev = &list_force_poison; +}#endif /**
lib/list_debug.c +4 -0
@@ -12,6 +12,8 @@#include <linux/kernel.h> #include <linux/rculist.h> +struct list_head list_force_poison; +/* * Insert a new entry between two known consecutive entries. *
@@ -23,6 +25,8 @@ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { + WARN(new->next == &list_force_poison || new->prev == &list_force_poison, + "list_add attempted on force-poisoned entry\n"); WARN(next->prev != prev, "list_add corruption. next->prev should be " "prev (%p), but was %p. (next=%p).\n",
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [-mm PATCH v2 19/25] list: introduce list_del_poison()
Quoted 27 lines · On Wed, 09 Dec 2015 18:38:55 -0800 Dan Williams <[email protected]>…
ZONE_DEVICEpages always have an elevated count and will never be on an lru reclaim list. That space in 'struct page' can be redirected for other uses, but for safety introduce a poison value that will always trip__list_add()to assert. This allows half of the structlist_headstorage to be reclaimed with some assurance to back up the assumption that the page count never goes to zero and alist_add()is never attempted....
include/linux/list.h +8
-0@@ -108,9 +108,26 @@ static inline void list_del(struct list_head *entry) entry->next =LIST_POISON1 ; entry->prev = LIST_POISON2; } + +#define list_del_poison list_del#else extern void __list_del_entry (struct list_head *entry);extern void list_del (struct list_head *entry); +extern struct list_head list_force_poison; + +/** +* list_del_poison - poison an entry to always assert on list_add +* @entry: the element to delete and poison +*
include/linux/list.h static inline void list_del(struct list_head *entry) · line 131
Quoted 10 lines
include/linux/list.h +9
-0+* Note: the assertion on list_add() only occurs when CONFIG_DEBUG_LIST=y, +* otherwise this is identical to list_del() +*/ +static inline void list_del_poison (struct list_head *entry) +{ +__list_del (entry->prev, entry->next); + entry->next = &list_force_poison; + entry->prev = &list_force_poison; +}#endif
list_del() already poisons the list_head. Does this really add anything?
Quoted 15 lines
include/linux/list.h +0
-0/** lib/list_debug.c +2
-0@@ -12,6 +12,8 @@#include <linux/kernel.h> #include <linux/rculist.h> +struct list_head list_force_poison; +/* * Insert a new entry between two known consecutive entries. *
lib/list_debug.c void __list_add(struct list_head *new, · line 29
Quoted 5 lines
lib/list_debug.c +2
-0@@ -23,6 +25,8 @@ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { + WARN(new->next == &list_force_poison || new->prev == &list_force_poison, + "list_add attempted on force-poisoned entry\n");
I suppose that list_replace() should poison as well, and perhaps other places were missed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v2 19/25] list: introduce list_del_poison()
Quoted 33 lines · Andrew Morton
Quoted 31 lines · On Wed, 09 Dec 2015 18:38:55 -0800 Dan Williams <[email protected]>…
ZONE_DEVICEpages always have an elevated count and will never be on an lru reclaim list. That space in 'struct page' can be redirected for other uses, but for safety introduce a poison value that will always trip__list_add()to assert. This allows half of the structlist_headstorage to be reclaimed with some assurance to back up the assumption that the page count never goes to zero and alist_add()is never attempted....
include/linux/list.h +12
-0@@ -108,9 +108,26 @@ static inline void list_del(struct list_head *entry) entry->next =LIST_POISON1 ; entry->prev = LIST_POISON2; } + +#define list_del_poison list_del#else extern void __list_del_entry (struct list_head *entry);extern void list_del (struct list_head *entry); +extern struct list_head list_force_poison; + +/** +* list_del_poison - poison an entry to always assert on list_add +* @entry: the element to delete and poison +* +* Note: the assertion on list_add() only occurs when CONFIG_DEBUG_LIST=y, +* otherwise this is identical to list_del() +*/ +static inline void list_del_poison (struct list_head *entry)
Quoted 8 lines
include/linux/list.h static inline void list_del(struct list_head *entry) · line 131
Quoted 6 lines
include/linux/list.h +5
-0+{ +__list_del (entry->prev, entry->next); + entry->next = &list_force_poison; + entry->prev = &list_force_poison; +}#endif
list_del()already poisons thelist_head. Does this really add anything?
The poison values that list_del() injects detect double-deletion, but it is fine to re-add a deleted entry.
This version causes list_add() to warn if the list entry is ever attempted to be added.
Maybe it is better called list_del_permanent(), but this really is a special case to catch code that attempts to use page->lru for a zone_device page. I think I'll make list_del_poison() private to kernel/memremap.c for now, I don't suspect any other code is doing union tricks like struct page to re-purpose fields.
Quoted 9 lines
Quoted 9 lines
include/linux/list.h +0
-0/** lib/list_debug.c +0
-0@@ -12,6 +12,8 @@#include <linux/kernel.h> #include <linux/rculist.h>
Quoted 15 lines
lib/list_debug.c void __list_add(struct list_head *new, · line 29
Quoted 11 lines
lib/list_debug.c +4
-0+struct list_head list_force_poison; +/* * Insert a new entry between two known consecutive entries. * @@ -23,6 +25,8 @@ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { + WARN(new->next == &list_force_poison || new->prev == &list_force_poison, + "list_add attempted on force-poisoned entry\n");I suppose that
list_replace()should poison as well, and perhaps other places were missed.
At least in the case of list_replace() it has to have gone through a list_add() first.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 20/25 libnvdimm, pmem: move request_queue allocation earlier in probe
In reply to Dan WilliamsBefore the dynamically allocated struct pages from devm_memremap_pages() can be put to use outside the driver, we need a mechanism to track whether they are still in use at teardown. Towards that goal reorder the initialization sequence to allow the 'q_usage_counter' from the request_queue to be used by the devm_memremap_pages() implementation (in subsequent patches).
--- drivers/nvdimm/pmem.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/nvdimm/pmem.c +20 -13
@@ -124,6 +124,7 @@ static struct pmem_device *pmem_alloc(struct device *dev, struct resource *res, int id) {struct pmem_device *pmem; +struct request_queue *q; pmem =devm_kzalloc (dev,sizeof (*pmem),GFP_KERNEL );if (!pmem)
@@ -141,6 +142,10 @@ static struct pmem_device *pmem_alloc(struct device *dev,return ERR_PTR (-EBUSY ); } + q =blk_alloc_queue_node (GFP_KERNEL ,dev_to_node (dev)); +if (!q) +return ERR_PTR (-ENOMEM ); + pmem->pfn_flags =PFN_DEV ;if (pmem_should_map_pages (dev)) { pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res,
@@ -151,9 +156,12 @@ static struct pmem_device *pmem_alloc(struct device *dev, pmem->phys_addr, pmem->size, ARCH_MEMREMAP_PMEM); -if (IS_ERR (pmem->virt_addr)) +if (IS_ERR (pmem->virt_addr)) { +blk_cleanup_queue (q);return (void __force *) pmem->virt_addr; + } + pmem->pmem_queue = q;return pmem; }
@@ -173,10 +181,6 @@ static int pmem_attach_disk(struct device *dev,int nid =dev_to_node (dev);struct gendisk *disk; - pmem->pmem_queue =blk_alloc_queue_node (GFP_KERNEL , nid); -if (!pmem->pmem_queue) -return -ENOMEM ; -blk_queue_make_request (pmem->pmem_queue, pmem_make_request);blk_queue_physical_block_size (pmem->pmem_queue,PAGE_SIZE );blk_queue_max_hw_sectors (pmem->pmem_queue,UINT_MAX );
@@ -411,19 +415,22 @@ static int nd_pmem_probe(struct device *dev)dev_set_drvdata (dev, pmem); ndns->rw_bytes = pmem_rw_bytes; -if (is_nd_btt (dev)) +if (is_nd_btt (dev)) { +/* btt allocates its own request_queue */ +blk_cleanup_queue (pmem->pmem_queue); + pmem->pmem_queue =NULL ;return nvdimm_namespace_attach_btt (ndns); + }if (is_nd_pfn (dev))return nvdimm_namespace_attach_pfn (ndns); -if (nd_btt_probe (ndns, pmem) ==0 ) { -/* we'll come back as btt-pmem */ -return -ENXIO ; - } - -if (nd_pfn_probe (ndns, pmem) ==0 ) { -/* we'll come back as pfn-pmem */ +if (nd_btt_probe (ndns, pmem) ==0 ||nd_pfn_probe (ndns, pmem) ==0 ) { +/* +* We'll come back as either btt-pmem, or pfn-pmem, so +* drop the queue allocation for now. +*/ +blk_cleanup_queue (pmem->pmem_queue);return -ENXIO ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 21/25 mm, dax, pmem: introduce {get|put}_dev_pagemap() for dax-gup
In reply to Dan Williamsget_dev_page() enables paths like get_user_pages() to pin a dynamically mapped pfn-range (devm_memremap_pages()) while the resulting struct page objects are in use. Unlike get_page() it may fail if the device is, or is in the process of being, disabled. While the initial lookup of the range may be an expensive list walk, the result is cached to speed up subsequent lookups which are likely to be in the same mapped range.
devm_memremap_pages() now requires a reference counter to be specified at init time. For pmem this means moving request_queue allocation into pmem_alloc() so the existing queue usage counter can track "device pages".
--- drivers/nvdimm/pmem.c | 6 +++-- include/linux/mm.h | 49 +++++++++++++++++++++++++++++++++++++++++-- include/linux/mm_types.h | 5 ++++ kernel/memremap.c | 53 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 105 insertions(+), 8 deletions(-)
drivers/nvdimm/pmem.c +4 -2
@@ -149,7 +149,7 @@ static struct pmem_device *pmem_alloc(struct device *dev, pmem->pfn_flags =PFN_DEV ;if (pmem_should_map_pages (dev)) { pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res, -NULL ); + &q->q_usage_counter,NULL ); pmem->pfn_flags |=PFN_MAP ; }else pmem->virt_addr = (void __pmem *) devm_memremap(dev,
@@ -323,6 +323,7 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)struct vmem_altmap *altmap;struct nd_pfn_sb *pfn_sb;struct pmem_device *pmem; +struct request_queue *q;phys_addr_t offset;int rc;struct vmem_altmap __altmap = {
@@ -374,9 +375,10 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)/* establish pfn range for lookup, and switch to direct map */ pmem =dev_get_drvdata (dev); + q = pmem->pmem_queue;devm_memunmap (dev, (void __force *) pmem->virt_addr); pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res, - altmap); + &q->q_usage_counter, altmap); pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr);
include/linux/mm.h +47 -2
86 lines not on this page · raw message
include/linux/mm_types.h +5 -0
@@ -116,6 +116,11 @@ struct page {* Can be used as a generic list * by the page owner. */ +struct dev_pagemap *pgmap;/* ZONE_DEVICE pages are never on an +* lru or handled by a slab +* allocator, this points to the +* hosting device page map. +*/ struct {/* slub per cpu partial pages */ struct page *next;/* Next partial slab */ #ifdef CONFIG_64BIT
kernel/memremap.c +49 -4
99 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [-mm PATCH v2 21/25] mm, dax, pmem: introduce {get|put}_dev_pagemap() for dax-gup
Quoted 65 lines · On Wed, 09 Dec 2015 18:39:06 -0800 Dan Williams <[email protected]>…
get_dev_page()enables paths likeget_user_pages()to pin a dynamically mapped pfn-range (devm_memremap_pages()) while the resulting struct page objects are in use. Unlikeget_page()it may fail if the device is, or is in the process of being, disabled. While the initial lookup of the range may be an expensive list walk, the result is cached to speed up subsequent lookups which are likely to be in the same mapped range.
devm_memremap_pages()now requires a reference counter to be specified at init time. For pmem this means movingrequest_queueallocation intopmem_alloc()so the existing queue usage counter can track "device pages".Cc Dave Hansen <[email protected]>Cc Andrew Morton <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Ross Zwisler <[email protected]>Cc Alexander Viro <[email protected]>Tested-by Logan Gunthorpe <[email protected]>Signed-off-by Dan Williams <[email protected]>--- drivers/nvdimm/pmem.c | 6 +++-- include/linux/mm.h | 49 +++++++++++++++++++++++++++++++++++++++++-- include/linux/mm_types.h | 5 ++++ kernel/memremap.c | 53 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 105 insertions(+), 8 deletions(-)drivers/nvdimm/pmem.c +4
-2@@ -149,7 +149,7 @@ static struct pmem_device *pmem_alloc(struct device *dev, pmem->pfn_flags =PFN_DEV ;if (pmem_should_map_pages (dev)) { pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, res, -NULL ); + &q->q_usage_counter,NULL ); pmem->pfn_flags |=PFN_MAP ; }else pmem->virt_addr = (void __pmem *) devm_memremap(dev,@@ -323,6 +323,7 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)struct vmem_altmap *altmap;struct nd_pfn_sb *pfn_sb;struct pmem_device *pmem; +struct request_queue *q;phys_addr_t offset;int rc;struct vmem_altmap __altmap = {@@ -374,9 +375,10 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)/* establish pfn range for lookup, and switch to direct map */ pmem =dev_get_drvdata (dev); + q = pmem->pmem_queue;devm_memunmap (dev, (void __force *) pmem->virt_addr); pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res, - altmap); + &q->q_usage_counter, altmap); pmem->pfn_flags |=PFN_MAP ;if (IS_ERR (pmem->virt_addr)) { rc =PTR_ERR (pmem->virt_addr);include/linux/mm.h +0
-0@@ -15,12 +15,14 @@#include <linux/debug_locks.h>
include/linux/mm.h line 25
Quoted 10 lines
include/linux/mm.h +2
-0#include <linux/mm_types.h> #include <linux/range.h> +#include <linux/percpu-refcount.h> #include <linux/pfn.h> #include <linux/bit_spinlock.h> #include <linux/shrinker.h> #include <linux/resource.h> #include <linux/page_ext.h> #include <linux/err.h> +#include <linux/ioport.h>
Oh geeze, poor old mm.h.
Quoted 29 lines
...
include/linux/mm.h +22
-0@@ -785,6 +791,45 @@ static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start) }#endif +/** +* get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn +* @pfn: page frame number to lookup page_map +* @pgmap: optional known pgmap that already has a reference +* +* @pgmap allows the overhead of a lookup to be bypassed when @pfn lands in the +* same mapping. +*/ +static inline struct dev_pagemap *get_dev_pagemap (unsigned long pfn, +struct dev_pagemap *pgmap) +{ +const struct resource *res = pgmap ? pgmap->res :NULL ; +resource_size_t phys =__pfn_to_phys (pfn); + +/* +* In the cached case we're already holding a live reference so +* we can simply do a blind increment +*/ +if (res && phys >= res->start && phys <= res->end) { +percpu_ref_get (pgmap->ref); +return pgmap; + }
include/linux/mm.h static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start) · line 825
Quoted 10 lines
include/linux/mm.h +10
-0+ +/* fall back to slow path lookup */ +rcu_read_lock (); + pgmap =find_dev_pagemap (phys); +if (pgmap && !percpu_ref_tryget_live (pgmap->ref)) + pgmap =NULL ; +rcu_read_unlock (); + +return pgmap; +}
Big. Does it need to be inlined?
include/linux/mm.h static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
Quoted 9 lines
include/linux/mm.h +6
-0+static inline void put_dev_pagemap (struct dev_pagemap *pgmap) +{ +if (pgmap) +percpu_ref_put (pgmap->ref); +} +
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 22/25 mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd
In reply to Dan WilliamsA dax-huge-page mapping while it uses some thp helpers is ultimately not a transparent huge page. The distinction is especially important in the get_user_pages() path. pmd_devmap() is used to distinguish dax-pmds from pmd_huge() and pmd_trans_huge() which have slightly different semantics.
Explicitly mark the pmd_trans_huge() helpers that dax needs by adding pmd_devmap() checks.
Also, before we introduce usages of pmd_pfn() in common code, include a definition for archs that have not needed it to date.
--- arch/ia64/include/asm/pgtable.h | 1 + arch/sh/include/asm/pgtable-3level.h | 1 + arch/x86/include/asm/pgtable.h | 8 +++++++- include/asm-generic/pgtable.h | 4 ++++ include/linux/huge_mm.h | 3 ++- include/linux/mm.h | 4 ++++ mm/huge_memory.c | 33 +++++++++++++++++++-------------- mm/memory.c | 8 ++++---- mm/mprotect.c | 5 +++-- mm/pgtable-generic.c | 2 +- 10 files changed, 46 insertions(+), 23 deletions(-)
arch/ia64/include/asm/pgtable.h +1 -0
@@ -273,6 +273,7 @@ extern unsigned long VMALLOC_END;#define pmd_clear (pmdp) (pmd_val(*(pmdp)) = 0UL)#define pmd_page_vaddr (pmd) ((unsigned long) __va(pmd_val(pmd) & _PFN_MASK))#define pmd_page (pmd) virt_to_page((pmd_val(pmd) + PAGE_OFFSET)) +#define pmd_pfn (pmd) (pmd_val(pmd) >> PAGE_SHIFT)#define pud_none (pud) (!pud_val(pud))#define pud_bad (pud) (!ia64_phys_addr_valid(pud_val(pud)))
arch/sh/include/asm/pgtable-3level.h +1 -0
@@ -29,6 +29,7 @@typedef struct {unsigned long long pmd; }pmd_t ;#define pmd_val (x) ((x).pmd) +#define pmd_pfn (x) ((pmd_val(x) & PMD_MASK) >> PAGE_SHIFT)#define __pmd (x) ((pmd_t) { (x) } )static inline unsigned long pud_page_vaddr (pud_t pud)
arch/x86/include/asm/pgtable.h +7 -1
@@ -164,7 +164,13 @@ static inline int pmd_large(pmd_t pte)#ifdef CONFIG_TRANSPARENT_HUGEPAGE static inline int pmd_trans_huge (pmd_t pmd) { -return pmd_val (pmd) & _PAGE_PSE; +return (pmd_val (pmd) & (_PAGE_PSE|_PAGE_DEVMAP)) == _PAGE_PSE; +} + +#define pmd_devmap pmd_devmap +static inline int pmd_devmap (pmd_t pmd) +{ +return !!(pmd_val (pmd) & _PAGE_DEVMAP); }static inline int has_transparent_hugepage (void )
include/asm-generic/pgtable.h +4 -0
@@ -616,6 +616,10 @@ static inline int pmd_trans_huge(pmd_t pmd) {return 0 ; } +static inline int pmd_devmap (pmd_t pmd) +{ +return 0 ; +}#ifndef __HAVE_ARCH_PMD_WRITEstatic inline int pmd_write (pmd_t pmd) {
include/linux/huge_mm.h +2 -1
@@ -104,7 +104,8 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,#define split_huge_pmd (__vma, __pmd, __address) \ do { \ pmd_t *____pmd = (__pmd); \ - if (pmd_trans_huge(*____pmd)) \ + if (pmd_trans_huge(*____pmd) \ + || pmd_devmap(*____pmd)) \ __split_huge_pmd(__vma, __pmd, __address); \ } while (0)
include/linux/mm.h +4 -0
@@ -1935,6 +1935,10 @@ static inline void pgtable_pmd_page_dtor(struct page *page) {}#define pte_devmap (x) (0)#endif +#ifndef pmd_devmap +#define pmd_devmap (x) (0) +#endif +static inline spinlock_t *pmd_lock (struct mm_struct *mm,pmd_t *pmd) {spinlock_t *ptl =pmd_lockptr (mm, pmd);
mm/huge_memory.c +19 -14
@@ -1023,7 +1023,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, ret = -EAGAIN ; pmd = *src_pmd; -if (unlikely (!pmd_trans_huge (pmd))) { +if (unlikely (!pmd_trans_huge (pmd) && !pmd_devmap (pmd))) {pte_free (dst_mm, pgtable); goto out_unlock; }
@@ -1046,17 +1046,20 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, goto out_unlock; } - src_page =pmd_page (pmd); -VM_BUG_ON_PAGE (!PageHead (src_page), src_page); -get_page (src_page); -page_dup_rmap (src_page, true); -add_mm_counter (dst_mm,MM_ANONPAGES ,HPAGE_PMD_NR ); +if (pmd_trans_huge (pmd)) { +/* thp accounting separate from pmd_devmap accounting */ + src_page =pmd_page (pmd); +VM_BUG_ON_PAGE (!PageHead (src_page), src_page); +get_page (src_page); +page_dup_rmap (src_page, true); +add_mm_counter (dst_mm,MM_ANONPAGES ,HPAGE_PMD_NR ); +atomic_long_inc (&dst_mm->nr_ptes); +pgtable_trans_huge_deposit (dst_mm, dst_pmd, pgtable); + }pmdp_set_wrprotect (src_mm, addr, src_pmd); pmd =pmd_mkold (pmd_wrprotect (pmd)); -pgtable_trans_huge_deposit (dst_mm, dst_pmd, pgtable);set_pmd_at (dst_mm, addr, dst_pmd, pmd); -atomic_long_inc (&dst_mm->nr_ptes); ret =0 ; out_unlock:
@@ -1744,7 +1747,7 @@ bool __pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma, spinlock_t **ptl) { *ptl =pmd_lock (vma->vm_mm, pmd); -if (likely (pmd_trans_huge (*pmd))) +if (likely (pmd_trans_huge (*pmd) ||pmd_devmap (*pmd)))return true;spin_unlock (*ptl);return false;
@@ -2861,7 +2864,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,VM_BUG_ON (haddr & ~HPAGE_PMD_MASK );VM_BUG_ON_VMA (vma->vm_start > haddr, vma);VM_BUG_ON_VMA (vma->vm_end < haddr +HPAGE_PMD_SIZE , vma); -VM_BUG_ON (!pmd_trans_huge (*pmd)); +VM_BUG_ON (!pmd_trans_huge (*pmd) && !pmd_devmap (*pmd));count_vm_event (THP_SPLIT_PMD );
@@ -2974,11 +2977,13 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,mmu_notifier_invalidate_range_start (mm, haddr, haddr +HPAGE_PMD_SIZE ); ptl =pmd_lock (mm, pmd); -if (unlikely (!pmd_trans_huge (*pmd))) +if (unlikely (!pmd_trans_huge (*pmd) && !pmd_devmap (*pmd))) goto out; - page =pmd_page (*pmd);__split_huge_pmd_locked (vma, pmd, haddr, false); -if (PageMlocked (page)) + +if (pmd_trans_huge (*pmd)) + page =pmd_page (*pmd); +if (page &&PageMlocked (page))get_page (page);else page =NULL ;
@@ -3011,7 +3016,7 @@ static void split_huge_pmd_address(struct vm_area_struct *vma,return ; pmd =pmd_offset (pud, address); -if (!pmd_present (*pmd) || !pmd_trans_huge (*pmd)) +if (!pmd_present (*pmd) || (!pmd_trans_huge (*pmd) && !pmd_devmap (*pmd)))return ;/* * Caller holds the mmap_sem write mode, so a huge pmd cannot
mm/memory.c +4 -4
@@ -949,7 +949,7 @@ static inline int copy_pmd_range(struct mm_struct *dst_mm, struct mm_struct *src src_pmd =pmd_offset (src_pud, addr); do { next = pmd_addr_end(addr, end); - if (pmd_trans_huge(*src_pmd)) { + if (pmd_trans_huge(*src_pmd) || pmd_devmap(*src_pmd)) { int err; VM_BUG_ON(next-addr != HPAGE_PMD_SIZE); err = copy_huge_pmd(dst_mm, src_mm,
@@ -1176,7 +1176,7 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb, pmd =pmd_offset (pud, addr); do { next = pmd_addr_end(addr, end); - if (pmd_trans_huge(*pmd)) { + if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { if (next - addr != HPAGE_PMD_SIZE) { #ifdef CONFIG_DEBUG_VM if (!rwsem_is_locked(&tlb->mm->mmap_sem)) {
@@ -3374,7 +3374,7 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,int ret;barrier (); -if (pmd_trans_huge (orig_pmd)) { +if (pmd_trans_huge (orig_pmd) ||pmd_devmap (orig_pmd)) {unsigned int dirty = flags &FAULT_FLAG_WRITE ;if (pmd_protnone (orig_pmd))
@@ -3403,7 +3403,7 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unlikely(__pte_alloc(mm, vma, pmd, address)))return VM_FAULT_OOM ;/* if an huge pmd materialized from under us just retry later */ -if (unlikely (pmd_trans_huge (*pmd))) +if (unlikely (pmd_trans_huge (*pmd) ||pmd_devmap (*pmd)))return 0 ;/* * A regular pmd is established and it can't morph into a huge pmd
mm/mprotect.c +3 -2
@@ -149,7 +149,8 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,unsigned long this_pages; next =pmd_addr_end (addr, end); -if (!pmd_trans_huge (*pmd) &&pmd_none_or_clear_bad (pmd)) +if (!pmd_trans_huge (*pmd) && !pmd_devmap (*pmd) + &&pmd_none_or_clear_bad (pmd))continue ;/* invoke the mmu notifier if the pmd is populated */
@@ -158,7 +159,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,mmu_notifier_invalidate_range_start (mm, mni_start, end); } -if (pmd_trans_huge (*pmd)) { +if (pmd_trans_huge (*pmd) ||pmd_devmap (*pmd)) {if (next - addr !=HPAGE_PMD_SIZE )split_huge_pmd (vma, pmd, addr);else {
mm/pgtable-generic.c +1 -1
@@ -132,7 +132,7 @@ pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, {pmd_t pmd;VM_BUG_ON (address & ~HPAGE_PMD_MASK ); -VM_BUG_ON (!pmd_trans_huge (*pmdp)); +VM_BUG_ON (!pmd_trans_huge (*pmdp) && !pmd_devmap (*pmdp)); pmd =pmdp_huge_get_and_clear (vma->vm_mm, address, pmdp);flush_pmd_tlb_range (vma, address, address +HPAGE_PMD_SIZE );return pmd;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 23/25 mm, x86: get_user_pages() for dax mappings
In reply to Dan WilliamsA dax mapping establishes a pte with _PAGE_DEVMAP set when the driver has established a devm_memremap_pages() mapping, i.e. when the pfn_t return from ->direct_access() has PFN_DEV and PFN_MAP set. Later, when encountering _PAGE_DEVMAP during a page table walk we lookup and pin a struct dev_pagemap instance to keep the result of pfn_to_page() valid until put_page().
--- arch/x86/mm/gup.c | 56 ++++++++++++++++++++++++++++++++++-- include/linux/huge_mm.h | 10 ++++++ include/linux/mm.h | 35 ++++++++++++++++------ mm/gup.c | 18 +++++++++++ mm/huge_memory.c | 74 +++++++++++++++++++++++++++++++++++++---------- mm/swap.c | 15 ++++++++++ 6 files changed, 178 insertions(+), 30 deletions(-)
arch/x86/mm/gup.c +53 -3
@@ -63,6 +63,16 @@ retry:#endif } +static void undo_dev_pagemap (int *nr,int nr_start,struct page **pages) +{ +while ((*nr) - nr_start) { +struct page *page = pages[--(*nr)]; + +ClearPageReferenced (page); +put_page (page); + } +} +/* * The performance critical leaf functions are made noinline otherwise gcc * inlines everything into a single function which results in too much
@@ -71,7 +81,9 @@ retry: static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,unsigned long end,int write,struct page **pages,int *nr) { +struct dev_pagemap *pgmap =NULL ;unsigned long mask; +int nr_start = *nr;pte_t *ptep; mask = _PAGE_PRESENT|_PAGE_USER;
@@ -89,13 +101,21 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,return 0 ; } -if ((pte_flags (pte) & (mask | _PAGE_SPECIAL)) != mask) { + page =pte_page (pte); +if (pte_devmap (pte)) { + pgmap =get_dev_pagemap (pte_pfn (pte), pgmap); +if (unlikely (!pgmap)) { +undo_dev_pagemap (nr, nr_start, pages); +pte_unmap (ptep); +return 0 ; + } + }else if ((pte_flags (pte) & (mask | _PAGE_SPECIAL)) != mask) {pte_unmap (ptep);return 0 ; }VM_BUG_ON (!pfn_valid (pte_pfn (pte))); - page =pte_page (pte);get_page (page); +put_dev_pagemap (pgmap);SetPageReferenced (page); pages[*nr] = page; (*nr)++;
@@ -114,6 +134,32 @@ static inline void get_head_page_multiple(struct page *page, int nr)SetPageReferenced (page); } +static int __gup_device_huge_pmd (pmd_t pmd,unsigned long addr, +unsigned long end,struct page **pages,int *nr) +{ +int nr_start = *nr; +unsigned long pfn =pmd_pfn (pmd); +struct dev_pagemap *pgmap =NULL ; + + pfn += (addr & ~PMD_MASK ) >>PAGE_SHIFT ; +do { +struct page *page =pfn_to_page (pfn); + + pgmap =get_dev_pagemap (pfn, pgmap); +if (unlikely (!pgmap)) { +undo_dev_pagemap (nr, nr_start, pages); +return 0 ; + } +SetPageReferenced (page); + pages[*nr] = page; +get_page (page); +put_dev_pagemap (pgmap); + (*nr)++; + pfn++; + }while (addr +=PAGE_SIZE , addr != end); +return 1 ; +} + static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,unsigned long end,int write,struct page **pages,int *nr) {
@@ -126,9 +172,13 @@ static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr, mask |= _PAGE_RW;if ((pmd_flags (pmd) & mask) != mask)return 0 ; + +VM_BUG_ON (!pfn_valid (pmd_pfn (pmd))); +if (pmd_devmap (pmd)) +return __gup_device_huge_pmd (pmd, addr, end, pages, nr); +/* hugepages are never "special" */ VM_BUG_ON (pmd_flags (pmd) & _PAGE_SPECIAL); -VM_BUG_ON (!pfn_valid (pmd_pfn (pmd))); refs =0 ; head =pmd_page (pmd);
include/linux/huge_mm.h +9 -1
@@ -38,7 +38,6 @@ extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, int prot_numa);int vmf_insert_pfn_pmd (struct vm_area_struct *,unsigned long addr,pmd_t *,pfn_t pfn,bool write); -enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,
@@ -55,6 +54,9 @@ enum transparent_hugepage_flag {#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)#ifdef CONFIG_TRANSPARENT_HUGEPAGE +struct page *follow_devmap_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd,int flags); +#define HPAGE_PMD_SHIFT PMD_SHIFT#define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT)#define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1))
@@ -205,6 +207,12 @@ static inline bool is_huge_zero_page(struct page *page)return false; } + +static inline struct page *follow_devmap_pmd (struct vm_area_struct *vma, +unsigned long addr,pmd_t *pmd,int flags) +{ +return NULL ; +}#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif /* _LINUX_HUGE_MM_H */
include/linux/mm.h +25 -10
@@ -460,16 +460,7 @@ static inline int page_count(struct page *page)return atomic_read (&compound_head (page)->_count); } -static inline void get_page (struct page *page) -{ - page =compound_head (page); -/* -* Getting a normal page or the head of a compound page -* requires to already have an elevated page->_count. -*/ -VM_BUG_ON_PAGE (atomic_read (&page->_count) <=0 , page); -atomic_inc (&page->_count); -} +extern bool __get_page_tail (struct page *page);static inline struct page *virt_to_head_page (const void *x) {
@@ -762,6 +753,11 @@ struct dev_pagemap {void *devm_memremap_pages (struct device *dev,struct resource *res,struct percpu_ref *ref,struct vmem_altmap *altmap);struct dev_pagemap *find_dev_pagemap (resource_size_t phys); + +static inline bool is_zone_device_page (const struct page *page) +{ +return page_zonenum (page) ==ZONE_DEVICE ; +}#else static inline void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref,
@@ -780,6 +776,11 @@ static inline struct dev_pagemap *find_dev_pagemap(resource_size_t phys) {return NULL ; } + +static inline bool is_zone_device_page (const struct page *page) +{ +return false; +}#endif #if defined(CONFIG_SPARSEMEM_VMEMMAP ) && defined(CONFIG_ZONE_DEVICE )
@@ -830,6 +831,20 @@ static inline void put_dev_pagemap(struct dev_pagemap *pgmap)percpu_ref_put (pgmap->ref); } +static inline void get_page (struct page *page) +{ +if (is_zone_device_page (page)) +percpu_ref_get (page->pgmap->ref); + + page =compound_head (page); +/* +* Getting a normal page or the head of a compound page +* requires to already have an elevated page->_count. +*/ +VM_BUG_ON_PAGE (atomic_read (&page->_count) <=0 , page); +atomic_inc (&page->_count); +} +#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP )#define SECTION_IN_PAGE_FLAGS #endif
mm/gup.c +17 -1
@@ -98,7 +98,16 @@ retry: } page =vm_normal_page (vma, address, pte); -if (unlikely (!page)) { +if (!page &&pte_devmap (pte) && (flags &FOLL_GET )) { +/* +* Only return device mapping pages in the FOLL_GET case since +* they are only valid while holding the pgmap reference. +*/ +if (get_dev_pagemap (pte_pfn (pte),NULL )) + page =pte_page (pte); +else + goto no_page; + }else if (unlikely (!page)) {if (flags &FOLL_DUMP ) {/* Avoid special (like zero) pages in core dumps */ page =ERR_PTR (-EFAULT );
@@ -237,6 +246,13 @@ struct page *follow_page_mask(struct vm_area_struct *vma, }if ((flags &FOLL_NUMA ) &&pmd_protnone (*pmd))return no_page_table (vma, flags); +if (pmd_devmap (*pmd)) { + ptl =pmd_lock (mm, pmd); + page =follow_devmap_pmd (vma, address, pmd, flags); +spin_unlock (ptl); +if (page) +return page; + }if (likely (!pmd_trans_huge (*pmd)))return follow_page_pte (vma, address, pmd, flags);
mm/huge_memory.c +59 -15
86 lines not on this page · raw message
mm/swap.c +15 -0
@@ -90,10 +90,25 @@ static void __put_compound_page(struct page *page) (*dtor)(page); } +static bool put_device_page (struct page *page) +{ +/* +* ZONE_DEVICE pages are never "onlined" so their reference +* counts never reach zero. They are always owned by a device +* driver, not the mm core. I.e. the page is 'idle' when the +* count is 1. +*/ +VM_BUG_ON_PAGE (atomic_read (&page->_count) ==1 , page); +put_dev_pagemap (page->pgmap); +return atomic_dec_return (&page->_count) ==1 ; +} +void __put_page (struct page *page) {if (unlikely (PageCompound (page)))__put_compound_page (page); +else if (is_zone_device_page (page)) +put_device_page (page);else __put_single_page (page); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [-mm PATCH v2 23/25] mm, x86: get_user_pages() for dax mappings
Quoted 6 lines · On Wed, 09 Dec 2015 18:39:16 -0800 Dan Williams <[email protected]>…
A dax mapping establishes a pte with
_PAGE_DEVMAPset when the driver has established adevm_memremap_pages()mapping, i.e. when thepfn_treturn from ->direct_access() hasPFN_DEVandPFN_MAPset. Later, when encountering_PAGE_DEVMAPduring a page table walk we lookup and pin a structdev_pagemapinstance to keep the result ofpfn_to_page()valid untilput_page().
This patch adds a whole bunch of code and cycles to everyone's kernels, but few of those kernels will ever use it. What are our options for reducing that overhead, presumably via Kconfig?
Quoted 5 lines
arch/x86/mm/gup.c +0
-0@@ -63,6 +63,16 @@ retry:#endif }
arch/x86/mm/gup.c retry: · line 74
Quoted 10 lines
arch/x86/mm/gup.c +9
-0+static void undo_dev_pagemap (int *nr,int nr_start,struct page **pages) +{ +while ((*nr) - nr_start) { +struct page *page = pages[--(*nr)]; + +ClearPageReferenced (page); +put_page (page); + } +}
PG_referenced is doing something magical in this code. Could we have a nice comment explaining its meaning in this context? Unless it's already there and I missed it..
arch/x86/mm/gup.c static inline void put_dev_pagemap(struct dev_pagemap *pgmap) · line 839
Quoted 13 lines
...
arch/x86/mm/gup.c +6
-0@@ -830,6 +831,20 @@ static inline void put_dev_pagemap(struct dev_pagemap *pgmap)percpu_ref_put (pgmap->ref); } +static inline void get_page (struct page *page) +{ +if (is_zone_device_page (page)) +percpu_ref_get (page->pgmap->ref); + + page =compound_head (page);
So we're assuming that is_zone_device_page() against a tail page works OK. That's presently true, fingers crossed for the future...
And we're also assuming that device pages are never compound. How safe is that assumption?
arch/x86/mm/gup.c static inline void put_dev_pagemap(struct dev_pagemap *pgmap) · line 846
Quoted 7 lines
arch/x86/mm/gup.c +7
-0+/* +* Getting a normal page or the head of a compound page +* requires to already have an elevated page->_count. +*/ +VM_BUG_ON_PAGE (atomic_read (&page->_count) <=0 , page); +atomic_inc (&page->_count); +}
The core pagecache lookup bypasses get_page() by using page_cache_get_speculative(), but get_page() might be a hotpath for some workloads. Here we're adding quite a bit of text and math and a branch. I'm counting 157 callsites.
So this is a rather unwelcome change. Why do we need to alter such a generic function as get_page() anyway? Is there some way to avoid altering it?
Quoted 46 lines
arch/x86/mm/gup.c +46
-0+static void touch_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd) +{ +pmd_t _pmd; + +/* +* We should set the dirty bit only for FOLL_WRITE but for now +* the dirty bit in the pmd is meaningless. And if the dirty +* bit will become meaningful and we'll only set it with +* FOLL_WRITE, an atomic set_bit will be required on the pmd to +* set the young bit, instead of the current set_pmd_at. +*/ + _pmd =pmd_mkyoung (pmd_mkdirty (*pmd)); +if (pmdp_set_access_flags (vma, addr &HPAGE_PMD_MASK , + pmd, _pmd,1 )) +update_mmu_cache_pmd (vma, addr, pmd); +} + +struct page *follow_devmap_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd,int flags) +{ +unsigned long pfn =pmd_pfn (*pmd); +struct mm_struct *mm = vma->vm_mm; +struct dev_pagemap *pgmap; +struct page *page; + +assert_spin_locked (pmd_lockptr (mm, pmd)); + +if (flags &FOLL_WRITE && !pmd_write (*pmd)) +return NULL ; + +if (pmd_present (*pmd) &&pmd_devmap (*pmd)) +/* pass */ ; +else +return NULL ; + +if (flags &FOLL_TOUCH ) +touch_pmd (vma, addr, pmd); + +/* +* device mapped pages can only be returned if the +* caller will manage the page reference count. +*/ +if (!(flags &FOLL_GET )) +return ERR_PTR (-EEXIST ); +
arch/x86/mm/gup.c static inline void put_dev_pagemap(struct dev_pagemap *pgmap)
Quoted 10 lines
arch/x86/mm/gup.c +10
-0+ pfn += (addr & ~PMD_MASK ) >>PAGE_SHIFT ; + pgmap =get_dev_pagemap (pfn,NULL ); +if (!pgmap) +return ERR_PTR (-EFAULT ); + page =pfn_to_page (pfn); +get_page (page); +put_dev_pagemap (pgmap); + +return page; +}
hm, so device pages can be huge. How does this play with get_page()'s assumption that the pages cannot be compound?
And again, this is bloating up the kernel for not-widely-used stuff.
Quoted 1 line
int copy_huge_pmd(struct
mm_struct*dst_mm, structmm_struct*src_mm,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v2 23/25] mm, x86: get_user_pages() for dax mappings
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Wed, 09 Dec 2015 18:39:16 -0800 Dan Williams <[email protected]>…
A dax mapping establishes a pte with
_PAGE_DEVMAPset when the driver has established adevm_memremap_pages()mapping, i.e. when thepfn_treturn from ->direct_access() hasPFN_DEVandPFN_MAPset. Later, when encountering_PAGE_DEVMAPduring a page table walk we lookup and pin a structdev_pagemapinstance to keep the result ofpfn_to_page()valid untilput_page().
Quoted 3 lines
This patch adds a whole bunch of code and cycles to everyone's kernels, but few of those kernels will ever use it. What are our options for reducing that overhead, presumably via
Kconfig?
It's does compile out when CONFIG_ZONE_DEVICE=n.
Quoted 6 lines
Quoted 6 lines
arch/x86/mm/gup.c +0
-0@@ -63,6 +63,16 @@ retry:#endif }
Quoted 13 lines
arch/x86/mm/gup.c retry: · line 74
Quoted 9 lines
arch/x86/mm/gup.c +9
-0+static void undo_dev_pagemap (int *nr,int nr_start,struct page **pages) +{ +while ((*nr) - nr_start) { +struct page *page = pages[--(*nr)]; + +ClearPageReferenced (page); +put_page (page); + } +}
PG_referencedis doing something magical in this code. Could we have a nice comment explaining its meaning in this context? Unless it's already there and I missed it..
In this case I'm just duplicating what gup_pte_range() already does with normal memory pages, no special meaning for zone_device pages.
Quoted 18 lines
Quoted 5 lines
...
arch/x86/mm/gup.c static inline void put_dev_pagemap(struct dev_pagemap *pgmap) · line 839
Quoted 9 lines
arch/x86/mm/gup.c +6
-0@@ -830,6 +831,20 @@ static inline void put_dev_pagemap(struct dev_pagemap *pgmap)percpu_ref_put (pgmap->ref); } +static inline void get_page (struct page *page) +{ +if (is_zone_device_page (page)) +percpu_ref_get (page->pgmap->ref); + + page =compound_head (page);So we're assuming that
is_zone_device_page()against a tail page works OK. That's presently true, fingers crossed for the future...
Quoted 2 lines
And we're also assuming that device pages are never compound. How safe is that assumption?
These pages are never on a slab lru or touched by the mm outside of get_user_pages() and the I/O path for dma mapping. It's a bug if a zone_device page is anything but a standalone vanilla page.
Quoted 8 lines
arch/x86/mm/gup.c static inline void put_dev_pagemap(struct dev_pagemap *pgmap) · line 846
Quoted 7 lines
arch/x86/mm/gup.c +7
-0+/* +* Getting a normal page or the head of a compound page +* requires to already have an elevated page->_count. +*/ +VM_BUG_ON_PAGE (atomic_read (&page->_count) <=0 , page); +atomic_inc (&page->_count); +}
Quoted 8 lines
The core pagecache lookup bypasses
get_page()by usingpage_cache_get_speculative(), butget_page()might be a hotpath for some workloads. Here we're adding quite a bit of text and math and a branch. I'm counting 157 callsites.So this is a rather unwelcome change. Why do we need to alter such a generic function as
get_page()anyway? Is there some way to avoid altering it?
The minimum requirement is to pin down the driver while the pages it allocated might be in active use for dma or other i/o. We could meet this requirement by simply pinning the driver while any dax vma is open.
The downside of this is that it blocks device driver unbind indefinitely while a dax vma is established rather than only temporarily blocking unbind/remove for the lifetime of an O_DIRECT I/O operation.
This goes back to a recurring debate about whether pmem is "memory" or a "storage-device / disk".
pmem as memory => pin it active while any vma is established
pmem as storage device => pin it active only while i/o is in flight and forcibly revoke mappings on an unbind/remove event.
Quoted 51 lines
Quoted 51 lines
arch/x86/mm/gup.c +51
-0+static void touch_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd) +{ +pmd_t _pmd; + +/* +* We should set the dirty bit only for FOLL_WRITE but for now +* the dirty bit in the pmd is meaningless. And if the dirty +* bit will become meaningful and we'll only set it with +* FOLL_WRITE, an atomic set_bit will be required on the pmd to +* set the young bit, instead of the current set_pmd_at. +*/ + _pmd =pmd_mkyoung (pmd_mkdirty (*pmd)); +if (pmdp_set_access_flags (vma, addr &HPAGE_PMD_MASK , + pmd, _pmd,1 )) +update_mmu_cache_pmd (vma, addr, pmd); +} + +struct page *follow_devmap_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd,int flags) +{ +unsigned long pfn =pmd_pfn (*pmd); +struct mm_struct *mm = vma->vm_mm; +struct dev_pagemap *pgmap; +struct page *page; + +assert_spin_locked (pmd_lockptr (mm, pmd)); + +if (flags &FOLL_WRITE && !pmd_write (*pmd)) +return NULL ; + +if (pmd_present (*pmd) &&pmd_devmap (*pmd)) +/* pass */ ; +else +return NULL ; + +if (flags &FOLL_TOUCH ) +touch_pmd (vma, addr, pmd); + +/* +* device mapped pages can only be returned if the +* caller will manage the page reference count. +*/ +if (!(flags &FOLL_GET )) +return ERR_PTR (-EEXIST ); + + pfn += (addr & ~PMD_MASK ) >>PAGE_SHIFT ; + pgmap =get_dev_pagemap (pfn,NULL ); +if (!pgmap) +return ERR_PTR (-EFAULT ); + page =pfn_to_page (pfn);
Quoted 8 lines
arch/x86/mm/gup.c
Quoted 5 lines
arch/x86/mm/gup.c +5
-0+get_page (page); +put_dev_pagemap (pgmap); + +return page; +}hm, so device pages can be huge. How does this play with get_page()'s assumption that the pages cannot be compound?
We don't need to track the pages as a compound unit because they'll never hit mm paths that care about the distinction. They are effectively never "onlined".
Quoted 1 line
And again, this is bloating up the kernel for not-widely-used stuff.
I suspect the ability to compile it out is little comfort since we're looking to get CONFIG_ZONE_DEVICE enabled by default in major distros. If that's the case I'm wiling to entertain the coarse pinning route. We can always circle back for the finer grained option if a problem arises, but let me know if CONFIG_ZONE_DEVICE=n was all you were looking for...
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [-mm PATCH v2 23/25] mm, x86: get_user_pages() for dax mappings
Quoted 2 lines · Dan Williams
On Tue, Dec 15, 2015 at 4:14 PM, Andrew Morton
<[email protected]> wrote:
[..]
Quoted 8 lines
Quoted 1 line
And again, this is bloating up the kernel for not-widely-used stuff.
I suspect the ability to compile it out is little comfort since we're looking to get
CONFIG_ZONE_DEVICEenabled by default in major distros. If that's the case I'm wiling to entertain the coarse pinning route. We can always circle back for the finer grained option if a problem arises, but let me know ifCONFIG_ZONE_DEVICE=nwas all you were looking for...
I chatted with Dave Hansen a bit and we're thinking that just moving the zone_device count updates out of line and marking the branch unlikely should address this concern.
In fact my initial numbers are showing that moving the call to "percpu_ref_get(page->pgmap->ref)" out of line saves nearly 24K of text!
If that's not enough there's always jump labels, but that's likely to show diminishing returns compared to the size reduction of moving the percpu_refcount update out of line.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 24/25 dax: provide diagnostics for pmd mapping failures
In reply to Dan WilliamsThere is a wide gamut of conditions that can trigger the dax pmd path to fallback to pte mappings. Ideally we'd have a syscall interface to determine mapping characteristics after the fact. In the meantime provide debug messages.
--- fs/dax.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 9 deletions(-)
fs/dax.c +48 -9
@@ -557,6 +557,14 @@ EXPORT_SYMBOL_GPL(dax_fault);*/ #define PG_PMD_COLOUR ((PMD_SIZE >> PAGE_SHIFT) - 1) +static void dax_pmd_dbg (struct block_device *bdev,unsigned long address, +const char *reason) +{ +pr_debug ("%s%s dax_pmd: %s addr: %lx fallback: %s\n" , bdev + ?dev_name (part_to_dev (bdev->bd_part)) :"" , bdev + ?": " :"" , current->comm, address, reason); +} +int __dax_pmd_fault (struct vm_area_struct *vma,unsigned long address,pmd_t *pmd,unsigned int flags,get_block_t get_block,dax_iodone_t complete_unwritten)
@@ -568,7 +576,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,unsigned blkbits = inode->i_blkbits;unsigned long pmd_addr = address &PMD_MASK ;bool write = flags &FAULT_FLAG_WRITE ; -struct block_device *bdev; +struct block_device *bdev =NULL ;pgoff_t size, pgoff;sector_t block;int result =0 ;
@@ -580,21 +588,29 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,/* Fall back to PTEs if we're going to COW */ if (write && !(vma->vm_flags &VM_SHARED )) {split_huge_pmd (vma, pmd, address); +dax_pmd_dbg (bdev, address,"cow write" );return VM_FAULT_FALLBACK ; }/* If the PMD would extend outside the VMA */ -if (pmd_addr < vma->vm_start) +if (pmd_addr < vma->vm_start) { +dax_pmd_dbg (bdev, address,"vma start unaligned" );return VM_FAULT_FALLBACK ; -if ((pmd_addr +PMD_SIZE ) > vma->vm_end) + } +if ((pmd_addr +PMD_SIZE ) > vma->vm_end) { +dax_pmd_dbg (bdev, address,"vma end unaligned" );return VM_FAULT_FALLBACK ; + } pgoff =linear_page_index (vma, pmd_addr); size = (i_size_read (inode) +PAGE_SIZE -1 ) >>PAGE_SHIFT ;if (pgoff >= size)return VM_FAULT_SIGBUS ;/* If the PMD would cover blocks out of the file */ -if ((pgoff |PG_PMD_COLOUR ) >= size) +if ((pgoff |PG_PMD_COLOUR ) >= size) { +dax_pmd_dbg (bdev, address, +"offset + huge page size > file size" );return VM_FAULT_FALLBACK ; + }memset (&bh,0 ,sizeof (bh)); block = (sector_t )pgoff << (PAGE_SHIFT - blkbits);
@@ -610,8 +626,10 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,* just fall back to PTEs. Calling get_block 512 times in a loop * would be silly. */ -if (!buffer_size_valid (&bh) || bh.b_size <PMD_SIZE ) +if (!buffer_size_valid (&bh) || bh.b_size <PMD_SIZE ) { +dax_pmd_dbg (bdev, address,"block allocation size invalid" ); goto fallback; + }/* * If we allocated new storage, make sure no process has any
@@ -634,23 +652,33 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, result =VM_FAULT_SIGBUS ; goto out; } -if ((pgoff |PG_PMD_COLOUR ) >= size) +if ((pgoff |PG_PMD_COLOUR ) >= size) { +dax_pmd_dbg (bdev, address,"pgoff unaligned" ); goto fallback; + }if (!write && !buffer_mapped (&bh) &&buffer_uptodate (&bh)) {spinlock_t *ptl;pmd_t entry;struct page *zero_page =get_huge_zero_page (); -if (unlikely (!zero_page)) +if (unlikely (!zero_page)) { +dax_pmd_dbg (bdev, address,"no zero page" ); goto fallback; + } ptl =pmd_lock (vma->vm_mm, pmd);if (!pmd_none (*pmd)) {spin_unlock (ptl); +dax_pmd_dbg (bdev, address,"pmd already present" ); goto fallback; } +dev_dbg (part_to_dev (bdev->bd_part), +"%s: %s addr: %lx pfn: <zero> sect: %llx\n" , + __func__, current->comm, address, + (unsigned long long )to_sector (&bh, inode)); + entry =mk_pmd (zero_page, vma->vm_page_prot); entry =pmd_mkhuge (entry);set_pmd_at (vma->vm_mm, pmd_addr, pmd, entry);
@@ -667,8 +695,13 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, result =VM_FAULT_SIGBUS ; goto out; } -if (length <PMD_SIZE - || (pfn_t_to_pfn (dax.pfn) &PG_PMD_COLOUR )) { +if (length <PMD_SIZE ) { +dax_pmd_dbg (bdev, address,"dax-length too small" ); +dax_unmap_atomic (bdev, &dax); + goto fallback; + } +if (pfn_t_to_pfn (dax.pfn) &PG_PMD_COLOUR ) { +dax_pmd_dbg (bdev, address,"pfn unaligned" );dax_unmap_atomic (bdev, &dax); goto fallback; }
@@ -679,6 +712,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,*/ if (pfn_t_has_page (dax.pfn)) {dax_unmap_atomic (bdev, &dax); +dax_pmd_dbg (bdev, address,"pfn not in memmap" ); goto fallback; }
@@ -691,6 +725,11 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, }dax_unmap_atomic (bdev, &dax); +dev_dbg (part_to_dev (bdev->bd_part), +"%s: %s addr: %lx pfn: %lx sect: %llx\n" , + __func__, current->comm, address, +pfn_t_to_pfn (dax.pfn), + (unsigned long long ) dax.sector); result |=vmf_insert_pfn_pmd (vma, address, pmd, dax.pfn, write); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 25/25 dax: re-enable dax pmd mappings
In reply to Dan WilliamsNow that the get_user_pages() path knows how to handle dax-pmd mappings, remove the protections that disabled dax-pmd support.
Tests available from github.com/pmem/ndctl:
make TESTS="lib/test-dax.sh lib/test-mmap.sh" check
--- fs/Kconfig | 3 ++- fs/dax.c | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-)
fs/Kconfig +2 -1
@@ -50,7 +50,8 @@ config FS_DAX_PMD bool default FS_DAX depends on FS_DAX - depends on BROKEN + depends on ZONE_DEVICE + depends on TRANSPARENT_HUGEPAGE endif # BLOCK
fs/dax.c +2 -6
@@ -581,7 +581,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,sector_t block;int result =0 ; -/* dax pmd mappings are broken wrt gup and fork */ +/* dax pmd mappings require pfn_t_devmap() */ if (!IS_ENABLED (CONFIG_FS_DAX_PMD ))return VM_FAULT_FALLBACK ;
@@ -706,11 +706,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, goto fallback; } -/* -* TODO: teach vmf_insert_pfn_pmd() to support -* 'pte_special' for pmds -*/ -if (pfn_t_has_page (dax.pfn)) { +if (!pfn_t_devmap (dax.pfn)) {dax_unmap_atomic (bdev, &dax);dax_pmd_dbg (bdev, address,"pfn not in memmap" ); goto fallback;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Dan Williams
Summary:
To date, we have implemented two I/O usage models for persistent memory, PMEM (a persistent "ram disk") and DAX (mmap persistent memory into userspace). This series adds a third, DAX-GUP, that allows DAX mappings to be the target of direct-i/o. It allows userspace to coordinate DMA/RDMA from/to persistent memory.
Quoted 6 lines
The implementation leverages the
ZONE_DEVICEmm-zone that went into 4.3-rc1 (also discussed at kernel summit) to flag pages that are owned and dynamically mapped by a device driver. The pmem driver, after mapping a persistent memory range into the system memmap viadevm_memremap_pages(), arranges for DAX to distinguish pfn-only versus page-backed pmem-pfns via flags in the newpfn_ttype.
So, this basically means that an admin has to decide whether or not DMA will be used on a given device before making a file system on it. That seems like an odd requirement. There's also a configuration option of whether to put those backing struct pages into DRAM or PMEM (which, of course, will be dictated by the size of pmem). I really think we should reconsider this approach.
First, the admin shouldn't have to choose whether or not DMA will be done on the file system. Second, eating up storage space to track mostly unused struct pages seems like a waste. Is there no future for the "introduce __pfn_t, evacuate struct page from sgls"[1] approach? And if not, is there some other way we can solve this problem? I know dynamic allocation of struct pages is scary, but is it more tractable than no pages for DMA?
Cheers,
Jeff
[1] https://lwn.net/Articles/647404/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 24 lines · Jeff Moyer
Quoted 8 lines · Dan Williams
Summary:
To date, we have implemented two I/O usage models for persistent memory, PMEM (a persistent "ram disk") and DAX (mmap persistent memory into userspace). This series adds a third, DAX-GUP, that allows DAX mappings to be the target of direct-i/o. It allows userspace to coordinate DMA/RDMA from/to persistent memory.
Quoted 6 lines
The implementation leverages the
ZONE_DEVICEmm-zone that went into 4.3-rc1 (also discussed at kernel summit) to flag pages that are owned and dynamically mapped by a device driver. The pmem driver, after mapping a persistent memory range into the system memmap viadevm_memremap_pages(), arranges for DAX to distinguish pfn-only versus page-backed pmem-pfns via flags in the newpfn_ttype.So, this basically means that an admin has to decide whether or not DMA will be used on a given device before making a file system on it. That seems like an odd requirement. There's also a configuration option of whether to put those backing struct pages into DRAM or PMEM (which, of course, will be dictated by the size of pmem). I really think we should reconsider this approach.
Quoted 2 lines
First, the admin shouldn't have to choose whether or not DMA will be done on the file system.
To be clear it's not "whether or not DMA will be done on the file system", it's whether or not both DMA and DAX will be done simultaneously on the filesystem.
DAX is already a capability that an admin can inadvertently disable by mis-configuring the alignment of a partition [1]. Why not also disable it when DMA support is not configured and force the fs back to page-cache? Namespace creation tooling in userspace can default to enabling DAX + DMA.
Quoted 4 lines
Second, eating up storage space to track
mostly unused struct pages seems like a waste. Is there no future for the "introduce__pfn_t, evacuate struct page from sgls"[1] approach? And if not, is there some other way we can solve this problem?
I'm still very much interested in revisiting the page-less mechanisms over time, but given comments like Dave's [2], it's not on any short term horizon.
Quoted 2 lines
I know dynamic allocation of struct pages is scary, but is it more tractable than no pages for DMA?
I wasn't convinced that it would be any better given the need to allocate at section granularity at fault time. It would still require ZONE_DEVICE or something similar. Waiting until get_user_pages() time to allocate pages means we don't get __get_user_pages_fast support. It also was not clear to that it would prevent exhaustion of DRAM for long-standing / large mappings.
[1]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=f0b2e563bc41
[2]: https://lists.01.org/pipermail/linux-nvdimm/2015-August/001853.html
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 25 lines · Dan Williams
Quoted 24 lines · Jeff Moyer
Quoted 8 lines · Dan Williams
Summary:
To date, we have implemented two I/O usage models for persistent memory, PMEM (a persistent "ram disk") and DAX (mmap persistent memory into userspace). This series adds a third, DAX-GUP, that allows DAX mappings to be the target of direct-i/o. It allows userspace to coordinate DMA/RDMA from/to persistent memory.
Quoted 6 lines
The implementation leverages the
ZONE_DEVICEmm-zone that went into 4.3-rc1 (also discussed at kernel summit) to flag pages that are owned and dynamically mapped by a device driver. The pmem driver, after mapping a persistent memory range into the system memmap viadevm_memremap_pages(), arranges for DAX to distinguish pfn-only versus page-backed pmem-pfns via flags in the newpfn_ttype.So, this basically means that an admin has to decide whether or not DMA will be used on a given device before making a file system on it. That seems like an odd requirement. There's also a configuration option of whether to put those backing struct pages into DRAM or PMEM (which, of course, will be dictated by the size of pmem). I really think we should reconsider this approach.
Quoted 6 lines
Quoted 2 lines
First, the admin shouldn't have to choose whether or not DMA will be done on the file system.
To be clear it's not "whether or not DMA will be done on the file system", it's whether or not both DMA and DAX will be done simultaneously on the filesystem.
Fair point, but I'd view one of those configurations as not recommended. To be clear, if you're just going to use the device for block based access, using btt is the safer option.
Quoted 2 lines
DAX is already a capability that an admin can inadvertently disable by mis-configuring the alignment of a partition [1].
Heh, using my own commit against me? ;-) Anyway, the commit message suggests that dax *could* be supported on misaligned partitions.
Quoted 3 lines
Why not also disable it when DMA support is not configured and force the fs back to page-cache? Namespace creation tooling in userspace can default to enabling DAX + DMA.
Well, the only reason I can come up with is manufactured: we've forced the admin to decide between having that extra space for storage and doing DMA, and he or she opted for more space.
Quoted 8 lines
Quoted 4 lines
Second, eating up storage space to track
mostly unused struct pages seems like a waste. Is there no future for the "introduce__pfn_t, evacuate struct page from sgls"[1] approach? And if not, is there some other way we can solve this problem?I'm still very much interested in revisiting the page-less mechanisms over time, but given comments like Dave's [2], it's not on any short term horizon.
OK.
Quoted 9 lines
Quoted 2 lines
I know dynamic allocation of struct pages is scary, but is it more tractable than no pages for DMA?
I wasn't convinced that it would be any better given the need to allocate at section granularity at fault time. It would still require
ZONE_DEVICEor something similar. Waiting untilget_user_pages()time to allocate pages means we don't get__get_user_pages_fastsupport. It also was not clear to that it would prevent exhaustion of DRAM for long-standing / large mappings.
Hmm, yeah, this does seem like a less attractive approach. Thanks for enumerating the issues.
-Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 30 lines · Jeff Moyer
Quoted 28 lines · Dan Williams
Quoted 26 lines · Jeff Moyer
Quoted 8 lines · Dan Williams
Summary:
To date, we have implemented two I/O usage models for persistent memory, PMEM (a persistent "ram disk") and DAX (mmap persistent memory into userspace). This series adds a third, DAX-GUP, that allows DAX mappings to be the target of direct-i/o. It allows userspace to coordinate DMA/RDMA from/to persistent memory.
Quoted 6 lines
The implementation leverages the
ZONE_DEVICEmm-zone that went into 4.3-rc1 (also discussed at kernel summit) to flag pages that are owned and dynamically mapped by a device driver. The pmem driver, after mapping a persistent memory range into the system memmap viadevm_memremap_pages(), arranges for DAX to distinguish pfn-only versus page-backed pmem-pfns via flags in the newpfn_ttype.So, this basically means that an admin has to decide whether or not DMA will be used on a given device before making a file system on it. That seems like an odd requirement. There's also a configuration option of whether to put those backing struct pages into DRAM or PMEM (which, of course, will be dictated by the size of pmem). I really think we should reconsider this approach.
First, the admin shouldn't have to choose whether or not DMA will be done on the file system.
Quoted 7 lines
Quoted 3 lines
To be clear it's not "whether or not DMA will be done on the file system", it's whether or not both DMA and DAX will be done simultaneously on the filesystem.
Fair point, but I'd view one of those configurations as not recommended. To be clear, if you're just going to use the device for block based access, using btt is the safer option.
Speaking of btt, the mechanism for setting up a btt is identical to specifying a reserved area for the memmap. I.e. write an info block to the namespace to specify a new mode of operation.
Quoted 5 lines
Quoted 2 lines
DAX is already a capability that an admin can inadvertently disable by mis-configuring the alignment of a partition [1].
Heh, using my own commit against me? ;-) Anyway, the commit message suggests that dax *could* be supported on misaligned partitions.
All's fair in love, war, and code defense. :-)
Quoted 7 lines
Quoted 3 lines
Why not also disable it when DMA support is not configured and force the fs back to page-cache? Namespace creation tooling in userspace can default to enabling DAX + DMA.
Well, the only reason I can come up with is manufactured: we've forced the admin to decide between having that extra space for storage and doing DMA, and he or she opted for more space.
Is this any worse than the "forcing" we're imposing in the btt / no-btt decision that impacts DAX? This additional configuration flexibility for whether / where to store a memmap array is merely incremental, not fatal. It's also a configuration decision we can stop asking an admin to make when / if we ever re-write the kernel to reduce its dependency on struct page.
In the meantime, I expect some would say DAX is a toy as long as it continues to fail at DMA.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Dan Williams
In the meantime, I expect some would say DAX is a toy as long as it continues to fail at DMA.
I suppose this is the crux of it. Given that we may be able to migrate away from the allocation of storage for temporary data structures in the future, and given that admin tooling could hide the undesirable configurations, this approach seems workable.
Thanks,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Jeff Moyer
Quoted 2 lines · Dan Williams
In the meantime, I expect some would say DAX is a toy as long as it continues to fail at DMA.
I suppose this is the crux of it. Given that we may be able to migrate away from the allocation of storage for temporary data structures in the future, and given that admin tooling could hide the undesirable configurations, this approach seems workable.
Here's my current thoughts on the tooling for namespace creation:
ndctl create-namespace
That command by default will create a maximally sized pmem namespace and set up the struct page memmap by default i.e. it defaults to the following parameters:
ndctl create-namespace --type=pmem --mode=memory
The other options for 'mode' are 'safe' and 'raw' where 'safe' establishes a btt, and 'raw' exposes the full un-decorated capacity of the namespace.
If you have a pre-existing 'raw' mode pmem namespace, you can convert it to be enabled for dma, and other capabilities typical memory possesses, with the following:
ndctl create-namespace --mode=memory -r namespace0.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 15 lines · Dan Williams
Changes since v1: [1]
1/ Rebase on latest -next (20151209). Fixed up
PHYSICAL_PAGE_MASK, but
no other major collisions.2/ Decreased the transfer size in "dax: increase granularity of
dax_clear_blocks()operations" to get the max latency to reschedule under 1ms and average latency under 150us. (Andrew)3/ Add cc's for x86 maintainers
4/ Add Tested-by: Logan Gunthorpe
This update, as before, passes the ndctl [2] and nvml [3] test suites.
Quoted 8 lines
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-December/003213.html
[2]: https://github.com/pmem/ndctl
[3]: https://github.com/pmem/nvmlA git tree of this set is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimmlibnvdimm-pending
Andrew,
I went ahead and rebased the tree on next-20151211, and refreshed 3 patches with the following changes (sent as replies to avoid spamming folks with the other 22 patches that did not change):
[-mm PATCH v3 04/25] dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()
Updated to the new definition of blk_queue_enter() from commit 6f3b0e8bcf3c "blk-mq: add a flags parameter to blk_mq_alloc_request"
[-mm PATCH v3 09/25] mm, dax, pmem: introduce pfn_t
Moved phys_to_pfn_t() out of line to enable some new unit tests.
[-mm PATCH v3 10/25] mm: introduce find_dev_pagemap()
Just a reflow to pick up the context differences from the changes in [-mm PATCH v3 09/25].
These updates (plus next-20151211) continue to pass all my tests and have been pushed out to the 'libnvdimm-pending' branch.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 43 lines · Dan Williams
Quoted 15 lines · Dan Williams
Changes since v1: [1]
1/ Rebase on latest -next (20151209). Fixed up
PHYSICAL_PAGE_MASK, but
no other major collisions.2/ Decreased the transfer size in "dax: increase granularity of
dax_clear_blocks()operations" to get the max latency to reschedule under 1ms and average latency under 150us. (Andrew)3/ Add cc's for x86 maintainers
4/ Add Tested-by: Logan Gunthorpe
This update, as before, passes the ndctl [2] and nvml [3] test suites.
Quoted 8 lines
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-December/003213.html
[2]: https://github.com/pmem/ndctl
[3]: https://github.com/pmem/nvmlA git tree of this set is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimmlibnvdimm-pendingAndrew,
I went ahead and rebased the tree on next-20151211, and refreshed 3 patches with the following changes (sent as replies to avoid spamming folks with the other 22 patches that did not change):
[-mm PATCH v3 04/25] dax: fix lifetime of in-kernel dax mappings with
dax_map_atomic()Updated to the new definition of
blk_queue_enter()from commit6f3b0e8bcf3c"blk-mq: add a flags parameter toblk_mq_alloc_request"[-mm PATCH v3 09/25] mm, dax, pmem: introduce
pfn_tMoved
phys_to_pfn_t()out of line to enable some new unit tests.
Quoted 7 lines
[-mm PATCH v3 10/25] mm: introduce
find_dev_pagemap()Just a reflow to pick up the context differences from the changes in [-mm PATCH v3 09/25].
These updates (plus next-20151211) continue to pass all my tests and have been pushed out to the 'libnvdimm-pending' branch.
The set continues to re-apply and re-test cleanly on top of next-20151214.
I have patches and documentation updates queued up for the 'ndctl' utility to address Jeff's concern about the administrative interface.
Any other blocking concerns?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>