Skip to contentSkip to conversation

Implement print_modules()

DISCUSSION Andrew Morton 2 participants 2 messages May 12, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 10 lines · Arjan van de Ven

Hi,

the patch below resolves the "Not Yet Implemented" print_modules() thing. This is a really useful feature for distros; it allows us to do statistical analysis on which modules are present how often in oopses compared to how often they are used normally.
In addition it helps to spot candidates for certain bugs without having to go back to the customer asking for this information.

OK. Only three architectures are calling print_modules() at this time. arch maintainers should consider adding a call. We have a stub at present so the change can go in any time.

Quoted 42 lines

diff -purN linux-2.6.6/include/linux/module.h linux/include/linux/module.h

include/linux/module.h +1 -1
@@ -22,7 +22,7 @@
 
 /* Not Yet Implemented */
 #define MODULE_SUPPORTED_DEVICE(name)
-#define print_modules()
+extern void print_modules(void);
 
 /* v850 toolchain uses a `_' prefix for all user symbols */
 #ifndef MODULE_SYMBOL_PREFIX

diff -purN linux-2.6.6/kernel/module.c linux/kernel/module.c

kernel/module.c +19 -0
@@ -1886,6 +1886,25 @@ struct module *module_text_address(unsig
 	return NULL;
 }
 
+void print_modules(void)
+{
+	unsigned long flags;
+	struct module *mod;
+	
+	local_irq_save(flags);
+	if (!spin_trylock(&modlist_lock)) {
+		local_irq_restore(flags);
+		return;
+	}
+	printk("Modules linked in: ");
+	list_for_each_entry(mod, &modules, list) {
+		printk("%s ",mod->name);
+	}
+	printk("\n");
+	spin_unlock(&modlist_lock);
+	local_irq_restore(flags);
+}
+
 #ifdef CONFIG_MODVERSIONS
 /* Generate the signature for struct module here, too, for modversions. */
 void struct_module(struct module *mod) { return; }
#2 lore raw
Quoted 9 lines · Andrew Morton
Quoted 7 lines · Arjan van de Ven

the patch below resolves the "Not Yet Implemented" print_modules() thing. This is a really useful feature for distros; it allows us to do statistical analysis on which modules are present how often in oopses compared to how often they are used normally.
In addition it helps to spot candidates for certain bugs without having to go back to the customer asking for this information.

Quoted 3 lines

OK. Only three architectures are calling print_modules() at this time. arch maintainers should consider adding a call. We have a stub at present so the change can go in any time.

This (untested) one should do the trick for m68k:

arch/m68k/kernel/traps.c +1 -0
@@ -1187,6 +1187,7 @@ void die_if_kernel (char *str, struct pt
 
 	console_verbose();
 	printk("%s: %08x\n",str,nr);
+	print_modules();
 	printk("PC: [<%08lx>]",fp->pc);
 	print_symbol(" %s\n", fp->pc);
 	printk("\nSR: %04x  SP: %p  a2: %08lx\n",

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds