Index: sys/vm/uma_core.c =================================================================== --- sys/vm/uma_core.c +++ sys/vm/uma_core.c @@ -3632,6 +3632,10 @@ return (cache_alloc_item(zone, cache, bucket, NULL, flags)); } +#if defined(INVARIANTS) && (defined(DDB) || defined(STACK)) +#include +#endif + /* See uma.h */ void * uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) @@ -3639,6 +3643,31 @@ uma_cache_bucket_t bucket; 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 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); + stack_print(&st); + } + } +#endif + /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);