[PATCH v2 15/15] riscv: mm: Request large exec folios for Svnapot
Yunhui Cui <[email protected]> Thu, 16 Jul 2026 20:41:50 +0800
| Newsgroups | org.kernel.vger.linux-efi,org.infradead.lists.kvm-riscv,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-riscv,org.kernel.vger.kvm,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kvack.linux-mm |
|---|---|
| Message-ID | <88438f09b79ceab1548aff17384814b7f699a43d.1784201104.git.cuiyunhui@bytedance.com> |
The Svnapot MM support in this series allows generic MM paths to operate on folded 64KB executable mappings while preserving a per-page public PTE view. To benefit from that more often, executable file-backed mappings should be faulted in with a folio size that can be folded into a Svnapot range. Request 64KB executable folios when Svnapot is available, so executable text mappings are more likely to be installed as folded Svnapot blocks and benefit from lower iTLB pressure. Keep the default order-0 behavior when Svnapot is unavailable. Signed-off-by: Yunhui Cui <[email protected]> --- arch/riscv/include/asm/pgtable.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index b546e6614c558..6801ba135c483 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -296,6 +296,14 @@ static __always_inline bool has_svnapot(void) return riscv_has_extension_likely(RISCV_ISA_EXT_SVNAPOT); } +/* + * Request executable file-backed mappings to be read into 64KB folios when + * Svnapot is available. A naturally aligned 64KB folio can be folded into a + * Svnapot PTE range, reducing iTLB pressure for executable text. + */ +#define exec_folio_order() \ + (has_svnapot() ? NAPOT_CONT64KB_ORDER : 0) + static inline unsigned long pte_napot(pte_t pte) { return pte_val(pte) & _PAGE_NAPOT; -- 2.39.5