git: 88d81453b115 - main - riscv: support PV_STATS pmap option
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Jul 2024 14:52:33 UTC
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=88d81453b1151f8b133023073f3a773dd78cdc3a commit 88d81453b1151f8b133023073f3a773dd78cdc3a Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2024-07-08 14:44:10 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2024-07-08 14:44:10 +0000 riscv: support PV_STATS pmap option It is rarely used but trivially supported; add the missing stat calls and enable it in LINT. Reviewed by: markj, br (previous version), jhb (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45475 --- sys/conf/options.riscv | 2 +- sys/riscv/conf/NOTES | 3 +++ sys/riscv/riscv/pmap.c | 13 ++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/conf/options.riscv b/sys/conf/options.riscv index 6a8df1d2f54e..5e1b76140ec7 100644 --- a/sys/conf/options.riscv +++ b/sys/conf/options.riscv @@ -1,3 +1,3 @@ - RISCV opt_global.h # For cpu RISCV to work INTRNG opt_global.h +PV_STATS opt_pmap.h diff --git a/sys/riscv/conf/NOTES b/sys/riscv/conf/NOTES index 36d2e06fb698..102ee26811b3 100644 --- a/sys/riscv/conf/NOTES +++ b/sys/riscv/conf/NOTES @@ -17,6 +17,9 @@ options KDTRACE_HOOKS # Kernel DTrace hooks options DDB_CTF # Kernel ELF linker loads CTF data options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default +# Enable detailed accounting by the PV entry allocator. +options PV_STATS + # RISC-V SBI console device rcons diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 781f6b250a18..f49f18ba87bb 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -93,7 +93,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> /* * Manages physical address maps. * @@ -113,6 +112,8 @@ * and to when physical maps must be made correct. */ +#include "opt_pmap.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/bitstring.h> @@ -1891,7 +1892,6 @@ static const uint64_t pc_freemask[_NPCM] = { [_NPCM - 1] = PC_FREEL }; -#if 0 #ifdef PV_STATS static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail; @@ -1916,7 +1916,6 @@ SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG_RD, &pv_entry_spare, 0, "Current number of spare pv entries"); #endif -#endif /* 0 */ /* * We are in a serious low memory condition. Resort to @@ -2101,7 +2100,8 @@ retry: goto retry; reclaimed = true; } - /* XXX PV STATS */ + PV_STAT(atomic_add_int(&pc_chunk_count, 1)); + PV_STAT(atomic_add_int(&pc_chunk_allocs, 1)); #if 0 dump_add_page(m->phys_addr); #endif @@ -2112,6 +2112,7 @@ retry: pc->pc_map[2] = PC_FREEL; TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); + PV_STAT(atomic_add_int(&pv_entry_spare, _NPCPV)); /* * The reclaim might have freed a chunk from the current pmap. @@ -2222,6 +2223,7 @@ pmap_pv_demote_l2(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next); m->md.pv_gen++; /* Instantiate the remaining 511 pv entries. */ + PV_STAT(atomic_add_long(&pv_entry_allocs, Ln_ENTRIES - 1)); va_last = va + L2_SIZE - PAGE_SIZE; for (;;) { pc = TAILQ_FIRST(&pmap->pm_pvchunk); @@ -2250,7 +2252,8 @@ out: TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } - /* XXX PV stats */ + PV_STAT(atomic_add_long(&pv_entry_count, Ln_ENTRIES - 1)); + PV_STAT(atomic_add_int(&pv_entry_spare, -(Ln_ENTRIES - 1))); } #if VM_NRESERVLEVEL > 0