Page MenuHomeFreeBSD

Don't bother freeing UMA zones after the shutdown process starts.
ClosedPublic

Authored by markj on Jan 7 2020, 4:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 22 2023, 10:57 PM
Unknown Object (File)
Sep 25 2023, 3:12 PM
Unknown Object (File)
Aug 8 2023, 5:53 PM
Unknown Object (File)
Jul 12 2023, 1:39 AM
Unknown Object (File)
May 14 2023, 6:45 PM
Unknown Object (File)
Apr 25 2023, 7:04 PM
Unknown Object (File)
Apr 25 2023, 5:14 AM
Unknown Object (File)
Jan 10 2023, 12:20 AM
Subscribers

Details

Summary

Some kernel subsystems, notably ZFS, will destroy UMA zones from a
shutdown eventhandler. For slabs that are mapped into KVA this can be
very expensive and so it needlessly delays the shutdown process.

Add a new state to the "booted" variable, BOOT_SHUTDOWN. Once
kern_reboot() starts invoking shutdown handlers, turn uma_zdestroy()
into a no-op. In the future I plan to implement periodic preening of
cached items in excess of the WSS, which would alleviate the problem
somewhat, but this patch is simple and can be backported to the stable
branches.

PR: 242427

Test Plan

I wrote a kernel module that creates a zone, allocates and frees ~2 million items,
and then destroys the zone to trigger reclamation. With a slab size of 4096,
uma_zdestroy() takes about half a second to complete, whereas with a slab size
of 8192 it takes about 16 seconds.

Diff Detail

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

Event Timeline

markj edited the test plan for this revision. (Show Details)
markj added reviewers: jeff, kib, rlibby.
sys/vm/uma_core.c
2830 ↗(On Diff #66443)

We could have a debug tunable to disable this behaviour.

This revision is now accepted and ready to land.Jan 7 2020, 5:11 PM

Code looks good.

Should we maybe gate this on whether the zone defines a zfini or zrelease function? I'm a little concerned that it could be possible for a client to be affected by that difference. Then if a client defines one but really wants to leak anyway, it can always leak on its own.

Code looks good.

Should we maybe gate this on whether the zone defines a zfini or zrelease function? I'm a little concerned that it could be possible for a client to be affected by that difference. Then if a client defines one but really wants to leak anyway, it can always leak on its own.

Yes, I think that makes sense. Perhaps a non-default uk_freef should also prevent this short-circuiting.

I don't think a client can really do anything from zfini since it doesn't have a return value.

Apply rlibby's suggestion.

This revision now requires review to proceed.Jan 8 2020, 4:37 PM
This revision is now accepted and ready to land.Jan 8 2020, 5:40 PM