Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_malloc.c
Show First 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | if ((flags & M_NOWAIT) && (malloc_failure_rate != 0)) { | ||||
atomic_add_int(&malloc_nowait_count, 1); | atomic_add_int(&malloc_nowait_count, 1); | ||||
if ((malloc_nowait_count % malloc_failure_rate) == 0) { | if ((malloc_nowait_count % malloc_failure_rate) == 0) { | ||||
atomic_add_int(&malloc_failure_count, 1); | atomic_add_int(&malloc_failure_count, 1); | ||||
t_malloc_fail = time_uptime; | t_malloc_fail = time_uptime; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
if (flags & M_WAITOK) | |||||
KASSERT(curthread->td_intr_nesting_level == 0, | KASSERT(curthread->td_intr_nesting_level == 0, | ||||
("malloc(M_WAITOK) in interrupt context")); | ("malloc in interrupt context")); | ||||
if (flags & M_WAITOK) | |||||
KASSERT_WARN(THREAD_CAN_SLEEP(), | |||||
("malloc(M_WAITOK) in no_sleeping context")); | |||||
#ifdef DEBUG_MEMGUARD | #ifdef DEBUG_MEMGUARD | ||||
if (memguard_cmp_mtp(mtp, size)) { | if (memguard_cmp_mtp(mtp, size)) { | ||||
va = memguard_alloc(size, flags); | va = memguard_alloc(size, flags); | ||||
if (va != NULL) | if (va != NULL) | ||||
return (va); | return (va); | ||||
/* This is unfortunate but should not be fatal. */ | /* This is unfortunate but should not be fatal. */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 622 Lines • Show Last 20 Lines |