Page MenuHomeFreeBSD

Add a statistic to track the number of times a vnode is recycled.
ClosedPublic

Authored by jhb on Jan 25 2015, 8:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 22, 10:52 PM
Unknown Object (File)
Jan 23 2025, 5:32 AM
Unknown Object (File)
Jan 23 2025, 5:03 AM
Unknown Object (File)
Jan 14 2025, 7:10 PM
Unknown Object (File)
Dec 22 2024, 11:25 PM
Unknown Object (File)
Dec 18 2024, 4:11 AM
Unknown Object (File)
Dec 18 2024, 3:21 AM
Unknown Object (File)
Nov 23 2024, 3:05 PM
Subscribers

Details

Summary

AFAIK, there is not currently a way to easily tell if a system is
actively recycling vnodes, or how quickly it is being forced to do so.
In particular, on some workloads, constant recycling is a sign that
the system needs maxvnodes bumped (assuming there is sufficient RAM
available). I think that issue is less pressing now that maxvnodes no
longer has an artifically low cap of 100000 vnodes, but I think this
stat is still useful.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

jhb retitled this revision from to Add a statistic to track the number of times a vnode is recycled..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: kib.

The patch definitely not count all recycle events. It even does not count the number of recycles initiated by the vnlru_proc. Note that vnlru performs calls vnlru_free()->vtryrecycle()->vgonel() (which you count) and vlrureclaim()->vgonel(), both of which recycle a vnode.

So if your goal is to account recycles initiated by daemon or vnode shortage at the getnewvnode() time, then at least one more place, in vlrureclaim(), must be handled. If you want to account all recycles, including events such as inactivation of the unlinked vnode or unmounts, it is simpler to do it in vgonel() or even adding post handler for VOP_RECYCLE.

Which do you think is more useful? My guess is that it is probably best to be as simple as possible and just count all recycles, but recycles due to unlink or unmount might indeed by noisy.

In D1671#5, @jhb wrote:

Which do you think is more useful? My guess is that it is probably best to be as simple as possible and just count all recycles, but recycles due to unlink or unmount might indeed by noisy.

IMO the original stated intent, count the reclamations due to vnode deficit, is more interesting than overall vnode reclamation. As far as I see, your patch needs one more atomic_add_long() in the vlrureclaim().

That said, did you considered counting the vnode creation events instead, or in addition to the reclamation due to the vnodes shortage ? It is very easy to do, the only vnode constructor is getnewvnode(9). The graphs of numvnodes + getnewvnode calls counter would probably provide the same information.

Ok. I can always add both counters?

jhb edited edge metadata.
  • Count recycles in vlrureclaim().
  • Add counter for calls to getnewvnodes().
sys/kern/vfs_subr.c
164

Is this mib RW on purpose ?

1000

I think we must only count when vgonel() call is performed, i.e. under the if() branch.

1082

Althought this is currently not enabled, getnewvnode() was designed to allow fail.
Please move the increment after the alloc label, so that return (error) statement in the #if 0-block is still 'honored'.

sys/kern/vfs_subr.c
164

Eh, hmm. Some stat nodes are RW to allow them to be zero'd, but it looks like most of the VFS ones are read-only (though reassignbufcalls is RW). I'll switch it to read-only.

1000

Agreed, I almost made that change but talked myself out of it.

1082

Done. I've updated the counter's description to note that it only counts calls that succeed as well. Not sure if the name should also be changed from 'getnewvnode_calls' to 'getnewvnode_<mumble>' as well? (Can't think of a decent <mumble> off the top of my head) Maybe 'vnodes_allocated'?

kib edited edge metadata.
kib added inline comments.
sys/kern/vfs_subr.c
126

Might be , vnodes_created ?

This revision is now accepted and ready to land.Feb 6 2015, 4:31 PM
jhb edited edge metadata.

Rename to vnodes_created.

This revision now requires review to proceed.Feb 6 2015, 5:19 PM
sys/kern/vfs_subr.c
126

Ok.

kib edited edge metadata.
This revision is now accepted and ready to land.Feb 6 2015, 5:40 PM
jhb updated this revision to Diff 3766.

Closed by commit rS278760 (authored by @jhb).