[RFC 2/2] dax: Support MAP_PMEM_AWARE mmap flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is possible that applications like nvml is aware that
it is working with pmem, and is already doing movnt instructions
and cl_flushes to keep data persistent.

It is not enough that these applications do not call m/fsync,
in current code we already pay extra locking and resources in
the radix tree on every write page-fault even before we call
m/fsync.

Such application can do an mmap call with the new MAP_PMEM_AWARE
flag, and for these mmap pointers flushing will not be maintained.
This will not hurt any other legacy applications that do regular
mmap and memcpy for these applications even if working on the same
file, even legacy libraries in the same process space that do mmap
calls will have their pagefaults accounted for. Since this is per
vma.

CC: Dan Williams <dan.j.williams@xxxxxxxxx>
CC: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>
CC: Matthew Wilcox <willy@xxxxxxxxxxxxxxx>
CC: linux-nvdimm <linux-nvdimm@xxxxxxxxxxx>
Signed-off-by: Boaz Harrosh <boaz@xxxxxxxxxxxxx>
---
 fs/dax.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 64e3fc1..f8aec85 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -579,10 +579,12 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh,
 	}
 	dax_unmap_atomic(bdev, &dax);
 
-	error = dax_radix_entry(mapping, vmf->pgoff, dax.sector, false,
+	if (!(vma->vm_flags & VM_PMEM_AWARE)) {
+		error = dax_radix_entry(mapping, vmf->pgoff, dax.sector, false,
 			vmf->flags & FAULT_FLAG_WRITE);
-	if (error)
-		goto out;
+		if (error)
+			goto out;
+	}
 
 	error = vm_insert_mixed_rw(vma, vaddr, dax.pfn,
 				     0 != (vmf->flags & FAULT_FLAG_WRITE));
@@ -984,7 +986,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,
 		 * entry completely on the initial read and just wait until
 		 * the write to insert a dirty entry.
 		 */
-		if (write) {
+		if (write && !(vma->vm_flags & VM_PMEM_AWARE)) {
 			error = dax_radix_entry(mapping, pgoff, dax.sector,
 					true, true);
 			if (error) {
@@ -1065,7 +1067,9 @@ int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 * saves us from having to make a call to get_block() here to look
 	 * up the sector.
 	 */
-	dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false, true);
+	if (!(vma->vm_flags & VM_PMEM_AWARE))
+		dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false,
+				true);
 	return VM_FAULT_NOPAGE;
 }
 EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);
-- 
1.9.3


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]