summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2004-07-04 16:07:44 +0000
committerbmilekic <bmilekic@FreeBSD.org>2004-07-04 16:07:44 +0000
commitdf84cdbe06ddfd60e172e2f3d7ee2f7541c16f67 (patch)
tree0728b0e905a3f5e4cdf62a186f6e67d1bf7d89c4
parent77ef401fc60964c4edacb0a34bd820a3d426491d (diff)
downloadFreeBSD-src-df84cdbe06ddfd60e172e2f3d7ee2f7541c16f67.zip
FreeBSD-src-df84cdbe06ddfd60e172e2f3d7ee2f7541c16f67.tar.gz
Introduce debug.nosleepwithlocks sysctl, 0 by default. If set to 1
and WITNESS is not built, then force all M_WAITOK allocations to M_NOWAIT behavior (transparently). This is to be used temporarily if wierd deadlocks are reported because we still have code paths that perform M_WAITOK allocations with lock(s) held, which can lead to deadlock. If WITNESS is compiled, then the sysctl is ignored and we ask witness to tell us wether we have locks held, converting to M_NOWAIT behavior only if it tells us that we do. Note this removes the previous mbuf.h inclusion as well (only needed by last revision), and cleans up unneeded [artificial] comparisons to just the mbuf zones. The problem described above has nothing to do with previous mbuf wait behavior; it is a general problem.
-rw-r--r--sys/vm/uma_core.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 9e1f7d4..4b25a1b 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -68,7 +68,6 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/smp.h>
#include <sys/vmmeter.h>
-#include <sys/mbuf.h> /* XXX WITNESS_WARN() hack */
#include <vm/vm.h>
#include <vm/vm_object.h>
@@ -225,6 +224,9 @@ void uma_print_zone(uma_zone_t);
void uma_print_stats(void);
static int sysctl_vm_zone(SYSCTL_HANDLER_ARGS);
+static int nosleepwithlocks = 0;
+SYSCTL_INT(_debug, OID_AUTO, nosleepwithlocks, CTLFLAG_RW, &nosleepwithlocks,
+ 0, "Convert M_WAITOK to M_NOWAIT to avoid lock-held-across-sleep paths");
SYSCTL_OID(_vm, OID_AUTO, zone, CTLTYPE_STRING|CTLFLAG_RD,
NULL, 0, sysctl_vm_zone, "A", "Zone Info");
SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, uma_startup3, NULL);
@@ -1603,7 +1605,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
uma_cache_t cache;
uma_bucket_t bucket;
int cpu;
- int badness = 0;
+ int badness;
/* This is the fast path allocation */
#ifdef UMA_DEBUG_ALLOC_1
@@ -1613,16 +1615,12 @@ 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 ((zone_mbuf != NULL && zone == zone_mbuf) ||
- (zone_clust != NULL && zone == zone_clust) ||
- (zone_pack != NULL && zone == zone_pack))
+ badness = nosleepwithlocks;
#ifdef WITNESS
- badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
- NULL,
- "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
- zone->uz_name);
-#else
- badness = 1;
+ badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
+ NULL,
+ "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
+ zone->uz_name);
#endif
if (badness) {
flags &= ~M_WAITOK;
OpenPOWER on IntegriCloud