s390/mm: Batch PTE updates in lazy MMU mode
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v8 Latest15 patches 4 repliesApplied
- v74 patches 19 repliesSuperseded
- v64 patches 0 repliesSuperseded
Earlier versions · 5
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v5 | 4 patches | 2 replies | Superseded | |
| v4 | 4 patches | 3 replies | Superseded | |
| v3 | 7 patches | 0 replies | Superseded | |
| v2 | 6 patches | 23 replies | Superseded | |
| v1 RFC | 2 patches | 14 replies | Superseded |
Changes in v8 from the cover letter
- CPUHP_BP_PREPARE_DYN hotplug event is used to (de-)allocate per-cpu data
- lazy_mmu_enabled static key is used to indicate the lazy mmu mode availability
- is_lazy_mmu_active() is implemented using CLIY alternative
- lazy_mmu_count lowcore variable is turned 1 byte to allow CLIY alternative
Patches in v8 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/15 | mm: introduce hw_pte_t for PTE table storageMAINTAINERS include/ mm/ | +21 | 0 replies | |
| 2/15 | mm: rename pointers to software PTE values as ptentpinclude/ mm/ mm/ | +5 | 0 replies | |
| 3/15 | mm: use hw_pte_t for generic PTE table storagefs/ fs/ include/ +53 more | +410 | 0 replies | |
| 4/15 | mm: convert PTE table entries in ptep_get()include/ include/ | +3 | 0 replies | |
| 5/15 | mm: convert PTE table entry to pteinclude/ | +2 | 0 replies | |
| 6/15 | mm: add hw_pte_val for HW PTE storageinclude/ | +4 | 0 replies | |
| 7/15 | mm/kasan: use hw_pte_t for the early shadow PTE tableinclude/ mm/ mm/ | +3 | 0 replies | |
| 8/15 | drm/i915: use hw_pte_t for PTE range callbacksdrivers/ drivers/ | +4 | 0 replies | |
| 9/15 | xen: use hw_pte_t for PTE range callbacksdrivers/ drivers/ drivers/ +1 more | +5 | 0 replies | |
| 10/15 | s390/mm: Cleanup pXXp_flush_lazy() routinesarch/ | +2 | 2 replies | |
| 11/15 | s390: Distinguish hardware and software PTEsarch/ arch/ arch/ +14 more | +112 | 1 reply | |
| 12/15 | mm: Make lazy MMU mode context-awarefs/ include/ mm/ +4 more | +60 | 0 replies | |
| 13/15 | s390/mm: Batch PTE updates in lazy MMU modearch/ arch/ arch/ +3 more | +583 | 1 reply | |
| 14/15 | mm/kasan: Introduce helpers for lazy MMU mode sanitizerinclude/ mm/ mm/ +1 more | +36 | 0 replies | |
| 15/15 | s390/mm: Lazy MMU mode sanitizerarch/ arch/ | +29 | 0 replies |
Reviews trailers per patch
5 of 15 patches have a Reviewed-by or Acked-by.
| Patch | David Hildenbrand (Arm) | Juergen Gross | Kevin Brodsky | Gerald Schaefer |
|---|---|---|---|---|
| 1/15 | A-b | |||
| 2/15 | A-b | |||
| 3/15 | ||||
| 4/15 | ||||
| 5/15 | ||||
| 6/15 | ||||
| 7/15 | ||||
| 8/15 | ||||
| 9/15 | R-b | |||
| 10/15 | R-b | |||
| 11/15 | ||||
| 12/15 | A-b | R-b | ||
| 13/15 | ||||
| 14/15 | ||||
| 15/15 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v8 00/15] s390/mm: Batch PTE updates in lazy MMU mode
Hi All,
This is v8 of the batched PTE updates in lazy MMU mode rework.
Patches 1-9 are a prerequisite series [1] backported from mm-new to master. It is only posted to facilitate the follow-up s390 lazy MMU rework review.
Patch 10 is a cleanup that could be picked independently and is a prerequisite to patch 11
Patch 11 is the s390 variant of the ARM64 series [2] and provides hw_pte_t type enablement
Patches 12,13 are the lazy MMU mode implementation and the main objective of this rework.
Patches 14,15 are an additional KASAN-based lazy-PTE guard mechanism.
1. https://lore.kernel.org/linux-mm/[email protected]/
2. https://lore.kernel.org/all/[email protected]/
Changes since v7:
- CPUHP_BP_PREPARE_DYN hotplug event is used to (de-)allocate per-cpu data
- lazy_mmu_enabled static key is used to indicate the lazy mmu mode availability
- is_lazy_mmu_active() is implemented using CLIY alternative
- lazy_mmu_count lowcore variable is turned 1 byte to allow CLIY alternative
Changes since v6:
- bottom-halves are disabled on entering and leaving the lazy mmu mode
Changes since v5:
- IPTE optimization is not applied to secure guests [4]
- __kasan_(un)poison_pte() are marked as EXPORT_SYMBOL_GPL() [5]
- PTE table poisoning is not applied to architectures with PTE entry size= s
unaligned on KASAN_GRANULE_SIZE [5]
4. https://lore.kernel.org/linux-s390/cover.1783945507.git.agordeev@linux=
.ibm.com/T/#md98724bd3b66d0a0711deb6089fa541f420566d8
5. https://lore.kernel.org/linux-s390/cover.1783945507.git.agordeev@linux=
.ibm.com/T/#m9c8b31b4863416732d0cbbc5f5f63290db4522c1
Changes since v4:
- verified that a presumable sashiko performance regression finding [2] although appears valid does not really degrade performance
- applied sashiko suggestion [3] and added "direct-pte-access" kasan bug = type
2. https://lore.kernel.org/linux-s390/20260623062703.269982B28-agordeev@l=
inux.ibm.com/#r
3. https://lore.kernel.org/linux-s390/20260623061321.269982A64-agordeev@l=
inux.ibm.com/
Changes since v3:
- all prerequisite patches are landed in -next and removed from the serie= s
Changes since v2:
- lazy_mmu_mode_enable_for_pte_range() renamed to lazy_mmu_mode_enable_wi= th_ptes()
(David Hildenbrand)
- patch "mm/pgtable: Fix bogus comment to clear_not_present_full_ptes()" is dropped (David Hildenbrand)
- direct PTE dereferencing KASAN sanitizer added (Heiko Carstens)
- CONFIG_IPTE_BATCH option is dropped (Heiko Carstens)
- PTE_POISON changed from zero to 0x800 (Heiko Carstens)
- allocate per-cpu caches on CPU hot-plug (Heiko Carstens)
- introduced a lowcore field for fast lazy mode checking (Heiko Carstens)
- few minor code changes (Heiko Carstens)
Changes since v1:
- lazy_mmu_mode_enable_pte() renamed to lazy_mmu_mode_enable_for_pte_rang= e()
- lazy_mmu_mode_enable_for_pte_range() semantics clarified
- some sashiko comments addressed [1] including one bug fix [1]
- patches 2-4 added
1. https://sashiko.dev/#/patchset/cover.1774420056.git.agordeev%40linux.i=
bm.com
This series addresses an s390-specific aspect of how page table entries are modified. In many cases, changing a valid PTE (for example, setting or clearing a hardware bit) requires issuing an Invalidate Page Table Entry (IPTE) instruction beforehand.
A disadvantage of the IPTE instruction is that it may initiate a machine-wide quiesce state. This state acts as an expensive global hardware lock and should be avoided whenever possible.
Currently, IPTE is invoked for each individual PTE update in most code paths. However, the instruction itself supports invalidating multiple PTEs at once, covering up to 256 entries. Using this capability can significantly reduce the number of quiesce events, with a positive impact on overall system performance. At present, this feature is not utilized.
An effort was therefore made to identify kernel code paths that update large numbers of consecutive PTEs. Such updates can be batched and handled by a single IPTE invocation, leveraging the hardware support described above.
A natural candidate for this optimization is page-table walkers that change attributes of memory ranges and thus modify contiguous ranges of PTEs. Many memory-management system calls enter lazy MMU mode while updating such ranges.
This lazy MMU mode can be leveraged to build on the already existing infrastructure and implement a software-level lazy MMU mechanism, allowing expensive PTE invalidations on s390 to be batched.
Thanks!
Alexander Gordeev (6):
s390/mm: Cleanup pXXp_flush_lazy() routines
s390: Distinguish hardware and software PTEs
mm: Make lazy MMU mode context-aware
s390/mm: Batch PTE updates in lazy MMU mode mm/kasan: Introduce helpers for lazy MMU mode sanitizer s390/mm: Lazy MMU mode sanitizer
Muhammad Usama Anjum (9):
mm: introduce hw_pte_t for PTE table storage
mm: rename pointers to software PTE values as ptentp
mm: use hw_pte_t for generic PTE table storage
mm: convert PTE table entries in ptep_get()
mm: convert PTE table entry to pte
mm: add hw_pte_val for HW PTE storage mm/kasan: use hw_pte_t for the early shadow PTE table drm/i915: use hw_pte_t for PTE range callbacks
xen: use hw_pte_t for PTE range callbacks
MAINTAINERS | 1 + arch/s390/Kconfig | 2 + arch/s390/boot/startup.c | 2 +- arch/s390/boot/vmem.c | 17 +- arch/s390/include/asm/gmap_helpers.h | 2 +- arch/s390/include/asm/hugetlb.h | 18 +- arch/s390/include/asm/lowcore.h | 3 +- arch/s390/include/asm/maccess.h | 2 +- arch/s390/include/asm/page.h | 3 +- arch/s390/include/asm/pgalloc.h | 6 +- arch/s390/include/asm/pgtable.h | 215 +++++++-- arch/s390/kernel/uv.c | 4 +- arch/s390/kvm/s390/pv.c | 2 +- arch/s390/mm/Makefile | 2 +- arch/s390/mm/gmap_helpers.c | 18 +- arch/s390/mm/hugetlbpage.c | 20 +- arch/s390/mm/lazy_mmu.c | 449 ++++++++++++++++++ arch/s390/mm/maccess.c | 2 +- arch/s390/mm/pageattr.c | 10 +- arch/s390/mm/pgtable.c | 34 +- arch/s390/mm/vmem.c | 26 +- .../drm/i915/gem/selftests/i915_gem_mman.c | 4 +- drivers/gpu/drm/i915/i915_mm.c | 4 +- drivers/xen/gntdev.c | 2 +- drivers/xen/privcmd.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xlate_mmu.c | 4 +- fs/hugetlbfs/inode.c | 3 +- fs/proc/task_mmu.c | 35 +- include/asm-generic/hugetlb.h | 15 +- include/asm-generic/pgalloc.h | 6 +- include/asm-generic/tlb.h | 5 +- include/linux/hugetlb.h | 53 ++- include/linux/kasan.h | 21 +- include/linux/mm.h | 26 +- include/linux/page_table_check.h | 10 +- include/linux/pagewalk.h | 10 +- include/linux/pgtable.h | 127 +++-- include/linux/pgtable_types.h | 23 + include/linux/rmap.h | 2 +- include/linux/swapops.h | 6 +- include/linux/vmalloc.h | 4 +- include/trace/events/xen.h | 10 +- kernel/bpf/arena.c | 9 +- kernel/events/core.c | 3 +- mm/Kconfig | 3 + mm/damon/ops-common.c | 2 +- mm/damon/ops-common.h | 2 +- mm/damon/vaddr.c | 20 +- mm/debug_vm_pgtable.c | 2 +- mm/filemap.c | 4 +- mm/gup.c | 9 +- mm/highmem.c | 15 +- mm/hmm.c | 6 +- mm/huge_memory.c | 4 +- mm/hugetlb.c | 60 +-- mm/hugetlb_vmemmap.c | 13 +- mm/internal.h | 16 +- mm/kasan/common.c | 14 + mm/kasan/init.c | 14 +- mm/kasan/kasan.h | 2 + mm/kasan/report_generic.c | 3 + mm/kasan/shadow.c | 6 +- mm/khugepaged.c | 50 +- mm/ksm.c | 11 +- mm/madvise.c | 26 +- mm/mapping_dirty_helpers.c | 4 +- mm/memory-failure.c | 6 +- mm/memory.c | 86 ++-- mm/mempolicy.c | 4 +- mm/migrate.c | 4 +- mm/migrate_device.c | 4 +- mm/mincore.c | 4 +- mm/mlock.c | 4 +- mm/mprotect.c | 21 +- mm/mremap.c | 6 +- mm/page_table_check.c | 4 +- mm/pagewalk.c | 9 +- mm/percpu.c | 2 +- mm/pgtable-generic.c | 20 +- mm/ptdump.c | 4 +- mm/rmap.c | 6 +- mm/sparse-vmemmap.c | 22 +- mm/swap_state.c | 3 +- mm/swapfile.c | 5 +- mm/userfaultfd.c | 32 +- mm/util.c | 2 +- mm/vmalloc.c | 17 +- mm/vmscan.c | 6 +- 89 files changed, 1269 insertions(+), 512 deletions(-) create mode 100644 arch/s390/mm/lazy_mmu.c create mode 100644 include/linux/pgtable_types.h
Signature · 1 line
2.53.0