[RFC,2/2] dax: Support MAP_PMEM_AWARE mmap flag
diff mbox

Message ID 56C9EE87.2080106@plexistor.com
State New, archived
Headers show

Commit Message

Boaz Harrosh Feb. 21, 2016, 5:06 p.m. UTC
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@intel.com>
CC: Ross Zwisler <ross.zwisler@linux.intel.com>
CC: Matthew Wilcox <willy@linux.intel.com>
CC: linux-nvdimm <linux-nvdimm@ml01.01.org>
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 fs/dax.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Patch
diff mbox

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);