kmsg_dump: constrain mtdoops and ramoops to perform their actions only for KMSG_DUMP_...
authorSeiji Aguchi <seiji.aguchi@hds.com>
Thu, 13 Jan 2011 00:59:29 +0000 (16:59 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Jan 2011 16:03:07 +0000 (08:03 -0800)
This series aims to develop logging facility for enterprise use.

It is important to save kernel messages reliably on enterprise system
because they are helpful for diagnosing system.

This series add kmsg_dump() to the paths loosing kernel messages.  The use
case is the following.

[Use case of reboot/poweroff/halt/emergency_restart]

 My company has often experienced the followings in our support service.
 - Customer's system suddenly reboots.
 - Customers ask us to investigate the reason of the reboot.

We recognize the fact itself because boot messages remain in
/var/log/messages.  However, we can't investigate the reason why the
system rebooted, because the last messages don't remain.  And off course
we can't explain the reason.

We can solve above problem with this patch as follows.

 Case1: reboot with command
   - We can see "Restarting system with command:" or ""Restarting system.".

 Case2: halt with command
   - We can see "System halted.".

 Case3: poweroff with command
   - We can see " Power down.".

 Case4: emergency_restart with sysrq.
   - We can see "Sysrq:" outputted in __handle_sysrq().

 Case5: emergency_restart with softdog.
   - We can see "Initiating system reboot" in watchdog_fire().

So, we can distinguish the reason of reboot, poweroff, halt and emergency_restart.

If customer executed reboot command, you may think the customer should
know the fact.  However, they often claim they don't execute the command
when they rebooted system by mistake.

No message remains on the current Linux kernel, so we can't show the proof
to the customer.  This patch improves this situation.

This patch:

Alters mtdoops and ramoops to perform their actions only for
KMSG_DUMP_PANIC, KMSG_DUMP_OOPS and KMSG_DUMP_KEXEC because they would
like to log crashes only.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Marco Stornelli <marco.stornelli@gmail.com>
Reviewed-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/ramoops.c
drivers/mtd/mtdoops.c

index d3d63be2cd37efc15c5b261ab10492ba8b01caf6..eeec5758f9c48e9386250a7b7a11a8e6ac30bc32 100644 (file)
@@ -68,6 +68,11 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
        char *buf, *buf_orig;
        struct timeval timestamp;
 
+       if (reason != KMSG_DUMP_OOPS &&
+           reason != KMSG_DUMP_PANIC &&
+           reason != KMSG_DUMP_KEXEC)
+               return;
+
        /* Only dump oopses if dump_oops is set */
        if (reason == KMSG_DUMP_OOPS && !dump_oops)
                return;
index 1ee72f3f0512591d1ffd535f22aa2ac7dcb73941..c948150079bebe879316657f9bbc69791913dc1a 100644 (file)
@@ -307,6 +307,11 @@ static void mtdoops_do_dump(struct kmsg_dumper *dumper,
        unsigned long l1_cpy, l2_cpy;
        char *dst;
 
+       if (reason != KMSG_DUMP_OOPS &&
+           reason != KMSG_DUMP_PANIC &&
+           reason != KMSG_DUMP_KEXEC)
+               return;
+
        /* Only dump oopses if dump_oops is set */
        if (reason == KMSG_DUMP_OOPS && !dump_oops)
                return;