[PATCH v2 00/15] riscv: add Svnapot PTE folding support
Yunhui Cui
cuiyunhui at bytedance.com
Thu Jul 16 05:41:35 PDT 2026
Svnapot can encode a naturally aligned 64KB range as a single folded
PTE block. This series adds the RISC-V MM support needed to use that
encoding for suitable user mappings while preserving the generic MM view
of PAGE_SIZE PTEs.
The series starts by adding raw PTE helpers and switching architecture
page-table users that must see the encoded page-table entry to those raw
helpers. It then introduces Svnapot read-side and update helpers for
folded PTE ranges. Later patches make the generic PTE batch and leaf-size
interfaces work with the raw encoded view where required, avoid redundant
A/D aggregation and TLB flushes, optimize mprotect() for Svnapot ranges,
and request 64KB executable folios when Svnapot is available so text
mappings can benefit from lower iTLB pressure.
Dependency:
- This series depends on the prerequisite RISC-V patch posted at:
https://lore.kernel.org/all/20260618064406.14508-1-cuiyunhui@bytedance.com/
Changes in v2:
- Rework the v1 7-patch series into 15 smaller patches: split raw PTE
helper introduction from the architecture-user conversion, and split
Svnapot contpte handling into read-side and update-side pieces.
- Add the generic MM helper changes needed by folded Svnapot mappings,
including folio-batch comparison flags, raw-entry leaf-size queries and
fast-GUP-specific lockless PTE helpers.
- Make the RISC-V pte_batch_hint() implementation honor folio batch
flags, and preserve Svnapot leaf-size semantics via __ptep_leaf_size().
- Add follow-up fixes and optimizations that were not in v1: avoid
redundant A/D aggregation, avoid Svnapot consistency checks in
ptep_get(), avoid A/D aggregation in fast-GUP, remove a redundant TLB
flush, optimize mprotect() for Svnapot mappings, and request large
executable folios when Svnapot is available.
Yunhui Cui (15):
riscv: introduce raw PTE helpers
riscv: switch arch page-table users to raw PTE helpers
riscv/mm: implement Svnapot contpte read-side helpers
riscv/mm: implement Svnapot contpte update helpers
mm: extend pte batch and leaf-size helpers
riscv: make pte_batch_hint() honor folio batch flags
riscv/mm: preserve Svnapot leaf-size semantics for page-table
consumers
riscv/mm: avoid redundant Svnapot A/D aggregation
riscv/mm: avoid Svnapot consistency checks in ptep_get()
mm/gup: add fast-GUP specific lockless PTE helpers
riscv: mm: avoid Svnapot A/D aggregation in fast-GUP
arm64: mm: avoid contpte A/D aggregation in fast-GUP
riscv/mm: remove redundant TLB flush in napotpte_convert
riscv/mm: optimize mprotect for Svnapot mappings
riscv: mm: Request large exec folios for Svnapot
arch/arm64/include/asm/pgtable.h | 25 +-
arch/riscv/include/asm/kfence.h | 4 +-
arch/riscv/include/asm/pgtable.h | 480 +++++++++++++++++-
arch/riscv/kernel/efi.c | 4 +-
arch/riscv/kernel/hibernate.c | 3 +-
arch/riscv/kvm/gstage.c | 25 +-
arch/riscv/kvm/mmu.c | 4 +-
arch/riscv/mm/Makefile | 1 +
arch/riscv/mm/contpte.c | 804 +++++++++++++++++++++++++++++++
arch/riscv/mm/fault.c | 4 +-
arch/riscv/mm/hugetlbpage.c | 135 ++++--
arch/riscv/mm/init.c | 8 +-
arch/riscv/mm/kasan_init.c | 16 +-
arch/riscv/mm/pageattr.c | 12 +-
arch/riscv/mm/pgtable.c | 52 +-
include/linux/pgtable.h | 71 ++-
kernel/events/core.c | 2 +-
mm/gup.c | 6 +-
mm/internal.h | 39 +-
mm/mincore.c | 2 +-
mm/mremap.c | 2 +-
21 files changed, 1542 insertions(+), 157 deletions(-)
create mode 100644 arch/riscv/mm/contpte.c
base-commit: b8809969e1d7a591e0f49dd464a5d04b3cf02ab1
--
2.39.5
More information about the kvm-riscv
mailing list