Page MenuHomeFreeBSD

uma: Enforce the use of uz_bucket_size_max in the free path
ClosedPublic

Authored by markj on Nov 10 2020, 10:27 PM.
Tags
None
Referenced Files
F82723328: D27167.diff
Thu, May 2, 12:19 AM
Unknown Object (File)
Mar 29 2024, 8:51 AM
Unknown Object (File)
Dec 26 2023, 3:53 AM
Unknown Object (File)
Dec 22 2023, 11:22 PM
Unknown Object (File)
Dec 14 2023, 8:24 PM
Unknown Object (File)
Nov 26 2023, 7:09 AM
Unknown Object (File)
Nov 8 2023, 1:05 PM
Unknown Object (File)
Nov 7 2023, 12:03 AM
Subscribers

Details

Summary

uz_bucket_size_max is the maximum permitted bucket size. When filling a
new bucket to satisfy uma_zalloc(), the bucket is populated with at most
uz_bucket_size_max items. The maximum number of entries in the bucket
may be larger. When freeing items, however, we will fill per-CPPU
buckets up to their maximum number of entries, potentially exceeding
uz_bucket_size_max. This makes it difficult to precisely limit the
number of items that may be cached in a zone. For example, if I want
limit buckets to 1 entry in a particular zone, that's not possible since
the smallest bucket holds up to 2 entries.

Try to solve the problem by using uz_bucket_size_max to limit the number
of entries in a bucket. Note that the ub_entries field is initialized
upon every bucket allocation. Most zones are not affected since they do
not impose any hard limit on the maximum bucket size.

While here, remove the UMA_ZONE_MINBUCKET flag. It was unused and we
now have uma_zone_set_maxcache() to control the zone's cache size more
precisely.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34730
Build 31786: arc lint + arc unit

Event Timeline

markj created this revision.
This revision was not accepted when it landed; it landed in state Needs Review.Dec 6 2020, 10:46 PM
This revision was automatically updated to reflect the committed changes.

Limiting the actual bucket size makes sense to me.

head/sys/vm/uma.h
253 ↗(On Diff #80393)

Need to delete MINBUCKET from PRINT_UMA_ZFLAGS.

head/sys/vm/uma_core.c
509 ↗(On Diff #80393)

This is the only atomic access to uz_bucket_size. Is it important? ...

569–571 ↗(On Diff #80393)

(uz_bucket_size accessed without atomic and an explicit comment saying we don't care)

head/sys/vm/uma.h
253 ↗(On Diff #80393)

Thanks, will fix.

head/sys/vm/uma_core.c
509 ↗(On Diff #80393)

Hmm, right, I'd forgotten that we permit racy updates of uz_bucket_size now. I can't remember what led me to think that using an atomic load here was necessary.