Skip to content

mm/autonuma: replace savedwrite infrastructure

David Hildenbrand linux-mm linuxppc-dev lkml 2 versions – Applied

Status from this message: [merged mm-stable] selftests-vm-anon_cow-add-mprotect-optimization-tests.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 0 repliesApplied 7/7
  2. v16 patches 3 repliesSuperseded

Changes in v2 from the cover letter

* "mm/mprotect: factor out check whether manual PTE write upgrades are required"
-> Added
* "mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwrite" -> Simplify and don't opimize for failed migration
-> Update patch description

Patches in v2 All 7 applied

#Subject and filesSizeRepliesApplied
1/7mm/mprotect: allow clean exclusive anon pages to be writablemm/mprotect.c+3 -40 repliesApplied
2/7mm/mprotect: minor can_change_pte_writable() cleanupsmm/mprotect.c+14 -50 repliesApplied
3/7mm/huge_memory: try avoiding write faults when changing PMD protectionmm/huge_memory.c+36 -20 repliesApplied
4/7mm/mprotect: factor out check whether manual PTE write upgrades are requiredinclude/linux/mm.h mm/mprotect.c+18 -150 repliesApplied
5/7mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwriteinclude/linux/mm.h mm/huge_memory.c mm/ksm.c +2 more+36 -240 repliesApplied
6/7mm: remove unused savedwrite infrastructurearch/powerpc/include/asm/book3s/64/pgtable.h arch/powerpc/kvm/book3s_hv_rm_mmu.c include/linux/pgtable.h +1 more+5 -1330 repliesApplied
7/7selftests/vm: anon_cow: add mprotect() optimization teststools/testing/selftests/vm/anon_cow.c+46 -30 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] mm/autonuma: replace savedwrite infrastructure

This series is based on mm-unstable.

As discussed in my talk at LPC, we can reuse the same mechanism for deciding whether to map a pte writable when upgrading permissions via mprotect() -- e.g., PROT_READ -> PROT_READ|PROT_WRITE -- to replace the savedwrite infrastructure used for NUMA hinting faults (e.g., PROT_NONE -> PROT_READ|PROT_WRITE).

Instead of maintaining previous write permissions for a pte/pmd, we re-determine if the pte/pmd can be writable. The big benefit is that we have a common logic for deciding whether we can map a pte/pmd writable on protection changes.

For private mappings, there should be no difference -- from what I understand, that is what autonuma benchmarks care about.

I ran autonumabench for v1 on a system with 2 NUMA nodes, 96 GiB each via:

	perf stat --null --repeat 10

The numa01 benchmark is quite noisy in my environment and I failed to reduce the noise so far.

numa01:

	mm-unstable:   146.88 +- 6.54 seconds time elapsed  ( +-  4.45% )
	mm-unstable++: 147.45 +- 13.39 seconds time elapsed  ( +-  9.08% )

numa02:

	mm-unstable:   16.0300 +- 0.0624 seconds time elapsed  ( +-  0.39% )
	mm-unstable++: 16.1281 +- 0.0945 seconds time elapsed  ( +-  0.59% )

It is worth noting that for shared writable mappings that require writenotify, we will only avoid write faults if the pte/pmd is dirty (inherited from the older mprotect logic). If we ever care about optimizing that further, we'd need a different mechanism to identify whether the FS still needs to get notified on the next write access.

In any case, such an optimiztion will then not be autonuma-specific, but mprotect() permission upgrades would similarly benefit from it.

Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Dave Chinner <[email protected]>
Cc Nadav Amit <[email protected]>
Cc Peter Xu <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Anshuman Khandual <[email protected]>

v1 -> v2:
* "mm/mprotect: factor out check whether manual PTE write upgrades are required"
-> Added
* "mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwrite" -> Simplify and don't opimize for failed migration
-> Update patch description

RFC -> v1:
* "mm/mprotect: allow clean exclusive anon pages to be writable" -> Move comment change to patch #2
* "mm/mprotect: minor can_change_pte_writable() cleanups"
-> Adjust comments
* "mm/huge_memory: try avoiding write faults when changing PMD protection" -> Fix wrong check
* "selftests/vm: anon_cow: add mprotect() optimiation tests" -> Add basic tests for the mprotect() optimization

David Hildenbrand (6):
mm/mprotect: minor can_change_pte_writable() cleanups mm/huge_memory: try avoiding write faults when changing PMD protection mm/mprotect: factor out check whether manual PTE write upgrades are
required
mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwrite
mm: remove unused savedwrite infrastructure
selftests/vm: anon_cow: add mprotect() optimization tests

Nadav Amit (1):
mm/mprotect: allow clean exclusive anon pages to be writable

 arch/powerpc/include/asm/book3s/64/pgtable.h | 80 +-------------------
 arch/powerpc/kvm/book3s_hv_rm_mmu.c          |  2 +-
 include/linux/mm.h                           | 18 ++++-
 include/linux/pgtable.h                      | 24 ------
 mm/debug_vm_pgtable.c                        | 32 --------
 mm/huge_memory.c                             | 64 ++++++++++++----
 mm/ksm.c                                     |  9 +--
 mm/memory.c                                  | 16 +++-
 mm/mprotect.c                                | 50 ++++++------
 tools/testing/selftests/vm/anon_cow.c        | 49 +++++++++++-
 10 files changed, 158 insertions(+), 186 deletions(-)
Signature · 1 line
2.38.1