From 22e1c5c4e32614bb23a817ea53b4fa4842803d21 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 14 May 2004 20:23:01 -0700 Subject: [PATCH] [PATCH] implement print_modules() From: Arjan van de Ven , Rusty Russell 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. --- include/linux/module.h | 5 ++++- kernel/module.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/module.h b/include/linux/module.h index 9a3eb2f1f95d4..2709330e8684c 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -24,7 +24,6 @@ /* Not Yet Implemented */ #define MODULE_SUPPORTED_DEVICE(name) -#define print_modules() /* v850 toolchain uses a `_' prefix for all user symbols */ #ifndef MODULE_SYMBOL_PREFIX @@ -425,6 +424,7 @@ const struct exception_table_entry *search_module_extables(unsigned long addr); int register_module_notifier(struct notifier_block * nb); int unregister_module_notifier(struct notifier_block * nb); +extern void print_modules(void); #else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_GPL(sym) @@ -505,6 +505,9 @@ static inline int unregister_module_notifier(struct notifier_block * nb) #define module_put_and_exit(code) do_exit(code) +static inline void print_modules(void) +{ +} #endif /* CONFIG_MODULES */ #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) diff --git a/kernel/module.c b/kernel/module.c index 1781faa9a1323..e7a73bac2d58a 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2040,6 +2040,17 @@ struct module *module_text_address(unsigned long addr) return NULL; } +/* Don't grab lock, we're oopsing. */ +void print_modules(void) +{ + struct module *mod; + + printk("Modules linked in:"); + list_for_each_entry(mod, &modules, list) + printk(" %s", mod->name); + printk("\n"); +} + #ifdef CONFIG_MODVERSIONS /* Generate the signature for struct module here, too, for modversions. */ void struct_module(struct module *mod) { return; } -- 2.53.0