In current code for any mmap-write access there are two page faults. One that maps the pfn into the vma (vm_insert_mixed()), and a second one that converts the read-only mapping to read-write (via pfn_mkwrite). But since we already know that this is a write access we can map the pfn read-write and save the extra fault. Signed-off-by: Boaz Harrosh <boaz@xxxxxxxxxxxxx> --- fs/dax.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index a86d3cc..3fee696 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -289,6 +289,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, sector_t sector = bh->b_blocknr << (inode->i_blkbits - 9); unsigned long vaddr = (unsigned long)vmf->virtual_address; void __pmem *addr; + pgprot_t prot = vma->vm_page_prot; unsigned long pfn; pgoff_t size; int error; @@ -321,7 +322,10 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, wmb_pmem(); } - error = vm_insert_mixed(vma, vaddr, pfn); + if (vmf->flags & FAULT_FLAG_WRITE) + prot = pgprot_modify(prot, PAGE_SHARED); + + error = vm_insert_mixed_prot(vma, vaddr, pfn, prot); out: i_mmap_unlock_read(mapping); -- 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>