svn commit: r292117 - in head/sys: kern vm
Mark Johnston
markj at FreeBSD.org
Fri Dec 11 20:05:08 UTC 2015
Author: markj
Date: Fri Dec 11 20:05:07 2015
New Revision: 292117
URL: https://svnweb.freebsd.org/changeset/base/292117
Log:
Don't make assertions about td_critnest when the scheduler is stopped.
A panicking thread always executes with a critical section held, so any
attempt to allocate or free memory while dumping will otherwise cause a
second panic. This can occur, for example, if xpt_polled_action() completes
non-dump I/O that was pending at the time of the panic. The fact that this
can occur is itself a bug, but asserting in this case does little but
reduce the reliability of kernel dumps.
Suggested by: kib
Reported by: pho
Modified:
head/sys/kern/kern_malloc.c
head/sys/vm/uma_core.c
Modified: head/sys/kern/kern_malloc.c
==============================================================================
--- head/sys/kern/kern_malloc.c Fri Dec 11 18:47:41 2015 (r292116)
+++ head/sys/kern/kern_malloc.c Fri Dec 11 20:05:07 2015 (r292117)
@@ -475,8 +475,7 @@ malloc(unsigned long size, struct malloc
if (flags & M_WAITOK)
KASSERT(curthread->td_intr_nesting_level == 0,
("malloc(M_WAITOK) in interrupt context"));
-
- KASSERT(curthread->td_critnest == 0,
+ KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("malloc: called with spinlock or critical section held"));
#ifdef DEBUG_MEMGUARD
@@ -544,8 +543,7 @@ free(void *addr, struct malloc_type *mtp
u_long size;
KASSERT(mtp->ks_magic == M_MAGIC, ("free: bad malloc type magic"));
-
- KASSERT(curthread->td_critnest == 0,
+ KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("free: called with spinlock or critical section held"));
/* free(NULL, ...) does nothing */
@@ -610,8 +608,7 @@ realloc(void *addr, unsigned long size,
KASSERT(mtp->ks_magic == M_MAGIC,
("realloc: bad malloc type magic"));
-
- KASSERT(curthread->td_critnest == 0,
+ KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("realloc: called with spinlock or critical section held"));
/* realloc(NULL, ...) is equivalent to malloc(...) */
Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c Fri Dec 11 18:47:41 2015 (r292116)
+++ head/sys/vm/uma_core.c Fri Dec 11 20:05:07 2015 (r292117)
@@ -2149,8 +2149,7 @@ uma_zalloc_arg(uma_zone_t zone, void *ud
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"uma_zalloc_arg: zone \"%s\"", zone->uz_name);
}
-
- KASSERT(curthread->td_critnest == 0,
+ KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("uma_zalloc_arg: called with spinlock or critical section held"));
#ifdef DEBUG_MEMGUARD
@@ -2690,7 +2689,7 @@ uma_zfree_arg(uma_zone_t zone, void *ite
CTR2(KTR_UMA, "uma_zfree_arg thread %x zone %s", curthread,
zone->uz_name);
- KASSERT(curthread->td_critnest == 0,
+ KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("uma_zfree_arg: called with spinlock or critical section held"));
/* uma_zfree(..., NULL) does nothing, to match free(9). */
More information about the svn-src-head
mailing list