locks under printf(9) and WITNESS [Was: new panic in cpu_reset() with WITNESS]

Andriy Gapon avg at FreeBSD.org
Mon Jan 23 13:59:41 UTC 2012

on 23/01/2012 15:04 Gleb Smirnoff said the following:
> On Sat, Jan 21, 2012 at 07:26:55PM +0200, Andriy Gapon wrote:
> A> > BTW, we have a quite strange situation with spin locks in console output path.
> A> > cnputs_mtx is marked as MTX_NOWITNESS, supposedly because cnputs (printf) can be
> A> > called in any locking context (even during normal operation).  But there are a
> A> > number of console-specific locks (scrlock, uart_hwmtx, "syscons video lock")
> A> > which are acquired under cnputs_mtx, but which are *not* marked as
> A> > MTX_NOWITNESS.  More, they are specified in the witness order_lists as if we
> A> > certainly know a correct order for them.
> A> > I think that the msgbuf mutex also deserves mentioning in this context.
> A> > 
> A> > I think that all of these spin locks should be marked as MTX_NOWITNESS (as long
> A> > as they stay normal spinlocks), because printf(9) should be usable wherever I
> A> > stick it in the code.
> A> > 
> A> > P.S. The above only matters for WITNESS and !WITNESS_SKIPSPIN and I am not sure
> A> > if this combination really matters.
> A> > 
> A> 
> A> Here's my take at it:
> A> diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c
> A> index 5346bc3..97f0f16 100644
> ...
> This patch works.

Thank you for testing!

Andriy Gapon

More information about the freebsd-current mailing list