Page MenuHomeFreeBSD

Handle large mallocs by going directly to kmem without taking a detour through uma zones.
ClosedPublic

Authored by jeff on Nov 26 2019, 10:22 PM.
Tags
None
Referenced Files
F81657048: D22563.diff
Fri, Apr 19, 1:44 PM
Unknown Object (File)
Dec 29 2023, 10:51 AM
Unknown Object (File)
Dec 20 2023, 7:05 AM
Unknown Object (File)
Aug 28 2023, 10:09 AM
Unknown Object (File)
Aug 28 2023, 10:04 AM
Unknown Object (File)
Aug 28 2023, 10:02 AM
Unknown Object (File)
Aug 28 2023, 10:00 AM
Unknown Object (File)
Aug 28 2023, 9:38 AM
Subscribers

Details

Summary

In retrospect I don't know why i didn't do this in the first place. Rather than putting a slab in vtoslab() just so we can figure out what size the thing was, stuff the size and a special bit in the 'slab' pointer in the page. We can drop the slab allocation entirely.

I can do something similar for large zone sizes later.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27823
Build 26002: arc lint + arc unit

Event Timeline

jeff retitled this revision from Handle large mallocs by going directly to kmem without taking a detour through uma zones. to Handle large mallocs by going directly to kmem without taking a detourthrough uma zones..Nov 26 2019, 10:25 PM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: markj, rlibby.

I guess using UMA made more sense when KVA was still allocated directly from the vm_map instead of vmem?

sys/kern/kern_malloc.c
673

I don't think this behaviour from uma_large_malloc_domain() needs to be carried over. malloc_domain() is only called from malloc_domainset(); callers of malloc_domainset() must use _PREF to avoid failures caused by empty domains.

Actually this is all a big strange: malloc_domainset() is extracting a domain from a policy, and here we're converting it back to a policy. I think malloc_large() can change to use kmem_malloc_domain() instead. Otherwise we are running two iterators at different layers.

sys/kern/kern_malloc.c
673

It is a bit silly but uma_zalloc_domain is not uma_zalloc_domainset().

We could make such a thing and then collapse this. Or I could detect that the allocation should go to large in malloc_domainset() and bypass it.

sys/kern/kern_malloc.c
673

I don't quite understand your first sentence. It would make most sense to me for malloc_large() to call kmem_malloc_domain().

jeff retitled this revision from Handle large mallocs by going directly to kmem without taking a detourthrough uma zones. to Handle large mallocs by going directly to kmem without taking a detour through uma zones..Nov 27 2019, 11:01 PM

Handle domain iterators differently. Make sure large sizes are recorded
correctly in malloc stats. Eliminate false failures from domain specific
allocations.

markj added inline comments.
sys/kern/kern_malloc.c
663

The M_EXEC flag restriction seems kind of arbitrary? I don't think it will break anything in the tree though.

692

Missing space after ret.

This revision is now accepted and ready to land.Nov 28 2019, 7:26 PM
sys/kern/kern_malloc.c
663

Sorry, I misunderstood. The caller must go through malloc_large() instead.