Subject: Re: kprintf locking problem.
To: Anders Magnusson <ragge@ludd.luth.se>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-smp
Date: 06/03/2001 09:22:13
On Sun, Jun 03, 2001 at 05:47:19PM +0200, Anders Magnusson wrote:
> > Does the VAX's scheme deal with that okay?
> >
> Not from the slave CPUs (because the chars are sent via IPI).
>
> > Also, where do you want
> > to put the new #define? Probably should be in sys/types.h, or something,
> > as __NO_KPRINTF_LOCK.
> >
> It doesn't matter at all, I just want this to work for some degree of "work".
> I am interested in all suggestions as long as this problem is solved.
Ok, Bill Sommerfeld mentioned something to me which sparked an idea...
In your machine/lock.h, define a KPRINTF_SLOCK_ACQUIRE like so:
#define KPRINTF_SLOCK_ACQUIRE(alp) \
do { \
struct cpu_info *__ci = curcpu(); \
\
while (__cpu_simple_lock_try(&(alp)->lock_data) == 0) { \
if (__ci->ci_ipis_pending) \
/* go process them */ ; \
} \
} while (/*CONSTCOND*/0)
Then in subr_prf.c:
#ifndef KPRINTF_SLOCK_ACQUIRE
#define KPRINTF_SLOCK_ACQUIRE(alp) __cpu_simple_lock(&(alp)->lock_data)
#endif
#define KPRINTF_MUTEX_ENTER(s) \
do { \
(s) = splhigh(); \
KPRINTF_SLOCK_ACQUIRE(&kprintf_slock); \
} while (/*CONSTCOND*/0)
--
-- Jason R. Thorpe <thorpej@zembu.com>