Skip to content

Commit

Permalink
vfs: consult freevnodes in vnlru_kick_cond
Browse files Browse the repository at this point in the history
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:
74be676 ("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")
  • Loading branch information
mjguzik committed Oct 10, 2023
1 parent 1bf55a7 commit 23ef25d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sys/kern/vfs_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit 23ef25d

Please sign in to comment.