Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/uma_core.c
Show First 20 Lines • Show All 3,626 Lines • ▼ Show 20 Lines | #endif | ||||
critical_enter(); | critical_enter(); | ||||
cache = &zone->uz_cpu[curcpu]; | cache = &zone->uz_cpu[curcpu]; | ||||
bucket = &cache->uc_allocbucket; | bucket = &cache->uc_allocbucket; | ||||
if (__predict_false(bucket->ucb_cnt == 0)) | if (__predict_false(bucket->ucb_cnt == 0)) | ||||
return (cache_alloc_retry(zone, cache, NULL, flags)); | return (cache_alloc_retry(zone, cache, NULL, flags)); | ||||
return (cache_alloc_item(zone, cache, bucket, NULL, flags)); | return (cache_alloc_item(zone, cache, bucket, NULL, flags)); | ||||
} | } | ||||
#if defined(INVARIANTS) && (defined(DDB) || defined(STACK)) | |||||
#include <sys/stack.h> | |||||
#endif | |||||
/* See uma.h */ | /* See uma.h */ | ||||
void * | void * | ||||
uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) | uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) | ||||
{ | { | ||||
uma_cache_bucket_t bucket; | uma_cache_bucket_t bucket; | ||||
uma_cache_t cache; | uma_cache_t cache; | ||||
_Static_assert(M_NOWAIT != 0 && M_WAITOK != 0, | |||||
"M_NOWAIT and M_WAITOK must be non-zero for this assertion:"); | |||||
#if 0 | |||||
/* | |||||
* Give people time to find problems with the #else option below, | |||||
* then enable this instead. (Remove <sys/stack.h> above, too.) | |||||
*/ | |||||
KASSERT((flags & (M_NOWAIT|M_WAITOK)) == M_NOWAIT || | |||||
(flags & (M_NOWAIT|M_WAITOK)) == M_WAITOK, | |||||
("uma_zalloc_arg: must pass exactly one of M_NOWAIT or M_WAITOK")); | |||||
#elif defined(INVARIANTS) && (defined(DDB) || defined(STACK)) | |||||
if (__predict_false((flags & (M_NOWAIT|M_WAITOK)) != M_NOWAIT && | |||||
(flags & (M_NOWAIT|M_WAITOK)) != M_WAITOK)) { | |||||
static int stack_count; | |||||
struct stack st; | |||||
if (stack_count < 10) { | |||||
++stack_count; | |||||
printf("uma_zalloc_arg called with bad WAIT flags:\n"); | |||||
stack_save(&st); | |||||
vangyzen: I love the irony of hard-coding M_WAITOK here. | |||||
Done Inline ActionsDo we actually have to allocate one here? I thought that struct stack was small enough to be safe to be allocated directly from the stack. rstone: Do we actually have to allocate one here? I thought that struct stack was small enough to be… | |||||
Done Inline ActionsNo, we don't. Contrary to the little voice in my head, I tried using this KPI by reading _only the man page_, which clearly says stack_create is required. The src tree tells a different story, where only 1 out of 24 instances uses stack_create. From now on, I'll listen to the voices in my head. No...wait... D34461 updates the man page. vangyzen: No, we don't. Contrary to the little voice in my head, I tried using this KPI by reading _only… | |||||
stack_print(&st); | |||||
} | |||||
} | |||||
#endif | |||||
/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ | /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ | ||||
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA); | random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA); | ||||
/* This is the fast path allocation */ | /* This is the fast path allocation */ | ||||
CTR3(KTR_UMA, "uma_zalloc_arg zone %s(%p) flags %d", zone->uz_name, | CTR3(KTR_UMA, "uma_zalloc_arg zone %s(%p) flags %d", zone->uz_name, | ||||
zone, flags); | zone, flags); | ||||
▲ Show 20 Lines • Show All 2,227 Lines • Show Last 20 Lines |
I love the irony of hard-coding M_WAITOK here.