Skip to content

dax, ext4, xfs: Synchronous page faults

Jan Kara linux-api linux-ext4 linux-fsdevel linux-mm linux-nvdimm linux-parisc linux-xfs nvdimm 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest18 patches 7 repliesIn review
  2. v517 patches 11 repliesSuperseded
  3. v417 patches 4 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v319 patches38 repliesSuperseded
v2 RFC13 patches38 repliesSuperseded
v1 RFC7 patches33 repliesSuperseded

Changes in v6 from the cover letter

* really updated the manpage
* improved comment describing IOMAP_F_DIRTY
* fixed XFS handling of VM_FAULT_NEEDSYNC in xfs_filemap_pfn_mkwrite()

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flagsarch/alpha/include/uapi/asm/mman.h arch/mips/include/uapi/asm/mman.h arch/parisc/include/uapi/asm/mman.h +6 more+61 -05 replies
2/18mm: Remove VM_FAULT_HWPOISON_LARGE_MASKinclude/linux/mm.h+0 -20 replies
3/18dax: Simplify arguments of dax_insert_mapping()fs/dax.c+16 -160 replies
4/18dax: Factor out getting of pfn out of iomapfs/dax.c+43 -400 replies
5/18dax: Create local variable for VMA in dax_iomap_pte_fault()fs/dax.c+3 -20 replies
6/18dax: Create local variable for vmf->flags & FAULT_FLAG_WRITE testfs/dax.c+3 -20 replies
7/18dax: Inline dax_insert_mapping() into the callsitefs/dax.c+19 -270 replies
8/18dax: Inline dax_pmd_insert_mapping() into the callsitefs/dax.c include/trace/events/fs_dax.h+19 -290 replies
9/18dax: Fix comment describing dax_iomap_fault()fs/dax.c+2 -10 replies
10/18dax: Allow dax_iomap_fault() to return pfnfs/dax.c fs/ext2/file.c fs/ext4/file.c +2 more+12 -110 replies
11/18dax: Allow tuning whether dax_insert_mapping_entry() dirties entryfs/dax.c+7 -70 replies
12/18mm: Define MAP_SYNC and VM_SYNC flagsfs/proc/task_mmu.c include/linux/mm.h include/linux/mman.h +1 more+9 -20 replies
13/18dax, iomap: Add support for synchronous faultsfs/dax.c include/linux/iomap.h include/linux/mm.h+47 -30 replies
14/18dax: Implement dax_finish_sync_fault()fs/dax.c include/linux/dax.h include/trace/events/fs_dax.h+87 -00 replies
15/18ext4: Simplify error handling in ext4_dax_huge_fault()fs/ext4/file.c+7 -60 replies
16/18ext4: Support for synchronous DAX faultsfs/ext4/file.c fs/ext4/inode.c fs/jbd2/journal.c +1 more+47 -10 replies
17/18xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()fs/xfs/xfs_file.c fs/xfs/xfs_trace.h+4 -271 reply
18/18xfs: support for synchronous DAX faultsfs/xfs/xfs_file.c fs/xfs/xfs_iomap.c+19 -11 reply

Reviews trailers per patch

All 18 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchChristoph HellwigRoss ZwislerDarrick J. Wong
SeriesR-b
1/18R-b
2/18R-b R-b
3/18R-b R-b
4/18R-b R-b
5/18R-b R-b
6/18R-b R-b
7/18R-b R-b
8/18R-b R-b
9/18R-b R-b
10/18R-b R-b
11/18R-b R-b
12/18R-b R-b
13/18R-b R-b
14/18R-b R-b
15/18R-b
16/18R-b
17/18R-b
18/18R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH 0/18 v6] dax, ext4, xfs: Synchronous page faults

Hello,

here is the sixth version of my patches to implement synchronous page faults for DAX mappings to make flushing of DAX mappings possible from userspace so that they can be flushed on finer than page granularity and also avoid the overhead of a syscall.

I think we are ready to get this merged - I've talked to Dan and he said he could take the patches through his tree. It would just be nice to get final ack from Christoph for the first patch implementing MAP_VALIDATE and someone from XFS folks to check patch 17 (make xfs_filemap_pfn_mkwrite use __xfs_filemap_fault()).

---

We use a new mmap flag MAP_SYNC to indicate that page faults for the mapping should be synchronous. The guarantee provided by this flag is: While a block is writeably mapped into page tables of this mapping, it is guaranteed to be visible in the file at that offset also after a crash.

How I implement this is that ->iomap_begin() indicates by a flag that inode block mapping metadata is unstable and may need flushing (use the same test as whether fdatasync() has metadata to write). If yes, DAX fault handler refrains from inserting / write-enabling the page table entry and returns special flag VM_FAULT_NEEDDSYNC together with a PFN to map to the filesystem fault handler. The handler then calls fdatasync() (vfs_fsync_range()) for the affected range and after that calls DAX code to update the page table entry appropriately.

I did some basic performance testing on the patches over ramdisk - timed latency of page faults when faulting 512 pages. I did several tests: with file preallocated / with file empty, with background file copying going on / without it, with / without MAP_SYNC (so that we get comparison). The results are (numbers are in microseconds):

File preallocated, no background load no MAP_SYNC:
min=9 avg=10 max=46
8 - 15 us: 508
16 - 31 us: 3
32 - 63 us: 1

File preallocated, no background load, MAP_SYNC:
min=9 avg=10 max=47
8 - 15 us: 508
16 - 31 us: 2
32 - 63 us: 2

File empty, no background load, no MAP_SYNC:
min=21 avg=22 max=70
16 - 31 us: 506
32 - 63 us: 5
64 - 127 us: 1

File empty, no background load, MAP_SYNC:
min=40 avg=124 max=242
32 - 63 us: 1
64 - 127 us: 333
128 - 255 us: 178

File empty, background load, no MAP_SYNC:
min=21 avg=23 max=67
16 - 31 us: 507
32 - 63 us: 4
64 - 127 us: 1

File empty, background load, MAP_SYNC:
min=94 avg=112 max=181
64 - 127 us: 489
128 - 255 us: 23

So here we can see the difference between MAP_SYNC vs non MAP_SYNC is about 100-200 us when we need to wait for transaction commit in this setup.

Changes since v5:
* really updated the manpage
* improved comment describing IOMAP_F_DIRTY
* fixed XFS handling of VM_FAULT_NEEDSYNC in xfs_filemap_pfn_mkwrite()

Changes since v4:
* fixed couple of minor things in the manpage
* make legacy mmap flags always supported, remove them from mask declared to be supported by ext4 and xfs

Changes since v3:
* updated some changelogs
* folded fs support for VM_SYNC flag into patches implementing the functionality
* removed ->mmap_validate, use ->mmap_supported_flags instead
* added some Reviewed-by tags
* added manpage patch

Changes since v2:
* avoid unnecessary flushing of faulted page (Ross) - I've realized it makes no sense to remeasure my benchmark results (after actually doing that and seeing no difference, sigh) since I use ramdisk and not real PMEM HW and so flushes are ignored.
* handle nojournal mode of ext4
* other smaller cleanups & fixes (Ross)
* factor larger part of finishing of synchronous fault into a helper (Christoph)
* reorder pfnp argument of dax_iomap_fault() (Christoph)
* add XFS support from Christoph
* use proper MAP_SYNC support in mmap(2)
* rebased on top of 4.14-rc4

Changes since v1:
* switched to using mmap flag MAP_SYNC
* cleaned up fault handlers to avoid passing pfn in vmf->orig_pte
* switched to not touching page tables before we are ready to insert final entry as it was unnecessary and not really simplifying anything
* renamed fault flag to VM_FAULT_NEEDDSYNC
* other smaller fixes found by reviewers

Honza
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm