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
F83050735: D12591.id33701.diff
Sun, May 5, 2:33 PM
Unknown Object (File)
Sat, May 4, 10:27 AM
Unknown Object (File)
Fri, May 3, 12:35 AM
Unknown Object (File)
Mon, Apr 29, 10:38 PM
Unknown Object (File)
Mon, Apr 29, 10:38 PM
Unknown Object (File)
Mon, Apr 29, 5:14 PM
Unknown Object (File)
Mon, Apr 29, 1:27 AM
Unknown Object (File)
Sat, Apr 27, 3:19 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 Passed
Unit
No Test Coverage
Build Status
Buildable 11890
Build 12225: arc lint + arc unit

Event Timeline

cem added inline comments.
share/man/man9/unr.9
77

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

Why does this become conditional?

sys/kern/subr_unit.c
386–387

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

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

sys/fs/tmpfs/tmpfs_subr.c
365

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

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.