Page MenuHomeFreeBSD

uma: delay bucket_init() until we might actually enable buckets
ClosedPublic

Authored by rlibby on Dec 11 2019, 6:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 10 2024, 9:39 PM
Unknown Object (File)
Dec 20 2023, 5:41 AM
Unknown Object (File)
Dec 7 2023, 2:26 PM
Unknown Object (File)
Nov 10 2023, 6:54 AM
Unknown Object (File)
Nov 8 2023, 8:47 AM
Unknown Object (File)
Nov 8 2023, 6:55 AM
Unknown Object (File)
Nov 8 2023, 6:28 AM
Unknown Object (File)
Nov 6 2023, 10:24 PM
Subscribers

Details

Summary

This helps with a bootstrapping probleming in upcoming work.

We don't first enable buckets until uma_startup2(), so we can delay
bucket creation until then. The other two paths to bucket_enable() are
both later, one in the pageout daemon (SI_SUB_KTHREAD_PAGE vs SI_SUB_VM)
and one in uma_timeout() (first activated in uma_startup3()). Note that
although some bucket functions are accessible before uma_startup2()
(e.g. bucket_select() in zone_ctor()), none of them inspect ubz_zone.

Test Plan

boot

Diff Detail

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

Event Timeline

I think this is probably fine, I can't see any reason bucket zones need to be enabled so early.

sys/vm/uma_core.c
2450 ↗(On Diff #65502)

Is it useful to have separate bucket_init() and _enable() routines at this point?

sys/vm/uma_core.c
2450 ↗(On Diff #65502)

I think so? You mean, "are there other callers", or "do there need to be other callers"? It looks like bucket_enable() may toggle bucketdisable on a running system according to vm conditions, by either uma_timeout() or the pagedaemon via uma_reclaim().

markj added inline comments.
sys/vm/uma_core.c
2450 ↗(On Diff #65502)

Sorry for the noise, I didn't think that question through. I was really just wondering if bucket_init() should call bucket_enable() directly; I can't see why uma_reclaim_lock needs to be initialized first. There are some paths where we lock uma_reclaim_lock only if booted >= BOOT_BUCKETS, but that has nothing to do with buckets per se. It is a minor detail though.

This revision is now accepted and ready to land.Dec 11 2019, 9:31 PM
sys/vm/uma_core.c
2450 ↗(On Diff #65502)

I see. Yeah, it's not about the uma_reclaim_lock, it's about booted = BOOT_BUCKETS. I don't have a strong feeling on the organization there. To move the bucket_enable into bucket_init, I'd either need to revert the new KASSERT or move booted = BOOT_BUCKETS before bucket_init, which may be a little surprising (but I think we are still single-threaded here so I think this is just aesthetics).

Would it maybe read better arranged like so:

sx_init(&uma_reclaim_lock, "umareclaim");
bucket_init();
booted = BOOT_BUCKETS;
bucket_enable();
sys/vm/uma_core.c
2450 ↗(On Diff #65502)

I do find that clearer.

This revision now requires review to proceed.Dec 12 2019, 3:04 AM
This revision is now accepted and ready to land.Dec 12 2019, 3:05 AM