Page MenuHomeFreeBSD

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

Authored by jeff on Tue, Nov 26, 10:22 PM.

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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jeff created this revision.Tue, Nov 26, 10:22 PM
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..Tue, Nov 26, 10:25 PM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: markj, rlibby.
markj added a comment.Wed, Nov 27, 4:11 PM

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
684 ↗(On Diff #64918)

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.

jeff added inline comments.Wed, Nov 27, 8:49 PM
sys/kern/kern_malloc.c
684 ↗(On Diff #64918)

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.

markj added inline comments.Wed, Nov 27, 10:11 PM
sys/kern/kern_malloc.c
684 ↗(On Diff #64918)

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..Wed, Nov 27, 11:01 PM
jeff updated this revision to Diff 64982.Wed, Nov 27, 11:02 PM

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

markj accepted this revision.Thu, Nov 28, 7:26 PM
markj added inline comments.
sys/kern/kern_malloc.c
663 ↗(On Diff #64982)

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

692 ↗(On Diff #64982)

Missing space after ret.

This revision is now accepted and ready to land.Thu, Nov 28, 7:26 PM
markj added inline comments.Thu, Nov 28, 8:21 PM
sys/kern/kern_malloc.c
663 ↗(On Diff #64982)

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