From nobody Mon Jul 08 14:52:33 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WHnCj5cDzz5QMX6; Mon, 08 Jul 2024 14:52:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHnCj58CZz3wqf; Mon, 8 Jul 2024 14:52:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720450353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U+2tPirVldpECWcRRRspE8dbHEFQxksa3MlDjRoyQiA=; b=NOKcG55Jm5au/Qc/gdyAUvLyw+Y/Ij7b9umJiU75/SDE7AihbnaV4kgq6mqtQ0my3oZlbf gPsRIOowJosu7kt+8cxsGDJiv/0/pBNtm5LBhs2pXXbkXX4w1WCc/NyNcxLzW4mgg2a3dh qlu9FcqiJTGcYC/XcwDrgWil8JZAkwEgtBsQlASvtQUd17AXeuZjsg1xQtUJLsiyRYthgh Oaws6o1K7qjGQy6v5/4jN78IFcbbhuaQiQic6bviW5aE3WKotIjwDAuGjRPo1Sx9RnDvB3 uQMgdUSBkh+Jt49YGTy7kDPlr1nRwuT5yKsRA+KyX4+tuOlDubUMY0wso01aWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720450353; a=rsa-sha256; cv=none; b=FAccakYwOR27qWAvGkHm8yDJ27i14OivL3kIHoPtT9Hpf8V/olk/XKt3hpABrjvY/Ow5Yr /lEOwLFEc++ta6y+Eu/tgIWXZkmVLwko8covsdtDe6+nrypjCY14uP6dC+eIfc1XUZzDbV x/aYBvGgAoC0bexlyaRZrvC2qHFFHeRM4uPflD7mF2Ge6jG7L8C+9mj6k7lx/qCgyti8Eh flby3ChS2pAUOEyMu/AYimB04wsoxIKIF3zmjzRhbDPg/1y60HMHUd5dwxYlGd47UsDD+8 1w3QfuNtQM3Rq5VFAiFpxnLMuvHiUjF/NZhq/lrdJCiVF/2TvoScsZpg5ruP1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720450353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U+2tPirVldpECWcRRRspE8dbHEFQxksa3MlDjRoyQiA=; b=jpOF1um+kuUnxIwwSYTsAEYgHjZLHN8uISwjcwmN15VVRu5qy99wJYOiAJP6m7Kn17jqBC ZdA+i5zKYMykJWQU6zK33msXRhXERPeLq7jZ63Gbdl6GpNKzar1yxG46I8a9BgTiMBS6b9 /c7MWBDM6e6Paj1hyI05fB4uQFX5QjJltbT4y+gaGlBhOt8+0x0WD00tcziiJdnK1s9cWT vvp51BWHuYxgseYxwoR8/BIFKcJL6O3yx1qCP3khZ5XwU+gfUPc0clCa+/aAnS54/2QCmy X7GxNFC0TCQU84TqZ4ptPBl3SE04tVN9/SDU39fDZ+Tij6ZOxYShnhAwhTBEmQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WHnCj4lL9zwKD; Mon, 8 Jul 2024 14:52:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 468EqXHW046613; Mon, 8 Jul 2024 14:52:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 468EqXDu046610; Mon, 8 Jul 2024 14:52:33 GMT (envelope-from git) Date: Mon, 8 Jul 2024 14:52:33 GMT Message-Id: <202407081452.468EqXDu046610@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 88d81453b115 - main - riscv: support PV_STATS pmap option List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 88d81453b1151f8b133023073f3a773dd78cdc3a Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=88d81453b1151f8b133023073f3a773dd78cdc3a commit 88d81453b1151f8b133023073f3a773dd78cdc3a Author: Mitchell Horne AuthorDate: 2024-07-08 14:44:10 +0000 Commit: Mitchell Horne 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 /* * Manages physical address maps. * @@ -113,6 +112,8 @@ * and to when physical maps must be made correct. */ +#include "opt_pmap.h" + #include #include #include @@ -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