git: c79af90ce42f - releng/14.0 - vfs: convert recycles_count and recycles_free_count to mere u_long

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 14 Oct 2023 01:09:00 UTC
The branch releng/14.0 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=c79af90ce42f2cea823c6ab052726393c709b89a

commit c79af90ce42f2cea823c6ab052726393c709b89a
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-10-12 06:57:59 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-10-14 01:08:23 +0000

    vfs: convert recycles_count and recycles_free_count to mere u_long
    
    Only vnlru ever updates them.
    
    This also removes recycles_count updates from hand-rolled debug vnode
    recycling via sysctl.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 37544d9768110fd67527db7f2a3f7bb6fc977582)
    (cherry picked from commit bdd19ce53c07bc44b9d8f46dcedda0fceca8e069)
    
    Approved by:    re (gjb)
---
 sys/kern/vfs_subr.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index b14793ccd84e..0fe2bc46446c 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -199,16 +199,19 @@ static long wantfreevnodes;
 static long __exclusive_cache_line freevnodes;
 static long freevnodes_old;
 
-static counter_u64_t recycles_count;
-SYSCTL_COUNTER_U64(_vfs, OID_AUTO, recycles, CTLFLAG_RD, &recycles_count,
+static u_long recycles_count;
+SYSCTL_ULONG(_vfs, OID_AUTO, recycles, CTLFLAG_RD | CTLFLAG_STATS, &recycles_count, 0,
     "Number of vnodes recycled to meet vnode cache targets (legacy)");
-SYSCTL_COUNTER_U64(_vfs_vnode_vnlru, OID_AUTO, recycles, CTLFLAG_RD, &recycles_count,
+SYSCTL_ULONG(_vfs_vnode_vnlru, OID_AUTO, recycles, CTLFLAG_RD | CTLFLAG_STATS,
+    &recycles_count, 0,
     "Number of vnodes recycled to meet vnode cache targets");
 
-static counter_u64_t recycles_free_count;
-SYSCTL_COUNTER_U64(_vfs, OID_AUTO, recycles_free, CTLFLAG_RD, &recycles_free_count,
+static u_long recycles_free_count;
+SYSCTL_ULONG(_vfs, OID_AUTO, recycles_free, CTLFLAG_RD | CTLFLAG_STATS,
+    &recycles_free_count, 0,
     "Number of free vnodes recycled to meet vnode cache targets (legacy)");
-SYSCTL_COUNTER_U64(_vfs_vnode_vnlru, OID_AUTO, recycles_free, CTLFLAG_RD, &recycles_free_count,
+SYSCTL_ULONG(_vfs_vnode_vnlru, OID_AUTO, recycles_free, CTLFLAG_RD | CTLFLAG_STATS,
+    &recycles_free_count, 0,
     "Number of free vnodes recycled to meet vnode cache targets");
 
 static counter_u64_t direct_recycles_free_count;
@@ -458,7 +461,6 @@ sysctl_try_reclaim_vnode(SYSCTL_HANDLER_ARGS)
 		goto putvnode;
 	}
 
-	counter_u64_add(recycles_count, 1);
 	vgone(vp);
 putvnode:
 	vput(vp);
@@ -492,7 +494,6 @@ sysctl_ftry_reclaim_vnode(SYSCTL_HANDLER_ARGS)
 	if (error != 0)
 		goto drop;
 
-	counter_u64_add(recycles_count, 1);
 	vgone(vp);
 	VOP_UNLOCK(vp);
 drop:
@@ -774,8 +775,6 @@ vntblinit(void *dummy __unused)
 	uma_prealloc(buf_trie_zone, nbuf);
 
 	vnodes_created = counter_u64_alloc(M_WAITOK);
-	recycles_count = counter_u64_alloc(M_WAITOK);
-	recycles_free_count = counter_u64_alloc(M_WAITOK);
 	direct_recycles_free_count = counter_u64_alloc(M_WAITOK);
 	vnode_skipped_requeues = counter_u64_alloc(M_WAITOK);
 
@@ -1282,7 +1281,7 @@ restart:
 			vn_finished_write(mp);
 			goto next_iter_unlocked;
 		}
-		counter_u64_add(recycles_count, 1);
+		recycles_count++;
 		vgonel(vp);
 		VOP_UNLOCK(vp);
 		vdropl_recycle(vp);
@@ -1911,7 +1910,7 @@ vtryrecycle(struct vnode *vp, bool isvnlru)
 	}
 	if (!VN_IS_DOOMED(vp)) {
 		if (isvnlru)
-			counter_u64_add(recycles_free_count, 1);
+			recycles_free_count++;
 		else
 			counter_u64_add(direct_recycles_free_count, 1);
 		vgonel(vp);