git: 23ef25d25d98 - main - vfs: consult freevnodes in vnlru_kick_cond
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Oct 2023 16:29:50 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=23ef25d25d989e7213bc1d3ef32b0f48a9eb2537
commit 23ef25d25d989e7213bc1d3ef32b0f48a9eb2537
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-10-10 16:19:53 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-10-10 16:19:53 +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")
---
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 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));
}