Page MenuHomeFreeBSD

When destroying a UMA zone with a reserve, properly drain kegs
ClosedPublic

Authored by jtl on Nov 6 2020, 9:18 PM.
Tags
None
Referenced Files
F81679472: D27129.diff
Fri, Apr 19, 8:09 PM
Unknown Object (File)
Dec 20 2023, 6:28 AM
Unknown Object (File)
Aug 28 2023, 3:29 AM
Unknown Object (File)
Aug 7 2023, 3:46 AM
Unknown Object (File)
Aug 7 2023, 3:44 AM
Unknown Object (File)
Aug 2 2023, 1:44 AM
Unknown Object (File)
Aug 2 2023, 1:30 AM
Unknown Object (File)
Jul 6 2023, 1:51 PM
Subscribers

Details

Summary

When destroying a UMA zone which has a reserve (set with uma_zone_reserve()), messages like the following appear on the console:

Freed UMA keg (Test zone) was not empty (0 items). Lost 528 pages of memory.

When keg_drain_domain() is draining the zone, it tries to keep the number of items specified in the reservation. However, when we are destroying the UMA zone, we do not need to keep those items. Therefore, when destroying a non-secondary and non-cache zone, we should reset the keg reservation to 0 prior to draining the zone.

Test Plan

The following sequence produces the error message before the change, and does not after the change:

testzone = uma_zcreate("Test zone", 33 * 4096, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
uma_zone_reserve(testzone, 16);
uma_prealloc(testzone, 16);
uma_zdestroy(testzone);

Diff Detail

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