Page MenuHomeFreeBSD

VFS cache: Export sizeof(struct namecache_ts) in sysctl MIB
AbandonedPublic

Authored by olce on May 2 2025, 8:29 PM.
Tags
None
Referenced Files
F128144126: D50122.id.diff
Mon, Sep 8, 7:26 AM
F128140712: D50122.id.diff
Mon, Sep 8, 6:42 AM
F128126479: D50122.id154719.diff
Mon, Sep 8, 3:06 AM
F128125681: D50122.id154719.diff
Mon, Sep 8, 2:53 AM
Unknown Object (File)
Sun, Sep 7, 5:30 AM
Unknown Object (File)
Thu, Sep 4, 9:56 AM
Unknown Object (File)
Tue, Aug 26, 12:04 AM
Unknown Object (File)
Tue, Aug 12, 12:11 AM
Subscribers

Details

Reviewers
kib
markj
Summary

For analysis purposes.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63842
Build 60726: arc lint + arc unit

Event Timeline

olce requested review of this revision.May 2 2025, 8:29 PM
sys/kern/vfs_cache.c
602

These aren't very useful, as they don't reflect the actual allocation size. That can be obtained from vmstat -z, and more detailed info is under the vm.uma sysctl. It's also easy to get similar info from ctfdump or debug info (e.g. with gdb's ptype/o). Why add yet another thing?

sys/kern/vfs_cache.c
602

Seconded this opinion. Never used the debug.sizeof, gdb 'p/x sizeof(struct)' was enough, and with the pahole support gdb is all what I need.

In fact, it might make sense to remove the whole debug.sizeof subtree to slightly reduce the bloat.

sys/kern/vfs_cache.c
602

At least debug.sizeof.znode is used (by libprocstat, and it's a hack). For compatibility it's probably better to retain them, but again I don't see the value in expanding the tree. We should always prefer to avoid making kernel structure layout visible to userspace.

olce marked 3 inline comments as done.
olce added inline comments.
sys/kern/vfs_cache.c
602

That can be obtained from vmstat -z, and more detailed info is under the vm.uma sysctl.

Then, I'll just give up this revision.

It's also easy to get similar info from ctfdump or debug info (e.g. with gdb's ptype/o). Why add yet another thing?

Oh, simply because it didn't occur to me I could do that. :-) And I didn't know about ptype/o, *very* useful.

At least debug.sizeof.znode is used (by libprocstat, and it's a hack). For compatibility it's probably better to retain them, but again I don't see the value in expanding the tree. We should always prefer to avoid making kernel structure layout visible to userspace.

The point is not to make kernel structure layout visible, but to easily get info on structure sizes, for various reasons (see also the other revisions in this stack). This is in fact what vmstat -z for structures allocated from zones does.

These aren't very useful, as they don't reflect the actual allocation size.

No doubt that all memory allocation mechanisms have overhead. However, not sure why you're saying that, as the size reported by vmstat -z is (unsurprisingly) exactly sizeof(struct) (which includes end of struct padding), and the allocator's overhead doesn't seem to be reported, except for internal fragmentation through the efficiency leaves (which I've just discovered).

sys/kern/vfs_cache.c
602

However, not sure why you're saying that, as the size reported by vmstat -z is (unsurprisingly) exactly sizeof(struct) (which includes end of struct padding),

Note that there is a flexible array at the end of struct namecache. We define two UMA zones for namecache entries, "S VFS Cache" and "L VFS Cache", to reduce internal fragmentation. The former is for "short" paths which represent the common case. The zone size represents the actual allocation size, i.e. sizeof(struct namecache) + name length. Which vmstat -z entry are you looking at?

sys/kern/vfs_cache.c
602

I was looking at struct vm_object and struct vnode as examples when I wrote this. Right, it's best to have the final result than having to do the maths by hand in such cases.