aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2023-10-10 16:19:53 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2023-10-14 01:07:26 +0000
commit01211b4be09f6e1838da87339ddb3655702d254b (patch)
tree49e20fabe99325245884bffe21df5977a830ed8b
parent988f3becc6d4afdb5c12313184515183c3e631db (diff)
downloadsrc-01211b4be09f6e1838da87339ddb3655702d254b.tar.gz
src-01211b4be09f6e1838da87339ddb3655702d254b.zip
vfs: consult freevnodes in vnlru_kick_cond
If the count is high enough there is no point trying to produce more. Not going there reduces traffic on the vnode_list mtx. This further shaves total real time in a test mentioned in: 74be676d87745eb7 ("vfs: drop one vnode list lock trip during vnlru free recycle") -- 20 instances of find each creating 1 million vnodes, while total limit is set to 400k. Time goes down from ~41 to ~35 seconds. Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 23ef25d25d989e7213bc1d3ef32b0f48a9eb2537) (cherry picked from commit 5cf1c99d4c425ab196dfa3bafcf3a5f142eab887) Approved by: re (gjb)
-rw-r--r--sys/kern/vfs_subr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index e7e612254ba2..5e39a149ef36 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1584,6 +1584,9 @@ static void
vnlru_kick_cond(void)
{
+ if (vnlru_read_freevnodes() > wantfreevnodes)
+ return;
+
if (vnlruproc_sig)
return;
mtx_lock(&vnode_list_mtx);
@@ -1849,9 +1852,8 @@ vn_alloc_hard(struct mount *mp)
}
alloc:
mtx_assert(&vnode_list_mtx, MA_NOTOWNED);
- rnumvnodes = atomic_fetchadd_long(&numvnodes, 1) + 1;
- if (vnlru_under(rnumvnodes, vlowat))
- vnlru_kick_cond();
+ atomic_add_long(&numvnodes, 1);
+ vnlru_kick_cond();
return (uma_zalloc_smr(vnode_zone, M_WAITOK));
}