cvs commit: src/sys/amd64/amd64 genassym.c src/sys/arm/arm genassym.c src/sys/i386/i386 genassym.c src/sys/ia64/ia64 genassym.c src/sys/kern subr_prf.c tty_cons.c src/sys/powerpc/powerpc genassym.c src/sys/sparc64/sparc64 ...

John Baldwin jhb at freebsd.org
Wed Nov 1 15:27:41 UTC 2006


On Wednesday 01 November 2006 04:35, Pawel Jakub Dawidek wrote:
> On Wed, Nov 01, 2006 at 04:54:51AM +0000, John Birrell wrote:
> > jb          2006-11-01 04:54:51 UTC
> > 
> >   FreeBSD src repository
> > 
> >   Modified files:
> >     sys/amd64/amd64      genassym.c 
> >     sys/arm/arm          genassym.c 
> >     sys/i386/i386        genassym.c 
> >     sys/ia64/ia64        genassym.c 
> >     sys/kern             subr_prf.c tty_cons.c 
> >     sys/powerpc/powerpc  genassym.c 
> >     sys/sparc64/sparc64  genassym.c 
> >     sys/sys              cons.h pcpu.h 
> >   Log:
> >   Add a cnputs() function to write a string to the console with
> >   a lock to prevent interspersed strings written from different CPUs
> >   at the same time.
> 
> Nice, this was very annoying, but I'd still like to have a recursive
> lock, which could be used by printf(9) consumers. For example, I'm not
> able to implement such macro in a way that ensure everything will be
> printed in one line:
> 
> #define G_MIRROR_DEBUG(lvl, ...)	do {				\
> 	if (g_mirror_debug >= (lvl)) {					\
> 		printf("GEOM_MIRROR");					\
> 		if (g_mirror_debug > 0)					\
> 			printf("[%u]", lvl);				\
> 		printf(": ");						\
> 		printf(__VA_ARGS__);					\
> 		printf("\n");						\
> 	}								\
> } while (0)
> 
> What I'd like is a global printf_lock which will allow me to put many
> separate printfs under it and be sure it won't be messed up by other
> CPUs. Having it recursive could also eliminate the need for per-CPU
> buffers, as I don't think we care about performance here.
> 
> What do you think?

Because printf is used for things like panics, I think it needs to be as 
robust as possible.  I think adding a larger lock like you request would make 
it too fragile.

-- 
John Baldwin


More information about the cvs-src mailing list