Skip to contentSkip to conversation

Panics need better handling

PATCH New [email protected] 6 participants 6 messages Jun 14, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

The following information is visible on
a screen after a panic. Usually even
this amount of information is not
visible. It was visible because of an
intuitive guess that a panic was going
to happen within minutes of that guess.
A very lucky occurence resulted in one
of the lines being displayed which is
rarely displayed even when other panic
lines are visible. I am not asking for
help in solving this particular panic,
I am asking for help in general, in
getting information displayed when it
needs to be displayed.

EIP is at __insmod_binfmt_misc_S.data_L548 [binfmt_misc] 0x20e7 (2.4.20-custom)
eax: e47f1600 ebx: e4017e80 ecx: 00000000 edx: e7883000
esi: 04000001 edi: c034df54 ebp: 0000000b esp: c034df10
ds: 0068 es: 0068 ss: 0068
Process swapper (pid: 0, stackpage=c034d000)

Stack: c010aab5 0000000b e47f1600 c034df54 c036fe80 0000000b c29c6c00 00000580
       c010ac54 0000000b c034df54 c29c6c00 00000000 00000000 00000000 00000000
       c010d768 00000000 00000000 000005c1 00000000 00000000 00000000 c034dfbc
Call Trace:   [<c010aab5>] handle_IRQ_event [kernel] 0x45 (0xc034df10))

[<c010ac54>] do_IRQ [kernel] 0x84 (0xc034df30)) [<c010d768>] call_do_IRQ [kernel] 0x5 (0xc034df50)) [<c0110068>] dump_fpu [kernel] 0x48 (0xc034df70)) [<c01157ee>] apm_bios_call_simple [kernel] 0x8e (0xc034df7c)) [<c0115937>] apm_do_idle [kernel] 0x27 (0xc034dfa8)) [<c0115a8b>] apm_cpu_idle [kernel] 0xbb (0xc034dfc0)) [<c01159d0>] apm_cpu_idle [kernel] 0x0 (0xc034dfc4)) [<c0107040>] default_idle [kernel] 0x0 (0xc034dfd0)) [<c01070f2>] cpu_idle [kernel] 0x42 (0xc034dfd4)) [<c0105000>] stext [kernel] 0x0 (0xc034dfe0))

Code:  Bad EIP value.
 <0>Kernel panic: Aiee, killing interrupt handler!

In interrupt handler - not syncing
_ <-- (cursor is there)

I'm not sure which of these complaints
to prioritize.

When a panic is visible, there are two
blank lines, a redundant line saying

Kernel panic Aieee, a redundant line

saying In interrupt handler, and a
redundant line with the cursor only.
If these 5 lines were removed, there
could be 5 more lines of trace
information. Actually there usually
are 5 more lines of trace information,
actually usually more than that, but
they get scrolled off the top of the
screen. The line saying "EIP is at" is
almost always among the lines that get
scrolled off the screen, but in this
case we were lucky that this line just
barely got a chance to survive. And
usually the EIP isn't so badly invalid
as this one is, usually it's really
useful information that gets scrolled
off the top of the screen. Is there
any chance in getting the 24 most
important lines of panic information
displayed last, and putting the cursor
at the end of the 24th line thereof, so
that 24 valuable lines of panic
information can be visible?

Also, usually the panic information
isn't visible at all. Certain famous
frequent blue screens of death are
famous and frequent partly because of
famous frequent crashes, but also
partly because the kernel puts the
screen back into VGA text mode before
displaying the text. In Linux, usually
XFree86 is running, and usually the
only visible effect is a freeze. How
many of these freezes really have panic
information written to an invisible VGA
buffer and never displayed? When a
panic occurs, we need to shove off
XFree86 and put the display into VGA
text mode. Even if this makes Linux
black screens of death become as famous
and frequent as certain blue ones, we
need to get the information.

(Apologies if there are editing errors
in the above, which are not visible in
the web interface being used for this
submission. I used to send submissions
from my real e-mail account, and as a
result was rewarded with 60 spams per
day. I'm not going to send submissions
from my new real e-mail account.)

#1 lore raw

Hi,

Quoted 7 lines · On Sun, Jun 13, 2004 at 09:23:01PM -0500, [email protected] wrote:

Is there
any chance in getting the 24 most important lines of panic information displayed last, and putting the cursor at the end of the 24th line thereof, so that 24 valuable lines of panic information can be visible?

You could try kmsgdump, which Randy Dunlap ported to 2.6 :

http://developer.odsl.org/rddunlap/kmsgdump/

Upon panic, it switches real mode, uses the bios to change display to text mode (which does not work for every video card, but still most of them), then put you in an interactive screen in which you can scroll the last 32 kB of kernel messages, then decide to dump them on a floppy disk or print them on a parallel printer. This can also be configured to dump automatically without user interaction and automatically reboot once done.

Clearly what you need it seems,
Willy

#3 lore raw

PATCH 1/1 kmsgdump-2.6.6.patch (was: Panics need better handling)

Quoted 9 lines · Norberto Bensa
Quoted 1 line · Willy Tarreau

http://developer.odsl.org/rddunlap/kmsgdump/

http://developer.osdl.org/rddunlap/kmsgdump/

;-)

OK, I reapplied the patch from the URL above to 2.6.6 (this is current for most of my machines) and I am posting it here.

I moved one line in kmsg-reboot inside the appropriate #ifdef as not to cause warnings on compile. Apart form that only applying with the code shifted a bit.

I have prepared my floppy for a dump and everything seems ok, but I have not got any oopses yet :-)

Not sure if I need the signed-off-by, as it is not for inclusion (yet), but here it is:

Documentation/kmsgdump.txt +370 -0
diff -Nuarp linux-2.6.6/Documentation/kmsgdump.txt linux-2.6.6_K1/Documentation/kmsgdump.txt
@@ -0,0 +1,370 @@
+                     - Documentation for KMSGDUMP v0.4 -
+               [Sun Sep 19 19:30:32 CEST 1999] - Willy Tarreau
+               [updates by Randy Dunlap, Jan/Feb/Mar 2003]
+
+
+1. What is KMSGDUMP ?
+~~~~~~~~~~~~~~~~~~~~~
+
+KMSGDUMP is an extension to the Linux kernel which allows the user on the
+console to dump the last kernel messages onto a floppy diskette, thus
+avoiding to take a pen and a paper to copy them when the system is stuck.
+Only 3"1/2, 1.44 MB diskettes are supported by default. Other capacities
+might work, provided you change the geometry in the file "kmsgdump.h".
+
+
+2. How does it work ?
+~~~~~~~~~~~~~~~~~~~~~
+
+There are two ways of getting a dump :
+
+   - by pressing SysRQ+D (RightAlt - PrintScrn - D together) ;
+   - after a kernel panic has occurred, a dump may be automatically
+     generated.
+
+Before anything else, you MUST KNOW that in order to get maximal
+chances to complete the dump succesfully, the CPU is rebooted in
+real mode and disk accesses are made via the Bios. This ensures
+that even if kernel memory is really corrupted, the dump still
+has chances to work, but this also implies that after a dump has
+occurred, it is IMPOSSIBLE TO CONTINUE TO WORK WITH THE CURRENT
+KERNEL. You will have to REBOOT. So when your kernel still responds,
+you'd better get a similar dump by entering one of the following
+commands :
+
+# dmesg > /dev/fd0                   ( for RAW mode )
+
+or
+
+# dmesg | mwrite a:messages.txt      ( for FAT mode )
+
+
+Second, be sure that FLOPPY CONTENTS WILL BE LOST AFTER A DUMP.
+Even if there are cases in which you can dump at the end of a diskette without
+losing the beginning, consider that by default the beginning of the diskette
+will be ERASED and you won't be able to recover what's on it. You have been
+warned.
+
+
+3. Modes of operation
+~~~~~~~~~~~~~~~~~~~~~
+
+There are two modes of operation : manual and automated.
+
+Manual mode (or interactive mode) is always entered if you hit SysRQ+D.
+But it is also entered during a kernel panic if the current mode is set
+to "manual". This mode is recommended for a developer's workstation,
+or a kernel running under an emulator such as vmware. It's recommended
+to disable interactive mode on servers which may crash when nobody is
+near to reboot them.
+
+Automatic mode can only be entered during a kernel panic and if automatic
+mode was previously configured. Sometimes, the system is really weird and
+even kmsgdump can cause recursive crashes (this has been reported to me once).
+For this reason I've added a checkpoint mechanism to the code : every little
+part of code is checkpointed, and if a crash occurs again, the same part is
+not executed again, to prevent looping. So there are more chances to get
+to the reset routine which will, in the worst case, reboot the system, but
+not let it loop indefinitely.
+
+3.1. Manual mode
+~~~~~~~~~~~~~~~~
+
+Under manual mode, the screen initialized to color 80x25 mode (bios mode 3)
+with a blue background.
+
+ [Note: some people asked me to set other colors to avoid confusion
+        with another OS' BSOD, but I couldn't find good associations.
+        Even though I've received an interesting comment about the way
+        to choose colors readable on any color or monochrome display,
+        I'm waiting for suggestions, and for the moment we'll say that
+        these are the colors of Midnight Commander and call this "BSOL"
+        (blue screen of life) because this one is interactive.]
+
+The screen is divided in two portions. The upper one displays the current
+status (kernel version, drive unit, printer, format...), and the lower one
+the messages captured before switching to real mode. The internal speaker
+beeps if a key has not been hit within 3 seconds. This is simply to get
+someone's attention, mainly in cases where no monitor is connected to the
+PC.
+
+The interface is not case-sensitive about keys pressed. Keys used are :
+  Upper arrow : scroll messages to the beginning
+  Lower arrow : scroll messages to the end
+  B : immediately reBoot the system
+  D : Dump messages onto the selected floppy with selected format. Warning:
+      no check is done before, and the floppy will simply be overwritten by
+      the messages.
+  F : select Format, by switching between RAW and FAT12
+  H : immediately Halt the system.
+  I : display Information, little help about the keys.
+  P : Print messages on the currently selected printer. If you press this key
+      by accident, wait about one minute for the bios routine to timeout, and
+      you'll here the beeps again, stating that you can play again.
+  T : select next available prinTer. The system tests if a printer is
+      connected at the other end of the cable, and skips the empty ports.
+  U : change drive Unit. Although dump is possible on hard disks, they are
+      never proposed in the interface to avoid dramatic mistakes.
+
+Other keys are simply ignored.
+
+After a succesful dump or print, 3 quick beeps are played. In case of an error,
+only one beep is played. This is important if you act blindly with a keyboard
+and no monitor.
+
+3.2. Automatic mode
+~~~~~~~~~~~~~~~~~~~
+
+Automated operation is performed by the system only when a kernel panic
+occurs. In this case, the system waits for the "panic_timeout" delay
+to give you a few seconds if you want to try to play with SysRQ (sync,
+unmount filesystems, ...). This delay is configurable by entering a
+number of seconds in "/proc/sys/kernel/panic".
+
+After that, the system is rebooted to real mode, and depending on the
+mode of operation chosen, either the interactive mode is entered (see above)
+or it is the automatic mode, which we'll describe here.
+
+3.2.1. Start of operation
+~~~~~~~~~~~~~~~~~~~~~~~~~
+Some checks are performed. First, the system sees if the dump feature is
+enabled or not. If not, operation ends (see below). If dump is enabled,
+and if the "safe" flag is enabled, the diskette is verified to be a real
+"KMSGDUMP" diskette and not another one (read section 4 to know how to
+prepare a secure diskette for KMSGDUMP). If the diskette isn't a right one,
+operation ends. If the diskette is a right one, or if the check has been
+disabled, the dump is performed with the current parameters (unit, format...).
+
+3.2.2. End of operation
+~~~~~~~~~~~~~~~~~~~~~~~
+After completion of an automatic dump, or when a dump is aborted, the system
+can either halt or reboot. In case of redundant servers, you may prefer to halt
+a buggy system, because another one ensures the service continues to work.
+But in other cases, you may prefer rebooting to quickly restart services.
+This is also configurable (read section 4).
+
+
+4. How a crash can be prepared
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+4.1. Kernel options
+~~~~~~~~~~~~~~~~~~~
+
+First, choose the kernel compilation options which closely match your
+situation. This may seem obvious, but you can reduce the risks of crash
+by not enabling drivers designated for hardware you don't have. Specially
+on servers, use only a reduced feature set, because you know exactly what
+you need (eg: don't enable NTFS and QNX filesystems if you don't need them).
+
+Configure KMSGDUMP options to match your needs. Don't ask to auto-dump if
+you don't have a floppy drive. In this case, you might prefer to enable
+interactive mode to display messages on the screen and eventually print
+them.
+
+When you use SCSI hard disks, you can sometimes reduce the reset time to
+help the system recover faster. Eg: on my system, I have an AHA2940UW which
+waits 15 seconds by default. All peripherals still work well with 1 second,
+so 14 seconds are won.
+
+If you have changed your messages buffer size (which is 16 kB by default),
+you should modify the size in "include/asm/kmsgdump.h", parameter LOG_BUF_LEN.
+Some people required 32 kB. But you shouldn't exceed 60 kB since the dump is
+done in real mode (16 bits).
+For kernel versions 2.5.6x and later, the LOG_BUF_LEN parameter is part
+of the kernel .config file (LOG_BUF_SHIFT) so you don't need to modify
+it at all.
+
+4.2. Configure KMSGDUMP
+~~~~~~~~~~~~~~~~~~~~~~~
+
+If your kernel supports SYSCTL, you can adjust KMSGDUMP parameters by
+writing a string to /proc/sys/kernel/kmsgdump. This string consists of
+a concatenation of flags. Most of them are only booleans. For each boolean,
+a complementary flag exists to avoid any ambiguous interpretation.
+For the moment, the flags are :
+
+   Name Description         Default Complement
+   F    FAT mode              Yes   R
+   R    Raw mode                    F
+   A    Automatic mode        Yes   I
+   I    Interactive mode            A
+   B    Boot after dump       Yes   H   only used in automatic mode
+   H    Halt after dump             B   only used in automatic mode
+   S    Safe mode             Yes   O   only used in automatic mode
+   O    Overwrite disk              S   only used in automatic mode
+   E    Enable dumping        Yes   D   only used in automatic mode
+   D    Disable dumping             E   only used in automatic mode
+   Txxx Track xxx             0   (N/A) first track is 0 per default
+   Uxxx Unit xxx              0   (N/A) bios drive is 0 (A:) per default
+
+Note: default means "default if none specified".
+
+Example: if you enter the following command, a kernel panic will generate
+         a dump in FAT mode after verifying that the disk has been prepared
+         for a dump, and then it will reboot :
+
+         # echo "FABSE" > /proc/sys/kernel/kmsgdump
+
+This one will ask to dump raw messages at the end of the diskette in drive B
+and halt :
+
+         # echo "RABOET79U1" > /proc/sys/kernel/kmsgdump
+
+And this one will ask for a quick reboot :
+
+         # echo "DB" > /proc/sys/kernel/kmsgdump
+
+
+4.3. Prepare a disk for kmsgdump
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If safe mode is required, before an automatic dump, the system will read
+the beginning of the floppy in the drive and will look for the word "KMSGDUMP"
+at offset 3 of the first sector. This is the label of the diskette. The dump
+will only be performed if this word is found as-is. So if you enable safe mode
+don't forget to prepare your diskettes with the following command, provided
+your diskette is in drive A :
+
+         # echo "012KMSGDUMP" > /dev/fd0
+
+Please note that when the dump is performed in FAT mode, this word is written
+to the same place. This has two side effects :
+    - a diskette on which a dump has been done in FAT mode is re-usable without
+      intervention.
+    - you can prepare a diskette by entering kmsgdump (SysRQ+D) and doing a
+      FAT mode dump.
+
+On the other hand, when a RAW dump is done at the beginning of the disk, it
+cannot be used again as a "safe kmsgdump disk". Moreover, leaving it in the
+drive when rebooting will cause the system to hang if the bios tries to boot
+from the floppy first.
+
+4.4. Prepare the PC for a crash
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Because you'll have to leave a diskette in a drive, you may have to setup
+your bios to boot from hard disk or anything but the floppy first because
+the bios will find anything but a bootable system on this floppy. The problem
+is with older systems on which the boot sequence cannot be changed. For this
+reason, when a diskette is formatted in FAT mode, a small code is inserted on
+the boot sector which tries to redirect the boot to the first hard disk seen
+by the bios. This is *generally* the bootable disk, but this may not be the
+right on specific systems, so you may have to do some tests before considering
+this option to be the right one for you.
+
+If your system is a server, you may reduce the time the bios tests the PC to
+ensure quick reboot. On some systems, you can turn on the option "Quick
+power-on self test", and disable testing of memory above 1MB.
+
+
+5. Reading the messages back
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+5.1. FAT-formatted disks
+~~~~~~~~~~~~~~~~~~~~~~~
+
+If the disk has been formatted as FAT12, you'll find on it a file
+named "MESSAGES.TXT" which contains all of the 'messages' buffer. If the
+buffer is not full, the end of the file is filled with zeroes, so
+it's better to delete them using "tr" under linux.
+
+  - under Linux, either mount the disk :
+
+       # mount -rt msdos /dev/fd0 /mnt
+       # cat /mnt/messages.txt | tr -d '\000'
+       # umount /mnt
+
+    or read it using mtools :
+
+       # mtype a:messages.txt | tr -d '\000'
+
+  - under DOS, you can simply run EDIT :
+
+       C:\> edit a:messages.txt
+
+  - under Windows, you can open the file with Wordpad. Avoid using
+    Notepad since it doesn't understand linefeeds only.
+
+5.2. RAW disks
+~~~~~~~~~~~~~~
+
+Raw disks will be readable under linux by using the utility DD. By
+default, the dump will be performed from the first sector of the disk.
+Example with 16 kB messages buffer:
+
+       # dd if=/dev/fd0 bs=512 count=32 | tr -d '\000'
+
+If you specified "T79" in the parameters to dump on track 79 of the disk,
+you have to do some calculations :
+
+A 1.44 MB disk has 18 sectors/track, 2 heads and 512 bytes/sector so
+18*2*512 equals 18432 bytes/track. You'll have to skip 18432 bytes for
+each unwanted track. But you can also count only with kilobytes : if you
+consider that a track is exactly 18 kilobytes, then skip the number of
+tracks times 18 kilobytes :
+
+       # expr 79 \* 18
+       1422
+       # dd if=/dev/fd0 bs=1024 skip=1422 count=16 | tr -d '\000'
+
+The default dd utility reads all data from the start of the disk so this can
+be quite long. There are other implementations on the net which do an "lseek"
+before the first read.
+
+
+6. Other speed improvements
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Here is some advice to make a system reboot faster, especially if
+you don't use filesystem journalling.
+
+When a file server crashes, it may FSCK for a long time. There are good docs
+about how to dramatically reduce FSCK time, but at least consider these 
+methods :
+
+    - in /etc/fstab, set the sixth field (fs_passno) to 1 for the root fs,
+      and 2 for every other fs. FSCK will know it what it can parallelize
+      depending on hardware dependencies. In the better case, you can divide
+      the total time by the number of physical disks.
+      (man fstab and man fsck for more info).
+
+    - when possible, mount filesystems read-only. On an anonymous FTP server,
+      for example, it's not always necessary to mount everything RW. So before
+      copying files onto an fs, remount it RW :
+
+         # mount -wo remount /mount/point
+
+      At the end, remount it RO :
+ 
+         # mount -ro remount /mount/point
+
+    - change the number of bytes by inode and the block size when formatting
+      your FS. I personnaly use 16384 bytes/inode, a block size of 4096 bytes,
+      the sparse flag set (reduces the number of superblocks). This makes me
+      waste about 1% space, but total mount time is about 1 second for a total
+      of 8 FS's, 11 gigs on 5 separate disks and the total FSCK time after a
+      loosy power-off is less than 3 minutes.
+
+    - use a Linux journaling file system, such as ext3fs, IBM JFS, or
+      reiserfs in Linux 2.4, or any any of those or SGI XFS in Linux 2.5
+
+And of course, don't start services you don't need ! Sendmail itself can take
+a long time if it cannot resolve the domain name.
+
+
+7. For more information and/or suggestions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For more informations, you can email me at :
+
+       willy AT meta-x.org
+
+( be patient, I read my mail when I can, and can't always reply. I'm
+  used to "tail -1000 $MAIL|less" or "less +G $MAIL" )
+
+For suggestions, you can either email them to me, or share them with
+the Linux Kernel Mailing List :
+
+       [email protected]
+
+Enjoy using it,
+
+Willy
+
arch/i386/Kconfig +88 -0

94 lines not on this page · raw message

arch/i386/kernel/Makefile +1 -0
diff -Nuarp linux-2.6.6/arch/i386/kernel/Makefile linux-2.6.6_K1/arch/i386/kernel/Makefile
@@ -30,6 +30,7 @@ obj-y				+= sysenter.o vsyscall.o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat.o
 obj-$(CONFIG_HPET_TIMER) 	+= time_hpet.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
+obj-$(CONFIG_KMSGDUMP)		+= kmsg_reboot.o kmsgdump.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_X86_STD_RESOURCES)	+= std_resources.o
 
arch/i386/kernel/kmsg_reboot.c +315 -0

315 lines not on this page · raw message

arch/i386/kernel/kmsgdump.S +898 -0

898 lines not on this page · raw message

drivers/char/sysrq.c +21 -1
diff -Nuarp linux-2.6.6/drivers/char/sysrq.c linux-2.6.6_K1/drivers/char/sysrq.c
@@ -77,6 +77,22 @@ static struct sysrq_key_op sysrq_SAK_op 
 };
 #endif
 
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+extern void machine_dump(int);
+	
+static void sysrq_handle_dump(int key, struct pt_regs *pt_regs,
+		struct tty_struct *tty) {
+		machine_dump(1);/* 1 = "dump called from SysRq, so interactive mode expected" */
+}
+
+static struct sysrq_key_op sysrq_dump_op = {
+	handler:        sysrq_handle_dump,
+	help_msg:       "Dump",
+	action_msg:     "Trying to dump through real mode\n",
+};
+#endif
+
+
 #ifdef CONFIG_VT
 /* unraw sysrq handler */
 static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs,
@@ -236,7 +252,11 @@ static struct sysrq_key_op *sysrq_key_ta
 		 and will never arrive */
 /* b */	&sysrq_reboot_op,
 /* c */ NULL,
-/* d */	NULL,
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+/* d */       &sysrq_dump_op,
+#else
+/* d */       NULL,
+#endif
 /* e */	&sysrq_term_op,
 /* f */	NULL,
 /* g */	NULL,
include/asm-i386/kmsgdump.h +93 -0

93 lines not on this page · raw message

include/linux/sysctl.h +1 -0
diff -Nuarp linux-2.6.6/include/linux/sysctl.h linux-2.6.6_K1/include/linux/sysctl.h
@@ -112,6 +112,7 @@ enum
  	KERN_MSGMNI=42,		/* int: msg queue identifiers */
  	KERN_SEM=43,		/* struct: sysv semaphore limits */
  	KERN_SPARC_STOP_A=44,	/* int: Sparc Stop-A enable */
+	KERN_KMSGDUMP=44,	/* string: kmsgdump flags. Reuse Stop-A ID */
  	KERN_SHMMNI=45,		/* int: shm array identifiers */
 	KERN_OVERFLOWUID=46,	/* int: overflow UID */
 	KERN_OVERFLOWGID=47,	/* int: overflow GID */
kernel/panic.c +26 -0
diff -Nuarp linux-2.6.6/kernel/panic.c linux-2.6.6_K1/kernel/panic.c
@@ -20,6 +20,12 @@
 #include <linux/interrupt.h>
 #include <linux/nmi.h>
 
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+#include <linux/fs.h>
+extern void machine_dump(int);
+#endif
+
+
 int panic_timeout;
 int panic_on_oops;
 int tainted;
@@ -72,6 +78,26 @@ NORET_TYPE void panic(const char * fmt, 
 	smp_send_stop();
 #endif
 
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+	/* We allow SysRq to be used for <panic_timeout> seconds, and
+	   then the dump is forced. This way, if IRQs are frozen and
+	   keyboard doesn't respond anymore, the system can dump messages
+	   and reboot itself.
+	   This code has been voluntarily inserted before notifier_call_chain
+	   to ensure proper execution in case of crash. Please tell me if this
+	   can be wrong.
+	*/
+	printk(KERN_EMERG "Dumping messages in %d seconds : last chance for Alt-SysRq...",
+		panic_timeout);
+	local_irq_enable();
+	for (panic_timeout *= 10; panic_timeout > 0; panic_timeout--) {
+		emergency_sync();
+		mdelay(100);
+	}
+	machine_dump(0);        /* 0 tells machine_dump that it's called from panic() */
+#endif
+		
+	
        notifier_call_chain(&panic_notifier_list, 0, buf);
 
 	if (panic_timeout > 0)
kernel/printk.c +32 -0
diff -Nuarp linux-2.6.6/kernel/printk.c linux-2.6.6_K1/kernel/printk.c
@@ -371,6 +371,38 @@ out:
 	return error;
 }
 
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+#include <asm/kmsgdump.h>
+
+/*
+ * dump_syslog() : Added on 19991020 by Willy Tarreau <willy AT meta-x.org>
+ * This function is only used by machine_dump. It basically does the same
+ * as do_syslog(3), but avoids to check if *buf is writeable because this
+ * sometimes made the system crash in case of real instability (common
+ * case when machine_dump is called).
+ */
+
+void dump_syslog(char *buf) {
+	unsigned long i, j, count;
+
+	if (!buf)
+		return;	
+	/*
+	 * The logged_chars, log_start, and log_size values may
+	 * change from an interrupt, so we disable interrupts.
+	 */
+	spin_lock_irq(&logbuf_lock);
+	count = LOG_BUF_LEN;
+	if (count > logged_chars)
+		count = logged_chars;
+	j = log_start;
+	for (i = 0; (i < count) && (j != log_end); i++, j++) {
+		buf[i] = LOG_BUF(j);
+	}
+	spin_unlock_irq(&logbuf_lock);
+}
+#endif
+
 asmlinkage long sys_syslog(int type, char __user * buf, int len)
 {
 	return do_syslog(type, buf, len);
kernel/sysctl.c +15 -0
diff -Nuarp linux-2.6.6/kernel/sysctl.c linux-2.6.6_K1/kernel/sysctl.c
@@ -90,6 +90,10 @@ extern int msg_ctlmni;
 extern int sem_ctls[];
 #endif
 
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+extern char kmsgdump_flags[];
+#endif
+
 #ifdef __sparc__
 extern char reboot_command [];
 extern int stop_a_enabled;
@@ -513,6 +517,17 @@ static ctl_table kern_table[] = {
 		.proc_handler	= &proc_dointvec,
 	},
 #endif
+#if defined(__i386__) && defined(CONFIG_KMSGDUMP)
+	{
+		.ctl_name	= KERN_KMSGDUMP,
+		.procname	= "kmsgdump",
+		.data		= &kmsgdump_flags,
+		.maxlen		= 16,
+	 	.mode		= 0644,
+		.proc_handler	= &proc_dostring,
+		.strategy	= &sysctl_string,
+	},
+#endif
 	{
 		.ctl_name	= KERN_CADPID,
 		.procname	= "cad_pid",
#4 lore raw
In reply to [email protected]
Quoted 7 lines · [email protected] wrote:

I am not asking for
help in solving this particular panic, I am asking for help in general, in getting information displayed when it needs to be displayed.

I have struggled with this from time to time. Wanting to report a trace, but it is too long for the screen.

Using a framebuffer console helps a lot. I use 1280x1024 resolution, and 8x8 characters. The resulting 160x128 console isn't that fun to _work_ with, but most panics/oopses fit. I rarely work at the console anyway. If you do, consider making two almost identical kernels where console font size is the only difference. (The extra compile takes very little time.) Then use the small-font kernel when debugging.

Helge Hafting

#5 lore raw

Quote from Helge Hafting <[email protected]>:

Quoted 12 lines
Quoted 7 lines · [email protected] wrote:

I am not asking for
help in solving this particular panic, I am asking for help in general, in getting information displayed when it needs to be displayed.

I have struggled with this from time to time. Wanting to report a trace, but it is too long for the screen.

Quoted 7 lines

Using a framebuffer console helps a lot. I use 1280x1024 resolution, and 8x8 characters. The resulting 160x128 console isn't that fun to _work_ with, but most panics/oopses fit. I rarely work at the console anyway. If you do, consider making two almost identical kernels where console font size is the only difference. (The extra compile takes very little time.) Then use the small-font kernel when debugging.

On the other hand, if like me you use a text-based console almost exclusively, then the best course of action is probably to buy a real serial terminal, (or several :-) ), and configure one of them as the console. Then you can basically ignore the VGA display completely.

John.