Skip to content

Commit 21aa928

Browse files
fenrus75Ingo Molnar
authored andcommitted
debug: show being-loaded/being-unloaded indicator for modules
It's rather common that an oops/WARN_ON/BUG happens during the load or unload of a module. Unfortunatly, it's not always easy to see directly which module is being loaded/unloaded from the oops itself. Worse, it's not even always possible to ask the bug reporter, since there are so many components (udev etc) that auto-load modules that there's a good chance that even the reporter doesn't know which module this is. This patch extends the existing "show if it's tainting" print code, which is used as part of printing the modules in the oops/BUG/WARN_ON to include a "+" for "being loaded" and a "-" for "being unloaded". As a result this extension, the "taint_flags()" function gets renamed to "module_flags()" (and takes a module struct as argument, not a taint flags int). Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 5a52dd5 commit 21aa928

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎kernel/module.c‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,21 +2357,30 @@ static void m_stop(struct seq_file *m, void *p)
23572357
mutex_unlock(&module_mutex);
23582358
}
23592359

2360-
static char *taint_flags(unsigned int taints, char *buf)
2360+
static char *module_flags(struct module *mod, char *buf)
23612361
{
23622362
int bx = 0;
23632363

2364-
if (taints) {
2364+
if (mod->taints ||
2365+
mod->state == MODULE_STATE_GOING ||
2366+
mod->state == MODULE_STATE_COMING) {
23652367
buf[bx++] = '(';
2366-
if (taints & TAINT_PROPRIETARY_MODULE)
2368+
if (mod->taints & TAINT_PROPRIETARY_MODULE)
23672369
buf[bx++] = 'P';
2368-
if (taints & TAINT_FORCED_MODULE)
2370+
if (mod->taints & TAINT_FORCED_MODULE)
23692371
buf[bx++] = 'F';
23702372
/*
23712373
* TAINT_FORCED_RMMOD: could be added.
23722374
* TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
23732375
* apply to modules.
23742376
*/
2377+
2378+
/* Show a - for module-is-being-unloaded */
2379+
if (mod->state == MODULE_STATE_GOING)
2380+
buf[bx++] = '-';
2381+
/* Show a + for module-is-being-loaded */
2382+
if (mod->state == MODULE_STATE_COMING)
2383+
buf[bx++] = '+';
23752384
buf[bx++] = ')';
23762385
}
23772386
buf[bx] = '\0';
@@ -2398,7 +2407,7 @@ static int m_show(struct seq_file *m, void *p)
23982407

23992408
/* Taints info */
24002409
if (mod->taints)
2401-
seq_printf(m, " %s", taint_flags(mod->taints, buf));
2410+
seq_printf(m, " %s", module_flags(mod, buf));
24022411

24032412
seq_printf(m, "\n");
24042413
return 0;
@@ -2493,7 +2502,7 @@ void print_modules(void)
24932502

24942503
printk("Modules linked in:");
24952504
list_for_each_entry(mod, &modules, list)
2496-
printk(" %s%s", mod->name, taint_flags(mod->taints, buf));
2505+
printk(" %s%s", mod->name, module_flags(mod, buf));
24972506
printk("\n");
24982507
}
24992508

0 commit comments

Comments
 (0)