]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
debug: track and print last unloaded module in the oops trace
authorArjan van de Ven <arjan@linux.intel.com>
Fri, 25 Jan 2008 20:08:33 +0000 (21:08 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 25 Jan 2008 20:08:33 +0000 (21:08 +0100)
Based on a suggestion from Andi:

 In various cases, the unload of a module may leave some bad state around
 that causes a kernel crash AFTER a module is unloaded; and it's then hard
 to find which module caused that.

This patch tracks the last unloaded module, and prints this as part of the
module list in the oops trace.

Right now, only the last 1 module is tracked; I expect that this is enough
for the vast majority of cases where this information matters; if it turns
out that tracking more is important, we can always extend it to that.

[ mingo@elte.hu: build fix ]

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/module.c

index 5bbf225ca07a4d665c3575890caa7f37701abe3d..1bb4c5e0d56e330b1de92b5e20fddbd446e9d314 100644 (file)
@@ -496,6 +496,8 @@ static struct module_attribute modinfo_##field = {                    \
 MODINFO_ATTR(version);
 MODINFO_ATTR(srcversion);
 
+static char last_unloaded_module[MODULE_NAME_LEN+1];
+
 #ifdef CONFIG_MODULE_UNLOAD
 /* Init the unload section of the module. */
 static void module_unload_init(struct module *mod)
@@ -719,6 +721,8 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
                mod->exit();
                mutex_lock(&module_mutex);
        }
+       /* Store the name of the last unloaded module for diagnostic purposes */
+       sprintf(last_unloaded_module, mod->name);
        free_module(mod);
 
  out:
@@ -2503,6 +2507,8 @@ void print_modules(void)
        printk("Modules linked in:");
        list_for_each_entry(mod, &modules, list)
                printk(" %s%s", mod->name, module_flags(mod, buf));
+       if (last_unloaded_module[0])
+               printk(" [last unloaded: %s]", last_unloaded_module);
        printk("\n");
 }