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:
74be676d87 ("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")
This commit is contained in:
Mateusz Guzik
2023-10-10 16:19:53 +00:00
parent 1bf55a739e
commit 23ef25d25d
+5 -3
View File
@@ -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));
}