From nobody Thu Oct 05 12:44:48 2023 X-Original-To: dev-commits-src-main@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 4S1WV82zGqz4wZkd; Thu, 5 Oct 2023 12:44:48 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S1WV826d8z3gtb; Thu, 5 Oct 2023 12:44:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696509888; 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=bB+5mncnGS9EE4YEf1tbP+F03swS5HD7l6sj6oQqi+Q=; b=yuRE2mGfCNMTMak1S64nOJ2VP5dpwwJjUlSAT+zsaVIN+0gG6o/4kJoZib0QBPeWkzpEqX HJr82n7o+Ft5g/YigpNMlN0H2zxb5uYvrB0U/GjACUv3/lyFOBKMfc2FA+UqKDNWT1UPym y4a/b5/KgE5C7F1ilUntZjtKDLx1ghu3Ot8QQcyfIo7eCGBCQjgXZKxUj4R0Fmf9me7mjq m/iv4UZqWp7qtnSMpliI2pDDmWgRawrEN9PIOQPx/xbmvRXmeaH8RU9ydr3U9p8/9VQMsQ ehL1T+4/OokkFVBUb5ui9VY+1W3mL4fHNCfbxESHTMBAOee59UKFr5o0K21PxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696509888; a=rsa-sha256; cv=none; b=NlSM6n4HYaG+t97xSmr7N1ab8jCMMY6M5kFwTcQPE2ohdIGyG8A71g/sQICaJiwBonUgPG kPnTDIZhxR5yetOlMbsNNscYI1v4yWRdsLK2YB8lMWFColn9MhWjy2KJXgPPhLYkVbmBAY l1X+Jr2bbm8D3zhYQb4uPAmpDIUm6Rkz9nTjLtN8QQ+nRhdfsmQKsxo+3bmdBQ5+q6S6Uo d+1kK9kGeXkfbclrpuwsasUEhdmu3ag7fA1KF5xtbgwz7Vl9NOA0tDwSPfFMljU9jhQdTz r4rBz5kmlgEGJGgaiRLn0tvboEu0XMoSOBAmNqbu4C6BFhAJdaiVLI1kgFt+MQ== 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=1696509888; 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=bB+5mncnGS9EE4YEf1tbP+F03swS5HD7l6sj6oQqi+Q=; b=nk5KjQBOXqBN0S+UmPQjphCnnBre3VQWSALe01TNqDybMg15xJR5ry2fdVjPwKHa/9fsZu v54IkyzZSjDE3zQHLO8FUH4g80QLTI9joYwVRsYI5BEwfhgYaR3a9hy79ORpjw9s6oNvwo fUjick1XmNJTbWQxqlVuWcFipfTQHOgUctwUhugyrY5ER50k+TANsCpVu84FTh041ZdAU6 jlbtM85P1EJL8NeueS5mGDNhImVl0zgVfEdDA4DyKifQvtFfO6/9h01k13Wh4S/eR2QMVt SyrMNuLWCnxK0NpAT6bYo8nO84zucJMqvzNsbJ/8XycsLZkXjs8mcr6CUsj4ug== 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 4S1WV80t5Jz1KQy; Thu, 5 Oct 2023 12:44:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 395Cim1o027351; Thu, 5 Oct 2023 12:44:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 395CimUE027348; Thu, 5 Oct 2023 12:44:48 GMT (envelope-from git) Date: Thu, 5 Oct 2023 12:44:48 GMT Message-Id: <202310051244.395CimUE027348@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 2749c222da8a - main - vfs cache: sanitize debug counters List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2749c222da8a6325d39c0571f72b1dbed2f7d583 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2749c222da8a6325d39c0571f72b1dbed2f7d583 commit 2749c222da8a6325d39c0571f72b1dbed2f7d583 Author: Mateusz Guzik AuthorDate: 2023-10-05 12:16:18 +0000 Commit: Mateusz Guzik CommitDate: 2023-10-05 12:44:42 +0000 vfs cache: sanitize debug counters They are very rarely triggered, so no need for per-cpu distribution. At the same time the non-cpu ones still should use atomics to not lose any updates. --- sys/kern/vfs_cache.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 6ae4239cc11d..00632716a2ec 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -628,17 +628,14 @@ static SYSCTL_NODE(_vfs_cache, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Name cache debugging"); #define DEBUGNODE_ULONG(name, varname, descr) \ SYSCTL_ULONG(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &varname, 0, descr); -#define DEBUGNODE_COUNTER(name, varname, descr) \ - static COUNTER_U64_DEFINE_EARLY(varname); \ - SYSCTL_COUNTER_U64(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &varname, \ - descr); -DEBUGNODE_COUNTER(zap_bucket_relock_success, zap_bucket_relock_success, +static u_long zap_bucket_relock_success; +DEBUGNODE_ULONG(zap_bucket_relock_success, zap_bucket_relock_success, "Number of successful removals after relocking"); -static long zap_bucket_fail; +static u_long zap_bucket_fail; DEBUGNODE_ULONG(zap_bucket_fail, zap_bucket_fail, ""); -static long zap_bucket_fail2; +static u_long zap_bucket_fail2; DEBUGNODE_ULONG(zap_bucket_fail2, zap_bucket_fail2, ""); -static long cache_lock_vnodes_cel_3_failures; +static u_long cache_lock_vnodes_cel_3_failures; DEBUGNODE_ULONG(vnodes_cel_3_failures, cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); @@ -1739,7 +1736,7 @@ cache_zap_unlocked_bucket(struct namecache *ncp, struct componentname *cnp, cache_zap_locked(rncp); mtx_unlock(blp); cache_unlock_vnodes(dvlp, vlp); - counter_u64_add(zap_bucket_relock_success, 1); + atomic_add_long(&zap_bucket_relock_success, 1); return (0); } @@ -1835,7 +1832,7 @@ retry: error = cache_zap_locked_bucket(ncp, cnp, hash, blp); if (__predict_false(error != 0)) { - zap_bucket_fail++; + atomic_add_long(&zap_bucket_fail, 1); goto retry; } counter_u64_add(numposzaps, 1); @@ -2061,7 +2058,7 @@ negative_success: counter_u64_add(numnegzaps, 1); error = cache_zap_locked_bucket(ncp, cnp, hash, blp); if (__predict_false(error != 0)) { - zap_bucket_fail2++; + atomic_add_long(&zap_bucket_fail2, 1); goto retry; } cache_free(ncp); @@ -2259,8 +2256,8 @@ cache_lock_vnodes_cel_3(struct celockstate *cel, struct vnode *vp) } else { if (mtx_trylock(vlp)) goto out; - cache_lock_vnodes_cel_3_failures++; cache_unlock_vnodes_cel(cel); + atomic_add_long(&cache_lock_vnodes_cel_3_failures, 1); if (vlp < cel->vlp[0]) { mtx_lock(vlp); mtx_lock(cel->vlp[0]);