Limit mbuma damage. Suddenly ALL allocations with M_WAITOK are subject

to failing -- that is, allocations via malloc(M_WAITOK) that are required
to never fail -- if WITNESS is not defined.  While everyone should be
running WITNESS, in any case, zone "Mbuf" allocations are really the only
ones that should be screwed with by this hack.

This hack is crashing people, and would continue to do so with or without
WITNESS.  Things shouldn't be allocating with M_WAITOK with locks held,
but it's not okay just to always remove M_WAITOK when !WITNESS.

Reported by:	Bernd Walter <ticso@cicely5.cicely.de>
This commit is contained in:
Brian Feldman 2004-07-03 18:11:41 +00:00
parent 279f949ee5
commit cf107c1d1a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131528

View File

@ -1603,7 +1603,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
uma_cache_t cache; uma_cache_t cache;
uma_bucket_t bucket; uma_bucket_t bucket;
int cpu; int cpu;
int badness = 1; int badness = 0;
/* This is the fast path allocation */ /* This is the fast path allocation */
#ifdef UMA_DEBUG_ALLOC_1 #ifdef UMA_DEBUG_ALLOC_1
@ -1613,10 +1613,14 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
if (!(flags & M_NOWAIT)) { if (!(flags & M_NOWAIT)) {
KASSERT(curthread->td_intr_nesting_level == 0, KASSERT(curthread->td_intr_nesting_level == 0,
("malloc(M_WAITOK) in interrupt context")); ("malloc(M_WAITOK) in interrupt context"));
if (strcmp(zone->uz_name, "Mbuf") == 0)
#ifdef WITNESS #ifdef WITNESS
badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
"malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT", NULL,
zone->uz_name); "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
zone->uz_name);
#else
badness = 1;
#endif #endif
if (badness) { if (badness) {
flags &= ~M_WAITOK; flags &= ~M_WAITOK;