locks under printf(9) and WITNESS = panic?

Andriy Gapon avg at FreeBSD.org
Fri Jul 12 08:56:15 UTC 2013


on 11/07/2013 23:21 John Baldwin said the following:
> On Saturday, June 29, 2013 9:19:24 pm Steven Hartland wrote:
>> when booting stable/9 under a debug kernel with WITNESS
>> enabled and verbose I get the following panic..
>>
>> It seems very much like the discussion from a year back on
>> current: http://lists.freebsd.org/pipermail/freebsd-current/2012-
> January/031375.html
>>
>> Any ideas?
> 
> Yeah, that lock needs to be MTX_RECURSE (the cnputs_mtx).  However, it
> only recurses under witness.  *sigh*
> 

In my tree I have this commit:

commit 9ef2a49ec43e6ebf429e4dae3bf230a09ae106f1
Author: Andriy Gapon <avg at icyb.net.ua>
Date:   Fri May 18 12:58:13 2012 +0300

    [test] mark all locks in printf(9) call tree as no-witness

    ... to avoid warnings because of complex interactions between printf(9)
    being called from arbitrary contexts and syscons code making non-trivial
    calls into other subsystems (e.g. callout) for terminal emulation
    purposes.
    And also secondary problems resulting from witness(9) using printf(9)
    to warn about problem in the latter and thus causing its recursion.

diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index bfbbff7..8539d27 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -3299,7 +3299,7 @@ init_scp(sc_softc_t *sc, int vty, scr_stat *scp)
     scp->history_pos = 0;
     scp->history_size = 0;

-    mtx_init(&scp->scr_lock, "scrlock", NULL, MTX_SPIN);
+    mtx_init(&scp->scr_lock, "scrlock", NULL, MTX_SPIN | MTX_NOWITNESS);
 }

 int
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 353b67f..fbe20f0 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -537,7 +537,7 @@ typedef struct {

 #define SC_VIDEO_LOCKINIT(sc)						\
 		mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,	\
-		    MTX_SPIN | MTX_RECURSE);
+		    MTX_SPIN | MTX_RECURSE | MTX_NOWITNESS);
 #define SC_VIDEO_LOCK(sc)						\
 		do {							\
 			if (!cold)					\
diff --git a/sys/dev/uart/uart_core.c b/sys/dev/uart/uart_core.c
index b6bed03..8396f7a 100644
--- a/sys/dev/uart/uart_core.c
+++ b/sys/dev/uart/uart_core.c
@@ -413,7 +413,7 @@ uart_bus_attach(device_t dev)
 	 */
 	sc->sc_leaving = 1;

-	mtx_init(&sc->sc_hwmtx_s, "uart_hwmtx", NULL, MTX_SPIN);
+	mtx_init(&sc->sc_hwmtx_s, "uart_hwmtx", NULL, MTX_SPIN | MTX_NOWITNESS);
 	if (sc->sc_hwmtx == NULL)
 		sc->sc_hwmtx = &sc->sc_hwmtx_s;

diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 02ad77a..9ee7e1e 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -632,7 +632,6 @@ static struct witness_order_list_entry order_lists[] = {
 #endif
 	{ "rm.mutex_mtx", &lock_class_mtx_spin },
 	{ "sio", &lock_class_mtx_spin },
-	{ "scrlock", &lock_class_mtx_spin },
 #ifdef __i386__
 	{ "cy", &lock_class_mtx_spin },
 #endif
@@ -641,7 +640,6 @@ static struct witness_order_list_entry order_lists[] = {
 	{ "rtc_mtx", &lock_class_mtx_spin },
 #endif
 	{ "scc_hwmtx", &lock_class_mtx_spin },
-	{ "uart_hwmtx", &lock_class_mtx_spin },
 	{ "fast_taskqueue", &lock_class_mtx_spin },
 	{ "intr table", &lock_class_mtx_spin },
 #ifdef	HWPMC_HOOKS
@@ -657,7 +655,6 @@ static struct witness_order_list_entry order_lists[] = {
 	{ "td_contested", &lock_class_mtx_spin },
 	{ "callout", &lock_class_mtx_spin },
 	{ "entropy harvest mutex", &lock_class_mtx_spin },
-	{ "syscons video lock", &lock_class_mtx_spin },
 #ifdef SMP
 	{ "smp rendezvous", &lock_class_mtx_spin },
 #endif


-- 
Andriy Gapon


More information about the freebsd-stable mailing list