summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2004-07-03 18:11:41 +0000
committergreen <green@FreeBSD.org>2004-07-03 18:11:41 +0000
commitb003469f2d60f4e55251c1d5c00a0ce3c3252274 (patch)
tree32cc2d1c30aee55286b621470379ae89a581b15e
parentabeab8c454bcc24224bdda73a39102aa0a5c0ca0 (diff)
downloadFreeBSD-src-b003469f2d60f4e55251c1d5c00a0ce3c3252274.zip
FreeBSD-src-b003469f2d60f4e55251c1d5c00a0ce3c3252274.tar.gz
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>
-rw-r--r--sys/vm/uma_core.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index d49deea..1012df5 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1603,7 +1603,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
uma_cache_t cache;
uma_bucket_t bucket;
int cpu;
- int badness = 1;
+ int badness = 0;
/* This is the fast path allocation */
#ifdef UMA_DEBUG_ALLOC_1
@@ -1613,10 +1613,14 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
if (!(flags & M_NOWAIT)) {
KASSERT(curthread->td_intr_nesting_level == 0,
("malloc(M_WAITOK) in interrupt context"));
+ if (strcmp(zone->uz_name, "Mbuf") == 0)
#ifdef WITNESS
- badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
- "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
- zone->uz_name);
+ badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
+ NULL,
+ "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
+ zone->uz_name);
+#else
+ badness = 1;
#endif
if (badness) {
flags &= ~M_WAITOK;
OpenPOWER on IntegriCloud