Page MenuHomeFreeBSD

uma: Improve M_USE_RESERVE handling in keg_fetch_slab()
ClosedPublic

Authored by markj on Oct 15 2021, 10:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 23, 8:04 AM
Unknown Object (File)
Thu, May 23, 7:58 AM
Unknown Object (File)
Thu, May 23, 4:47 AM
Unknown Object (File)
Thu, May 23, 3:35 AM
Unknown Object (File)
Mon, May 20, 2:06 AM
Unknown Object (File)
Fri, May 17, 10:32 AM
Unknown Object (File)
Wed, May 15, 7:52 PM
Unknown Object (File)
Apr 5 2024, 10:46 AM
Subscribers

Details

Summary

M_USE_RESERVE is used in a couple of places in the VM to avoid unbounded
recursion when the direct map is not available, as is the case on 32-bit
platforms or when certain kernel sanitizers (KASAN and KMSAN) are
enabled. For example, to allocate KVA, the kernel might allocate a
kernel map entry, which might require a new slab, which requires KVA.

For these zones, we use uma_prealloc() to populate a reserve of items,
and then in certain serialized contexts M_USE_RESERVE can be used to
guarantee a successful allocation. uma_prealloc() allocates the
requested number of items, distributing them evenly among NUMA domains.
Thus, in a first-touch zone, to satisfy an M_USE_RESERVE allocation we
might have to check the slab lists of other domains than the current one
to provide the semantics expected by consumers.

So, try harder to find an item if M_USE_RESERVE is specified and the keg
doesn't have anything for current (first-touch) domain. Specifically,
fall back to a round-robin slab allocation. This change fixes boot-time
panics on NUMA systems with KASAN or KMSAN enabled.

Alternately we could have uma_prealloc() allocate the requested number
of items for each domain, but for some existing consumers this would be
quite wasteful. In general I think keg_fetch_slab() should try harder
to find free slabs in other domains before trying to allocate fresh
ones, but let's limit this to M_USE_RESERVE for now.

Also fix a separate problem that I noticed: in a non-round-robin slab
allocation with M_WAITOK, rather than sleeping after a failed slab
allocation we simply try again. Call vm_wait_domain() before retrying.

Reported by: mjg, tuexen

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42158
Build 39046: arc lint + arc unit

Event Timeline

I'd like to commit this soon, but if there's any interest in reviewing I'm happy to wait.

If you can wait until the weekend, I will look at this then. Weren't there other changes related to replacing preallocation with explicit reservation?

In D32515#737429, @alc wrote:

If you can wait until the weekend, I will look at this then. Weren't there other changes related to replacing preallocation with explicit reservation?

Thank you. There's no real urgency, the problem is limited to kernel sanitizers (which disable UMA_MD_SMALL_ALLOC) and NUMA systems.

I think I made some attempts to merge uma_prealloc() and uma_zone_reserve() but it stalled. That is somewhat orthogonal to this, though, unless I misunderstood.

In D32515#737429, @alc wrote:

If you can wait until the weekend, I will look at this then. Weren't there other changes related to replacing preallocation with explicit reservation?

Thank you. There's no real urgency, the problem is limited to kernel sanitizers (which disable UMA_MD_SMALL_ALLOC) and NUMA systems.

I think I made some attempts to merge uma_prealloc() and uma_zone_reserve() but it stalled. That is somewhat orthogonal to this, though, unless I misunderstood.

I only asked out of curiosity.

This revision is now accepted and ready to land.Nov 1 2021, 1:35 AM