Subject: kprintf locking problem.
To: None <tech-smp@netbsd.org>
From: Anders Magnusson <ragge@ludd.luth.se>
List: tech-smp
Date: 06/03/2001 16:55:04
I have a slight problem...
The kernel printf routines are protected by a spinlock so that only
one processor can be in the printf routnes at the same time. I assume
that this locking is to protect the console hardware from being accessed
from more than one CPU at a time. This causes problem on machines where
only one CPU can access the system console and the rest must send their
data over via IPI: if a slave CPU enters the printf routines, and then
the master CPU also tries to do a printf, the master will spinlock at
high ipl. Meanwhile the slave has reached putchar() and sends an IPI
which will never reach the master, hence the deadlock.
In an environment like this, the kprintf lock is unneccessary, because
of the hardware design. Therefore I would like to add:
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/subr_prf.c,v
retrieving revision 1.79
diff -c -r1.79 subr_prf.c
*** subr_prf.c 2001/05/06 13:23:42 1.79
--- subr_prf.c 2001/06/03 14:53:44
***************
*** 73,79 ****
#include <ipkdb/ipkdb.h>
#endif
! #if defined(MULTIPROCESSOR)
struct simplelock kprintf_slock = SIMPLELOCK_INITIALIZER;
/*
--- 73,79 ----
#include <ipkdb/ipkdb.h>
#endif
! #if defined(MULTIPROCESSOR) && !defined(NO_KPRINTF_SPINLOCK)
struct simplelock kprintf_slock = SIMPLELOCK_INITIALIZER;
/*
Do anyone see any problem with this, or are there side effects that I
have missed? Otherwise I'll just add this define.
-- Ragge