Date: Mon, 27 Jan 1997 01:43:47 +1100 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, sos@ravenock.cybercity.dk Cc: dgy@rtd.com, freebsd-hackers@freefall.freebsd.org Subject: Re: suggestion for kernel printk() ? Message-ID: <199701261443.BAA00334@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> it may be called from interrupt handlers. BTW, there _are_ reentrancy >> problems in the syscons and pcvt output routines. Don't use /dev/ttyv0 >> in syscons if you want the system to stay up forever. > >Erhm, why ?? I've not seen any problems and ttyv0 is the only tty I >use on my WS (its used almost only under X otherwise) Syscons is not reentrant and doesn't mask interrupts at all while it is doing output, so there must be races when it is reentered. This problem can't be fixed by masking interrupts, because it is important that kernel messages get printed no matter what, and in any case the the console driver is used for unmaskable traps (mainly debugger traps) and NMIs. Here's an LKM to demonstrate the problem. It just prints a "*" every 100 msec in its timeout interrupt handler. Running it together with `hd /* >/dev/ttyv0' usually causes a panic in 10-20 seconds on a 486/33. Use `make; make load' to run it. Reduce the timeout to panic faster. I often use ttyv0 and rarely use X and haven't seen the problem either. Kernel printfs are rare, but 10-20 seconds worth of printfs at 10/sec isn't many either. There are obviously more problems at line and page boundaries; perhaps the problems are rarer for kernel messages because most messages are newline-terminated. Bruce #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: Makefile foo.c # Wrapped by bde@gamplex.bde.org on Mon Jan 27 01:23:13 1997 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(97 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XBINDIR= /tmp XSRCS= foo.c XKMOD= foo_mod XNOMAN= none X XCLEANFILES+= ${KMOD} X X.include <bsd.kmod.mk> END_OF_FILE if test 97 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'foo.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'foo.c'\" else echo shar: Extracting \"'foo.c'\" \(725 characters\) sed "s/^X//" >'foo.c' <<'END_OF_FILE' X#include <sys/param.h> X#include <sys/systm.h> X#include <sys/exec.h> X#include <sys/sysent.h> X#include <sys/lkm.h> X XMOD_MISC(foo); X Xstatic void Xfoo(void *arg) X{ X#if 0 X sccnputc(0, '*'); X timeout(foo, NULL, 1); X#else X /* X * Fills up log if done every tick so only do it every 10 ticks and X * wait a bit longer for races. X */ X printf("*"); X timeout(foo, NULL, 10); X#endif X} X Xint Xfoo_mod(struct lkm_table *lkmtp, int cmd, int ver) X{ X DISPATCH(lkmtp, cmd, ver, foo_load, foo_unload, lkm_nullcmd); X} X Xstatic int Xfoo_load(struct lkm_table *lkmtp, int cmd) X{ X timeout(foo, NULL, 1); X return 0; X} X Xstatic int Xfoo_unload(struct lkm_table *lkmtp, int cmd) X{ X int s; X X s = splsoftclock(); X untimeout(foo, NULL); X splx(s); X return 0; X} END_OF_FILE if test 725 -ne `wc -c <'foo.c'`; then echo shar: \"'foo.c'\" unpacked with wrong size! fi # end of 'foo.c' fi echo shar: End of shell archive. exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701261443.BAA00334>