From 7c73d09c2efe0a1049f5556da74181668d20a1fb Mon Sep 17 00:00:00 2001 From: jca Date: Wed, 13 Dec 2023 18:26:41 +0000 Subject: [PATCH] Implement per-CPU caching for the page table page (vp) pool and the PTE descriptor (pted) pool in the [riscv64] pmap implementation. This significantly reduces the side-effects of lock contention on the kernel map lock that is (incorrectly) translated into excessive page daemon wakeups. This is not a perfect solution but it does lead to significant speedups [on the Hifive Unmatched] Improvement and commit message adapted from kettenis' rev 1.110 commit to arm64/pmap.c. ok phessler@ kettenis@ --- sys/arch/riscv64/include/pmap.h | 4 ++-- sys/arch/riscv64/riscv64/pmap.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/arch/riscv64/include/pmap.h b/sys/arch/riscv64/include/pmap.h index fcfd60d63be..1f52a260ee5 100644 --- a/sys/arch/riscv64/include/pmap.h +++ b/sys/arch/riscv64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.9 2023/12/11 22:12:53 kettenis Exp $ */ +/* $OpenBSD: pmap.h,v 1.10 2023/12/13 18:26:41 jca Exp $ */ /* * Copyright (c) 2019-2020 Brian Bamsch @@ -111,10 +111,10 @@ void pmap_physload_avail(void); struct pv_entry; /* investigate */ -#define pmap_init_percpu() do { /* nothing */ } while (0) #define pmap_unuse_final(p) do { /* nothing */ } while (0) int pmap_fault_fixup(pmap_t, vaddr_t, vm_prot_t); void pmap_postinit(void); +void pmap_init_percpu(void); #endif /* _KERNEL && !_LOCORE */ diff --git a/sys/arch/riscv64/riscv64/pmap.c b/sys/arch/riscv64/riscv64/pmap.c index 30db5d9b76b..1e33584f729 100644 --- a/sys/arch/riscv64/riscv64/pmap.c +++ b/sys/arch/riscv64/riscv64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.36 2023/11/28 09:10:18 jsg Exp $ */ +/* $OpenBSD: pmap.c,v 1.37 2023/12/13 18:26:41 jca Exp $ */ /* * Copyright (c) 2019-2020 Brian Bamsch @@ -1773,6 +1773,13 @@ pmap_postinit(void) npages * PAGE_SIZE, VM_MAP_INTRSAFE, FALSE, NULL); } +void +pmap_init_percpu(void) +{ + pool_cache_init(&pmap_pted_pool); + pool_cache_init(&pmap_vp_pool); +} + void pmap_update(pmap_t pm) { -- 2.20.1