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
Unknown Object (File)
Fri, Mar 29, 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
Unknown Object (File)
Nov 6 2023, 1:05 PM
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

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

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

Need to delete MINBUCKET from PRINT_UMA_ZFLAGS.

head/sys/vm/uma_core.c
509

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

569–571

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

head/sys/vm/uma.h
253

Thanks, will fix.

head/sys/vm/uma_core.c
509

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.