Skip to content

dax: Clear dirty bits after flushing caches

Jan Kara linux-fsdevel linux-mm linux-nvdimm nvdimm 6 versions – Applied

Status from this message: [merged] dax-clear-dirty-entry-tags-on-cache-flush.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest20 patches 4 repliesApplied 20/20
  2. v4 posting 2/221 patches 34 repliesSuperseded
  3. v4 posting 1/221 patches 10 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v320 patches50 repliesSuperseded
v215 patches2 repliesSuperseded
v13 patches8 repliesSuperseded

Changes in v5 from the cover letter

* added acks and reviewed by's
* dropped cleanup patch to remove vma->vm_ops check
* make sure we restore original vmf->flags after using vm_fault structure for page_mkwrite handler
* mask vmf->address by PAGE_MASK in generic mm code rather than in ->fault handlers
* fixed up error handling dax_load_hole()

Patches in v5 All 20 applied

#Subject and filesSizeRepliesApplied
1/20mm: Join struct fault_env and vm_faultDocumentation/filesystems/Locking fs/userfaultfd.c include/linux/huge_mm.h +8 more+414 -4121 replyApplied
2/20mm: Use vmf->address instead of of vmf->virtual_addressarch/powerpc/platforms/cell/spufs/file.c arch/x86/entry/vdso/vma.c drivers/char/agp/alpha-agp.c +24 more+57 -791 replyApplied
3/20mm: Use pgoff in struct vm_fault instead of passing it separatelymm/khugepaged.c mm/memory.c+19 -170 repliesApplied
4/20mm: Use passed vm_fault structure in __do_fault()mm/memory.c+10 -150 repliesApplied
5/20mm: Trim __do_fault() argumentsmm/memory.c+29 -380 repliesApplied
6/20mm: Use passed vm_fault structure for in wp_pfn_shared()mm/memory.c+2 -70 repliesApplied
7/20mm: Add orig_pte field into vm_faultinclude/linux/mm.h mm/internal.h mm/khugepaged.c +1 more+47 -480 repliesApplied
8/20mm: Allow full handling of COW faults in ->fault handlersinclude/linux/mm.h mm/memory.c+10 -80 repliesApplied
9/20mm: Factor out functionality to finish page faultsinclude/linux/mm.h mm/memory.c+36 -90 repliesApplied
10/20mm: Move handling of COW faults into DAX codefs/dax.c include/linux/dax.h include/linux/mm.h +1 more+34 -561 replyApplied
11/20mm: Factor out common parts of write fault handlingmm/memory.c+37 -410 repliesApplied
12/20mm: Pass vm_fault structure into do_page_mkwrite()mm/memory.c+10 -121 replyApplied
13/20mm: Use vmf->page during WP faultsmm/memory.c+29 -290 repliesApplied
14/20mm: Move part of wp_page_reuse() into the single call sitemm/memory.c+12 -150 repliesApplied
15/20mm: Provide helper for finishing mkwrite faultsinclude/linux/mm.h mm/memory.c+41 -270 repliesApplied
16/20mm: Change return values of finish_mkwrite_fault()mm/memory.c+3 -40 repliesApplied
17/20mm: Export follow_pte()include/linux/mm.h mm/memory.c+4 -20 repliesApplied
18/20dax: Make cache flushing protected by entry lockfs/dax.c+39 -220 repliesApplied
19/20dax: Protect PTE modification on WP fault by radix tree entry lockfs/dax.c mm/memory.c+17 -70 repliesApplied
20/20dax: Clear dirty entry tags on cache flushfs/dax.c+64 -00 repliesApplied

Reviews trailers per patch

All 20 patches have a Reviewed-by or Acked-by.

PatchKirill A. ShutemovRoss Zwisler
1/20A-b
2/20A-b
3/20A-b R-b
4/20A-b R-b
5/20A-b R-b
6/20A-b R-b
7/20A-b R-b
8/20A-b R-b
9/20A-b R-b
10/20A-b R-b
11/20A-b R-b
12/20A-b R-b
13/20A-b R-b
14/20A-b R-b
15/20A-b R-b
16/20A-b
17/20R-b
18/20R-b
19/20R-b
20/20R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH 0/20 v5] dax: Clear dirty bits after flushing caches

Hello,

This is the fifth revision of my patches to clear dirty bits from radix tree of DAX inodes when caches for corresponding pfns have been flushed. In principle, these patches enable handlers to easily update PTEs and do other work necessary to finish the fault without duplicating the functionality present in the generic code. I'd like to thank Kirill and Ross for reviews of the series! Kirill has reviewed most of patches from mm side and is fine with them - I'd just like his ack on the final version of patches 1, 2, 12 which I hope I've updated as he wished. Then I think the series can go in.

The patches are based on Ross' DAX PMD page fault series [1] currently sitting in XFS tree waiting for the merge window + ext4 conversion of DAX IO patch to the iomap infrastructure [2]. For testing, I've pushed out a tree including all these patches and further DAX fixes to:

git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git dax

The patches pass testing with xfstests on ext4 and xfs on my end. I'd be grateful for review so that we can push these patches for the next merge window.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git dax-4.10-iomap-pmd
[2] Posted an hour ago - look for "ext4: Convert ext4 DAX IO to iomap framework"

Changes since v4:
* added acks and reviewed by's
* dropped cleanup patch to remove vma->vm_ops check
* make sure we restore original vmf->flags after using vm_fault structure for page_mkwrite handler
* mask vmf->address by PAGE_MASK in generic mm code rather than in ->fault handlers
* fixed up error handling dax_load_hole()

Changes since v3:
* rebased on top of 4.9-rc1 + DAX PMD fault series + ext4 iomap conversion
* reordered some of the patches
* killed ->virtual_address field in vm_fault structure as requested by Christoph

Changes since v2:
* rebased on top of 4.8-rc8 - this involved dealing with new fault_env structure
* changed calling convention for fault helpers

Changes since v1:
* make sure all PTE updates happen under radix tree entry lock to protect against races between faults & write-protecting code
* remove information about DAX locking from mm/memory.c
* smaller updates based on Ross' feedback

----
Background information regarding the motivation:

Currently we never clear dirty bits in the radix tree of a DAX inode. Thus fsync(2) flushes all the dirty pfns again and again. This patches implement clearing of the dirty tag in the radix tree so that we issue flush only when needed.

The difficulty with clearing the dirty tag is that we have to protect against a concurrent page fault setting the dirty tag and writing new data into the page. So we need a lock serializing page fault and clearing of the dirty tag and write-protecting PTEs (so that we get another pagefault when pfn is written to again and we have to set the dirty tag again).

The effect of the patch set is easily visible:

Writing 1 GB of data via mmap, then fsync twice.

Before this patch set both fsyncs take ~205 ms on my test machine, after the patch set the first fsync takes ~283 ms (the additional cost of walking PTEs, clearing dirty bits etc. is very noticeable), the second fsync takes below 1 us.

As a bonus, these patches make filesystem freezing for DAX filesystems reliable because mappings are now properly writeprotected while freezing the fs.
Honza

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