From nobody Wed Jul 10 22:07:07 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 4WKBmC70QXz5RFXf; Wed, 10 Jul 2024 22:07:07 +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 4WKBmC5yjvz4LFM; Wed, 10 Jul 2024 22:07:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720649227; 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=65aJ/Avz8bh9Lz77lZdEn++bYOQCDv5bXFyfM+TNFZE=; b=C5PaCKSNa72nB+cUDMVvQDe6n5wiBBrUauLiaN99nW5nW4VXaKdy3qb9rES/DgR27L65Su g93L5YAIQXjVF12L4RP472rO4xKyfAXtN5Guo6UEm0Nw2cNg7qBX5lQmejzOqk5B17k2gk HszLwnmH2a8n/VjyQmMTJ3XCCQEWyACZyS0K/eFbV37P16pFicojV1glwEGkf31/EUPSId U21lAR/c0oC63gP9PWLY6r2EYGpIUrMsG5gnABwrGf/OwUULbauNvYWAFR98zEzy5GWDjC qof2pTHrGHa+4JD/EsCOA47nyQoNv4km3cy3lXyiu82XCKDBFm+Ss7soOmzBVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720649227; a=rsa-sha256; cv=none; b=x5rc3iQ0TK+ZhIOMvbIekzsURHJXuk+t7ENXYs+x9obFDSo7jSwAUAqpZGUzpZjRXpSpD4 3eju7fEpp9HI4ZWOm1g2SZZUL8dTFYMH6Bg846kOpwMM8s2fGveNjFeuHUcSbuyf4gyG2C XxYvjnrjbsxo7ZirUrsNCCboQses+Ef8sKUMDY/wnTuSC22Vyf5rqw/YJDDU/sUd5pb2HO CnLySuxG8jlJj/ze7452wvbt2S+WIF2n0GRc6TyKMQuthfSciCm5mP1s45KgHyXdxuL7M8 dt10tagM7w0cUHLfHt6IIWjA+sgLFYn09b5ocIhFeDxdqvumHfE0GgwkWa/1QA== 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=1720649227; 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=65aJ/Avz8bh9Lz77lZdEn++bYOQCDv5bXFyfM+TNFZE=; b=j6Z87OZl6ZhU7YWdfL9Co9JoI7hGGmWwXBFDSdI+jGgFS3G/JWeG7rt17qsvU5xZ48qEdo w6l2i5Q2fqHdsIKV2G/jWw96qhIQIDnmMmeP5OKLID+LjTOFQyvOl3dyu8NYsk1rEXlDK6 wU3w/+tQ/Fpi2RCU7UVtPzgCdm/nLAagjRfRAU6SbHEUB9kpT7C9Rp9a5LhUfPfshTmKDF /jr44XdysgyuCulO3zT8snWCg0gW8EthaDRaZOCzM3hONDpVdcFP55LCnd8XnbSKghRLUW KrActvsSKMk0JyXD2enoCxSqxRhEhZ/+vFy0D2t0nWxkmFAvjpkd72fpC42MLQ== 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 4WKBmC5ZtCzb4P; Wed, 10 Jul 2024 22:07:07 +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 46AM771F080284; Wed, 10 Jul 2024 22:07:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46AM778e080281; Wed, 10 Jul 2024 22:07:07 GMT (envelope-from git) Date: Wed, 10 Jul 2024 22:07:07 GMT Message-Id: <202407102207.46AM778e080281@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 8b5eb0cf6c4f - stable/13 - vfs cache: add sysctl vfs.cache.param.hitpct 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8b5eb0cf6c4f586f891fef7fb067beb343826435 Auto-Submitted: auto-generated The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8b5eb0cf6c4f586f891fef7fb067beb343826435 commit 8b5eb0cf6c4f586f891fef7fb067beb343826435 Author: Mateusz Guzik AuthorDate: 2024-07-08 17:57:39 +0000 Commit: Mateusz Guzik CommitDate: 2024-07-10 22:06:15 +0000 vfs cache: add sysctl vfs.cache.param.hitpct Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 0a487207227badcbfbec029103ac7e2d5291bd30) --- sys/kern/vfs_cache.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 647d4573563c..aacbd43403e1 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -988,6 +988,26 @@ SYSCTL_PROC(_vfs_cache, OID_AUTO, nchstats, CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_nchstats, "LU", "VFS cache effectiveness statistics"); +static int +sysctl_hitpct(SYSCTL_HANDLER_ARGS) +{ + long poshits, neghits, miss, total; + long pct; + + poshits = counter_u64_fetch(numposhits); + neghits = counter_u64_fetch(numneghits); + miss = counter_u64_fetch(nummiss); + total = poshits + neghits + miss; + + pct = 0; + if (total != 0) + pct = ((poshits + neghits) * 100) / total; + return (sysctl_handle_int(oidp, 0, pct, req)); +} +SYSCTL_PROC(_vfs_cache_stats, OID_AUTO, hitpct, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD, NULL, 0, sysctl_hitpct, + "I", "Percentage of hits"); + static void cache_recalc_neg_min(void) {