Page MenuHomeFreeBSD

vfs: add VOP_STAT
ClosedPublic

Authored by mjg on Aug 1 2020, 8:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 23, 11:35 AM
Unknown Object (File)
Mon, Mar 18, 6:04 PM
Unknown Object (File)
Sat, Mar 16, 9:41 PM
Unknown Object (File)
Dec 25 2023, 5:07 PM
Unknown Object (File)
Dec 13 2023, 4:01 AM
Unknown Object (File)
Nov 16 2023, 9:46 PM
Unknown Object (File)
Nov 9 2023, 4:31 AM
Unknown Object (File)
Oct 16 2023, 2:14 AM
Subscribers

Details

Reviewers
kib
Group Reviewers
manpages
Commits
rS364044: vfs: add VOP_STAT
Summary

The current scheme of calling VOP_GETATTR adds avoidable overhead.

On Cascade Lake (no meltdown, mds and similar problems) Linux gets the following on tmpfs:
fstat1_processes -t 1 -s 10: average:9299441
fstat1_threads -t 1 -s 10: average:8291153

In contrast, FreeBSD on the same hardware:
fstat1_processes -t 1 -s 10: average:7488958

Patched:
fstat1_processes -t 1 -s 10: average:7913833

[there is no difference for threaded case]

Which mostly catches up to threaded case. Remaining overhead is copying more data and avoidable atomics.

I'll patch other filesystems (zfs and ufs) later.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Aug 1 2020, 8:46 AM
mjg edited the summary of this revision. (Show Details)
sys/fs/tmpfs/tmpfs_vnops.c
458 ↗(On Diff #75242)

Can we avoid having fs to implement both VOP_STAT and VOP_GETATTR if it wants to provide STAT ?

sys/kern/vfs_default.c
1500 ↗(On Diff #75242)

I would argue that post hook should be called regardless of error.

1540 ↗(On Diff #75242)

There

1547 ↗(On Diff #75242)

And there

sys/sys/vnode.h
891 ↗(On Diff #75242)

Why not make them inline functions ?

  • make vop_stat_helper_post mandatory and return an error through it
sys/fs/tmpfs/tmpfs_vnops.c
458 ↗(On Diff #75242)

Not right now unfortunately. GETATTR itself is cheaper to execute and called all the time (e.g., mmap). Most consumers are only looking to get the file size though and other cheaply obtainable subset. I had a WIP patch to implement a stripped down GETATTR which provides only what's needed by mmap/exec/lseek/sendfile. With that in place GETATTR itself would be rare enough that we could retire it and indeed create a wrapper around stat.

sys/sys/vnode.h
891 ↗(On Diff #75242)

audit and mac add to header mess

kib added inline comments.
share/man/man9/VOP_ATTRIB.9
56 ↗(On Diff #75467)

I think it would be better to explicitly note that the VOP is optional and should only be provided when such optimization makes sense.

80 ↗(On Diff #75467)

Perhaps this should be marked as result. Same for VOP_GETATTR.

84 ↗(On Diff #75467)

State that NOCRED should be passed if no fd is.

This revision is now accepted and ready to land.Aug 6 2020, 1:15 PM
This revision was automatically updated to reflect the committed changes.