git: 7ec19caae5b0 - stable/13 - vfs: consult freevnodes in vnlru_kick_cond
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Oct 2023 23:53:54 UTC
The branch stable/13 has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=7ec19caae5b0044da963298d4ae79cfcf3ebaf01
commit 7ec19caae5b0044da963298d4ae79cfcf3ebaf01
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-10-10 16:19:53 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-10-13 23:48:13 +0000
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)
---
sys/kern/vfs_subr.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 29b255b418e4..5ddbff77a221 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1601,6 +1601,9 @@ static void
vnlru_kick_cond(void)
{
+ if (vnlru_read_freevnodes() > wantfreevnodes)
+ return;
+
if (vnlruproc_sig)
return;
mtx_lock(&vnode_list_mtx);
@@ -1867,9 +1870,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));
}