Page MenuHomeFreeBSD

Add clearing function for unr(9), call it from tmpfs.
ClosedPublic

Authored by mjoras on Oct 4 2017, 6:38 PM.
Tags
None
Referenced Files
F103148535: D12591.diff
Thu, Nov 21, 3:17 PM
Unknown Object (File)
Sun, Nov 3, 8:30 AM
Unknown Object (File)
Fri, Nov 1, 12:55 AM
Unknown Object (File)
Oct 1 2024, 12:26 AM
Unknown Object (File)
Oct 1 2024, 12:26 AM
Unknown Object (File)
Sep 26 2024, 8:12 PM
Unknown Object (File)
Sep 9 2024, 12:29 PM
Unknown Object (File)
Sep 5 2024, 10:21 PM
Subscribers

Details

Summary

Previously before you could call unrhdr_delete you needed to
individually free every allocated unit. It is useful to be able to tear
down the unr without having to go through this process, as it is
significantly faster than freeing the individual units.

When unmounting a tmpfs, do not call free_unr.

tmpfs uses unr(9) to allocate inodes. Previously when unmounting it
would individually free the units when it freed each vnode. This is
unnecessary as we can use the newly-added unrhdr_clear function to clear
out the unr in onde go. This measurably reduces the time to unmount a
tmpfs with many files.

This will be committed as two pieces, one for the unr(9) change, one for the
tmpfs usage change.

Test Plan

I tested this using a kld that uses unr, and I also tested it by repeatedly
extracting a ports tree to a tmpfs and umounting that tmpfs. In my testing
the unmount is sped up from ~.31s to ~.24s, on average. Memory does not
appear to be leaking given the output of vmstat -m | grep Unit

Diff Detail

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

Event Timeline

cem added inline comments.
share/man/man9/unr.9
77 ↗(On Diff #33700)

Sentences should start on their own line in man page format. A suggestion: use igor from ports to check man pages you write/edit; it should flag this.

sys/fs/tmpfs/tmpfs_subr.c
365 ↗(On Diff #33700)

Why does this become conditional?

sys/kern/subr_unit.c
386–387 ↗(On Diff #33700)

Why not move the assert to the top of the routine? It doesn't seem like the rest of the function affects ppfree.

share/man/man9/unr.9
77 ↗(On Diff #33700)

Thanks, I knew I'd commit some sort of manpage faux pas on my first manpage change :).

sys/fs/tmpfs/tmpfs_subr.c
365 ↗(On Diff #33700)

detach -> unmount, so in the unmount case we don't want to bother freeing the unit for every single inode. Instead we clear it out all at once. Should I add a comment? There's basically no comments in tmpfs, it's pretty sad.

sys/fs/tmpfs/tmpfs_subr.c
365 ↗(On Diff #33700)

Ah, that makes sense. Yeah, please add a comment.

  • Fixup manpage.
  • Move KASSERT.

I'd like a comment about the !detach-only free_unr but otherwise LGTM.

mjoras marked 2 inline comments as done.
  • Add comment explaining the conditional free_unr
This revision is now accepted and ready to land.Oct 4 2017, 8:19 PM
This revision was automatically updated to reflect the committed changes.