Page MenuHomeFreeBSD

Export some UMA info via sysctl.
ClosedPublic

Authored by markj on Jun 4 2019, 3:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 6:13 PM
Unknown Object (File)
Sat, Nov 2, 8:33 PM
Unknown Object (File)
Fri, Nov 1, 5:19 PM
Unknown Object (File)
Oct 21 2024, 1:41 AM
Unknown Object (File)
Oct 12 2024, 10:31 AM
Unknown Object (File)
Oct 11 2024, 2:49 AM
Unknown Object (File)
Oct 6 2024, 11:39 PM
Unknown Object (File)
Oct 4 2024, 8:34 PM
Subscribers

Details

Summary

These show the total amount of memory used for UMA slabs, and the limit
on such memory.

Diff Detail

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

Event Timeline

sys/vm/uma_core.c
148 ↗(On Diff #58228)

Is uma_kmem_limit also something that ought to be accessed and modified atomically?

151 ↗(On Diff #58228)

Consider making the initial value of 0 explicit here.

sys/vm/uma_core.c
3813 ↗(On Diff #58228)

Why do you need this atomic ? Esp. since sysctl handler would not use volatile qualification.

sys/vm/uma_core.c
148 ↗(On Diff #58228)

I don't think it's necessary: currently it's set only once, during boot time.

151 ↗(On Diff #58228)

Hmm, conventionally we omit the explicit zero-initialization when the variable is initialized later (early during boot in this case). For, e.g., a sysctl setting where 0 means off (default) and 1 means on, I would use an explicit initializer of 0.

3813 ↗(On Diff #58228)

I did it because I removed the volatile qualifier from the var. All of its other accesses are via atomic_* so I prefer to be consistent here.

sys/vm/uma_core.c
148 ↗(On Diff #58228)

Because uma_set_limit is called only once, during boot time. Maybe a comment somewhere should explain that.

So why initialize to LONG_MAX? Why not just

static unslgned long uma_kmem_limit; /* initialized by uma_set_limit(). */

sys/vm/uma_core.c
148 ↗(On Diff #58228)

I will add a comment.

We initialize to LONG_MAX so that UMA allocations can succeed before uma_set_limit() is called. If it were initialized to zero, such allocations would always fail because uma_avail() would return zero.

kib added inline comments.
sys/vm/uma_core.c
3813 ↗(On Diff #58228)

As I noted, sysctl would not access it as volatile.

This revision is now accepted and ready to land.Jun 4 2019, 4:59 PM
sys/vm/uma_core.c
3813 ↗(On Diff #58228)

Sorry, I see. The change is indeed unrelated to my original purpose of adding sysctls. I will commit that part separately.

Add a comment for uma_kmem_limit.

This revision now requires review to proceed.Jun 4 2019, 7:35 PM
markj marked an inline comment as done.Jun 4 2019, 7:37 PM
markj added inline comments.
sys/vm/uma_core.c
148 ↗(On Diff #58228)

Sorry, I misremembered. The allocations won't fail, but we'll erroneously wake up the UMA reclaim thread. See r327485.

This revision is now accepted and ready to land.Jun 4 2019, 7:37 PM
This revision was automatically updated to reflect the committed changes.