* Dynamic Debug module.ddebug fake param enhancements
@ 2010-09-15 22:11 Thomas Renninger
2010-09-15 22:11 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 Thomas Renninger
` (3 more replies)
0 siblings, 4 replies; 23+ messages in thread
From: Thomas Renninger @ 2010-09-15 22:11 UTC (permalink / raw)
To: trenn; +Cc: bjorn.helgaas, gregkh, jbaron, linux-kernel
This is the replacment of a patch Greg queued up recently, but it had issues.
I am not happy with some parts of the code, but it works:
Compile tested on different architectures with different .configs
Tested on X86 32 and 64 bit.
Cleanups, comments, suggestions are very welcome.
I spent more time on this as expected. I can take care for minor
cleanups, etc. and repost.
Jason: if it gets more, you have to take over again, sorry.
I picked out the pnp layer to show ddebug enhancements and how built-in
drivers/components can make use of it.
First I thought about pci, but some parts are initialized long before
dynamic debug, still similar changes might also make sense there.
Thomas
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 2010-09-15 22:11 Dynamic Debug module.ddebug fake param enhancements Thomas Renninger @ 2010-09-15 22:11 ` Thomas Renninger 2010-09-17 19:54 ` Jason Baron 2010-09-15 22:11 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger ` (2 subsequent siblings) 3 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-15 22:11 UTC (permalink / raw) To: trenn; +Cc: bjorn.helgaas, gregkh, jbaron, linux-kernel Dynamic Debug allows enabling of pr_debug and dev_dbg messages at runtime. This is controlled via /sys/kernel/debug/dynamic_debug/control. One major drawback is that the whole initialization of a module cannot be tracked, because ddebug is only aware of debug strings of loaded modules. But this is the most interesting part... This patch introduces a fake module parameter module.ddebug(not shown in /sys/module/*/parameters, thus it does not use any resources/memory). If a module passes ddebug as a module parameter (e.g. via module.ddebug kernel boot param or via "modprobe module ddebug"), all debug strings of this module get activated by issuing "module module_name +p" internally (not via sysfs) when the module gets loaded. Possible enhancements for the future if ddebug might get extended with further flags: module.ddebug=flags Then module.ddebug="p" would be the same as module.ddebug, but if there is a "x" ddebug flag added, one could pass: module.ddebug="xp" which would result in such a dynamic debug query: module module_name +xp Modules must not use "ddebug" as module parameter or it will get ignored. If it's tried, a warning will show up at module load time that it will get ignored (only works for not built-in modules). Tested with (additional added pr_debug messages): options hp-wmi ddebug in modprobe.conf -> works and pr_debug messages issued at module initialization time show up. Also "p" flag gets set for the whole hp-wmi module: grep hp-wmi /sys/../dynamic_debug/control also tested with compiled-in modules, e.g. pnp.ddebug and an additional patch later in the patch series which instruments pnp code to work with ddebug. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- Documentation/dynamic-debug-howto.txt | 28 ++++++++++- include/linux/dynamic_debug.h | 15 ++++++ include/linux/moduleparam.h | 3 + kernel/module.c | 1 + kernel/params.c | 13 +++++- lib/dynamic_debug.c | 86 +++++++++++++++++++++++++++++++- 6 files changed, 141 insertions(+), 5 deletions(-) diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt index 58ea64a..ebbbbdd 100644 --- a/Documentation/dynamic-debug-howto.txt +++ b/Documentation/dynamic-debug-howto.txt @@ -213,7 +213,7 @@ Note also that there is no convenient syntax to remove all the flags at once, you need to use "-psc". -Debug messages during boot process +Debug Messages during Boot Process ================================== To be able to activate debug messages during the boot process, @@ -232,6 +232,32 @@ PCI (or other devices) initialization also is a hot candidate for using this boot parameter for debugging purposes. +Debug Messages at Module Initialization Time +============================================ + +Enabling debug messages inside a module is only possible if the module itself +is loaded already. If you unload a module, the dynamic debug flags associated +to its debug messages are lost. +Therefore, enabling debug messages that get processed at module initialization +time through the <debugfs>/dynamic_debug/control interface is not possible. +Instead, a "ddebug" module paramter can be passed: + + - via kernel boot parameter: + module.ddebug + + - as an ordinary module parameter via modprobe + modprobe module ddebug + + - or the parameter can be used permanently via modprobe.conf(.local) + options module ddebug + +The ddebug option is not implemented as an ordinary module parameter and thus +will not show up in /sys/module/module_name/parameters/ddebug +The settings can get reverted through the sysfs interface again when the +module got loaded as soon as debug messages are not needed anymore: +echo "module module_name -p" > <debugfs>/dynamic_debug/control +as described in the "Command Language Reference" chapter above. + Examples ======== diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 52c0da4..56c0c3a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -39,8 +39,13 @@ struct _ddebug { int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); +struct kernel_param; + #if defined(CONFIG_DYNAMIC_DEBUG) extern int ddebug_remove_module(const char *mod_name); +extern int ddebug_exec_query(char *query_string); +extern void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, unsigned num); #define __dynamic_dbg_enabled(dd) ({ \ int __ret = 0; \ @@ -77,6 +82,16 @@ static inline int ddebug_remove_module(const char *mod) { return 0; } +static inline int ddebug_exec_query(char *query_string) +{ + return 0; +} +static incline void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, + unsigned num) +{ + return 0; +} #define dynamic_pr_debug(fmt, ...) \ do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 82a9124..ab0c88c 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -251,4 +251,7 @@ static inline void module_param_sysfs_remove(struct module *mod) { } #endif +/* For being able to parse parameters the same way params.c does */ +extern char *next_arg(char *args, char **param, char **val); + #endif /* _LINUX_MODULE_PARAMS_H */ diff --git a/kernel/module.c b/kernel/module.c index d0b5f8d..3912e12 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2628,6 +2628,7 @@ static struct module *load_module(void __user *umod, list_add_rcu(&mod->list, &modules); mutex_unlock(&module_mutex); + ddebug_module_parse_args(mod->name, mod->args, mod->kp, mod->num_kp); /* Module is ready to execute: parsing args may do that. */ err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL); if (err < 0) diff --git a/kernel/params.c b/kernel/params.c index 0b30ecd..df06dc0 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -54,6 +54,7 @@ static int parse_one(char *param, int (*handle_unknown)(char *param, char *val)) { unsigned int i; + char *tmp; /* Find parameter */ for (i = 0; i < num_params; i++) { @@ -64,6 +65,16 @@ static int parse_one(char *param, } } + /* + * Ignore ddebug module params and module.ddebug boot params: + * Documentation/dynamic-debug-howto.txt + */ + tmp = strstr(param, ".ddebug"); + if (parameq(param, "ddebug") || (tmp && strlen(tmp) == 7)) { + DEBUGP("Ignoring ddebug parameter %s\n", param); + return 0; + } + if (handle_unknown) { DEBUGP("Unknown argument: calling %p\n", handle_unknown); return handle_unknown(param, val); @@ -75,7 +86,7 @@ static int parse_one(char *param, /* You can use " around spaces, but can't escape ". */ /* Hyphens and underscores equivalent in parameter names. */ -static char *next_arg(char *args, char **param, char **val) +char *next_arg(char *args, char **param, char **val) { unsigned int i, equals = 0; int in_quote = 0, quoted = 0; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a687d90..826ea2e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -10,6 +10,7 @@ */ #include <linux/kernel.h> +#include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kallsyms.h> @@ -27,9 +28,13 @@ #include <linux/debugfs.h> #include <linux/slab.h> +#include <asm/setup.h> + extern struct _ddebug __start___verbose[]; extern struct _ddebug __stop___verbose[]; +#define DDEBUG_STRING_SIZE 1024 + /* dynamic_debug_enabled, and dynamic_debug_enabled2 are bitmasks in which * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They * use independent hash functions, to reduce the chance of false positives. @@ -429,7 +434,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, return 0; } -static int ddebug_exec_query(char *query_string) +int ddebug_exec_query(char *query_string) { unsigned int flags = 0, mask = 0; struct ddebug_query query; @@ -437,6 +442,9 @@ static int ddebug_exec_query(char *query_string) int nwords; char *words[MAXWORDS]; + if (verbose) + printk(KERN_INFO "%s: got query: %s\n", __func__, query_string); + nwords = ddebug_tokenize(query_string, words, MAXWORDS); if (nwords <= 0) return -EINVAL; @@ -450,10 +458,10 @@ static int ddebug_exec_query(char *query_string) return 0; } -static __initdata char ddebug_setup_string[1024]; +static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE]; static __init int ddebug_setup_query(char *str) { - if (strlen(str) >= 1024) { + if (strlen(str) >= DDEBUG_STRING_SIZE) { pr_warning("ddebug boot param string too large\n"); return 0; } @@ -704,6 +712,76 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, } EXPORT_SYMBOL_GPL(ddebug_add_module); +/* We search for *ddebug* module params */ +void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, unsigned num) +{ + char ddebug[DDEBUG_STRING_SIZE], *param, *val, *args_it, *arg_dup_ptr; + int i; + + /* + * We must not modify the passed args string and need to store the + * kstrdup pointer to be able to free memory later, TBD: find a way + * to do this nicer + */ + arg_dup_ptr = args_it = kstrdup(args, GFP_KERNEL); + + if (verbose) + printk(KERN_INFO "%s: Parsing ARGS: -%s- of %s\n", + __func__, args_it, name); + + for (i = 0; i < num; i++) { + if (!strcmp("ddebug", params[i].name)) + pr_warning("Module %s uses reserved keyword " + "*ddebug* as parameter\n", name); + } + + /* Chew leading spaces */ + args_it = skip_spaces(args_it); + + while (*args_it) { + args_it = next_arg(args_it, ¶m, &val); + if (verbose) + printk(KERN_INFO "%s: Param: %s, val: %s\n", + __func__, param, val); + if (!strcmp(param, "ddebug")) { + pr_info("Enabling debugging for module %s\n", name); + snprintf(ddebug, DDEBUG_STRING_SIZE, "module %s +p", + name); + ddebug_exec_query(ddebug); + } + } + kfree(arg_dup_ptr); + if (verbose) + printk(KERN_INFO "%s: Finished %s parsing\n", __func__, name); +} +/* We search for module.ddebug kernel boot params */ +static void ddebug_boot_parse_args(void) +{ + char tmp_cmd_arr[COMMAND_LINE_SIZE], *tmp_cmd_ptr, *param, *val, *tmp; + char module[MODULE_NAME_LEN], ddebug[DDEBUG_STRING_SIZE]; + + /* next_arg touches the passed buffer and chops each argument */ + strlcpy(tmp_cmd_arr, saved_command_line, COMMAND_LINE_SIZE); + /* Chew leading spaces */ + tmp_cmd_ptr = skip_spaces(tmp_cmd_arr); + + while (*tmp_cmd_ptr) { + tmp_cmd_ptr = next_arg(tmp_cmd_ptr, ¶m, &val); + if (verbose) + printk(KERN_INFO "%s: Param: %s, val: %s\n", + __func__, param, val); + tmp = strstr(param, ".ddebug"); + if (tmp && strlen(tmp) == 7) { + strlcpy(module, param, tmp - param + 1); + pr_info("Enabling debugging for module %s\n", module); + snprintf(ddebug, DDEBUG_STRING_SIZE, "module %s +p", + module); + ddebug_exec_query(ddebug); + } + } +} + static void ddebug_table_free(struct ddebug_table *dt) { list_del_init(&dt->link); @@ -805,6 +883,8 @@ static int __init dynamic_debug_init(void) ddebug_setup_string); } + ddebug_boot_parse_args(); + out_free: if (ret) ddebug_remove_all_tables(); -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 2010-09-15 22:11 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 Thomas Renninger @ 2010-09-17 19:54 ` Jason Baron 2010-09-17 21:52 ` Thomas Renninger 0 siblings, 1 reply; 23+ messages in thread From: Jason Baron @ 2010-09-17 19:54 UTC (permalink / raw) To: Thomas Renninger; +Cc: bjorn.helgaas, gregkh, linux-kernel On Thu, Sep 16, 2010 at 12:11:45AM +0200, Thomas Renninger wrote: > Dynamic Debug allows enabling of pr_debug and dev_dbg messages at runtime. > This is controlled via /sys/kernel/debug/dynamic_debug/control. > One major drawback is that the whole initialization of a module cannot be > tracked, because ddebug is only aware of debug strings of loaded modules. > But this is the most interesting part... > > This patch introduces a fake module parameter module.ddebug(not shown in > /sys/module/*/parameters, thus it does not use any resources/memory). > > If a module passes ddebug as a module parameter (e.g. via module.ddebug > kernel boot param or via "modprobe module ddebug"), all debug strings of this > module get activated by issuing "module module_name +p" internally > (not via sysfs) when the module gets loaded. > > Possible enhancements for the future if ddebug might get extended with > further flags: > module.ddebug=flags > Then module.ddebug="p" would be the same as module.ddebug, but if there > is a "x" ddebug flag added, one could pass: > module.ddebug="xp" > which would result in such a dynamic debug query: > module module_name +xp > > Modules must not use "ddebug" as module parameter or it will get ignored. > If it's tried, a warning will show up at module load time that it will get > ignored (only works for not built-in modules). > > Tested with (additional added pr_debug messages): > options hp-wmi ddebug > in modprobe.conf > -> works and pr_debug messages issued at module initialization time show > up. Also "p" flag gets set for the whole hp-wmi module: > grep hp-wmi /sys/../dynamic_debug/control > also tested with compiled-in modules, e.g. pnp.ddebug and an additional > patch later in the patch series which instruments pnp code to work with ddebug. > > Signed-off-by: Thomas Renninger <trenn@suse.de> > CC: Bjorn Helgaas <bjorn.helgaas@hp.com> > CC: Jason Baron <jbaron@redhat.com> > CC: Greg KH <gregkh@suse.de> > CC: lkml <linux-kernel@vger.kernel.org> > --- > Documentation/dynamic-debug-howto.txt | 28 ++++++++++- > include/linux/dynamic_debug.h | 15 ++++++ > include/linux/moduleparam.h | 3 + > kernel/module.c | 1 + > kernel/params.c | 13 +++++- > lib/dynamic_debug.c | 86 +++++++++++++++++++++++++++++++- > 6 files changed, 141 insertions(+), 5 deletions(-) > > diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt > index 58ea64a..ebbbbdd 100644 > --- a/Documentation/dynamic-debug-howto.txt > +++ b/Documentation/dynamic-debug-howto.txt > @@ -213,7 +213,7 @@ Note also that there is no convenient syntax to remove all > the flags at once, you need to use "-psc". > > > -Debug messages during boot process > +Debug Messages during Boot Process > ================================== > > To be able to activate debug messages during the boot process, > @@ -232,6 +232,32 @@ PCI (or other devices) initialization also is a hot candidate for using > this boot parameter for debugging purposes. > > > +Debug Messages at Module Initialization Time > +============================================ > + > +Enabling debug messages inside a module is only possible if the module itself > +is loaded already. If you unload a module, the dynamic debug flags associated > +to its debug messages are lost. > +Therefore, enabling debug messages that get processed at module initialization > +time through the <debugfs>/dynamic_debug/control interface is not possible. > +Instead, a "ddebug" module paramter can be passed: > + > + - via kernel boot parameter: > + module.ddebug > + > + - as an ordinary module parameter via modprobe > + modprobe module ddebug > + > + - or the parameter can be used permanently via modprobe.conf(.local) > + options module ddebug > + > +The ddebug option is not implemented as an ordinary module parameter and thus > +will not show up in /sys/module/module_name/parameters/ddebug > +The settings can get reverted through the sysfs interface again when the > +module got loaded as soon as debug messages are not needed anymore: > +echo "module module_name -p" > <debugfs>/dynamic_debug/control > +as described in the "Command Language Reference" chapter above. > + > Examples > ======== > > diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h > index 52c0da4..56c0c3a 100644 > --- a/include/linux/dynamic_debug.h > +++ b/include/linux/dynamic_debug.h > @@ -39,8 +39,13 @@ struct _ddebug { > int ddebug_add_module(struct _ddebug *tab, unsigned int n, > const char *modname); > > +struct kernel_param; > + > #if defined(CONFIG_DYNAMIC_DEBUG) > extern int ddebug_remove_module(const char *mod_name); > +extern int ddebug_exec_query(char *query_string); > +extern void ddebug_module_parse_args(const char *name, char* args, > + struct kernel_param *params, unsigned num); > > #define __dynamic_dbg_enabled(dd) ({ \ > int __ret = 0; \ > @@ -77,6 +82,16 @@ static inline int ddebug_remove_module(const char *mod) > { > return 0; > } > +static inline int ddebug_exec_query(char *query_string) > +{ > + return 0; > +} > +static incline void ddebug_module_parse_args(const char *name, char* args, > + struct kernel_param *params, > + unsigned num) > +{ > + return 0; > +} > > #define dynamic_pr_debug(fmt, ...) \ > do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) > diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h > index 82a9124..ab0c88c 100644 > --- a/include/linux/moduleparam.h > +++ b/include/linux/moduleparam.h > @@ -251,4 +251,7 @@ static inline void module_param_sysfs_remove(struct module *mod) > { } > #endif > > +/* For being able to parse parameters the same way params.c does */ > +extern char *next_arg(char *args, char **param, char **val); > + > #endif /* _LINUX_MODULE_PARAMS_H */ > diff --git a/kernel/module.c b/kernel/module.c > index d0b5f8d..3912e12 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -2628,6 +2628,7 @@ static struct module *load_module(void __user *umod, > list_add_rcu(&mod->list, &modules); > mutex_unlock(&module_mutex); > > + ddebug_module_parse_args(mod->name, mod->args, mod->kp, mod->num_kp); > /* Module is ready to execute: parsing args may do that. */ > err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL); > if (err < 0) > diff --git a/kernel/params.c b/kernel/params.c > index 0b30ecd..df06dc0 100644 > --- a/kernel/params.c > +++ b/kernel/params.c > @@ -54,6 +54,7 @@ static int parse_one(char *param, > int (*handle_unknown)(char *param, char *val)) > { > unsigned int i; > + char *tmp; > > /* Find parameter */ > for (i = 0; i < num_params; i++) { > @@ -64,6 +65,16 @@ static int parse_one(char *param, > } > } > > + /* > + * Ignore ddebug module params and module.ddebug boot params: > + * Documentation/dynamic-debug-howto.txt > + */ > + tmp = strstr(param, ".ddebug"); > + if (parameq(param, "ddebug") || (tmp && strlen(tmp) == 7)) { > + DEBUGP("Ignoring ddebug parameter %s\n", param); > + return 0; > + } > + > if (handle_unknown) { > DEBUGP("Unknown argument: calling %p\n", handle_unknown); > return handle_unknown(param, val); > @@ -75,7 +86,7 @@ static int parse_one(char *param, > > /* You can use " around spaces, but can't escape ". */ > /* Hyphens and underscores equivalent in parameter names. */ > -static char *next_arg(char *args, char **param, char **val) > +char *next_arg(char *args, char **param, char **val) > { > unsigned int i, equals = 0; > int in_quote = 0, quoted = 0; > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > index a687d90..826ea2e 100644 > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -10,6 +10,7 @@ > */ > > #include <linux/kernel.h> > +#include <linux/init.h> > #include <linux/module.h> > #include <linux/moduleparam.h> > #include <linux/kallsyms.h> > @@ -27,9 +28,13 @@ > #include <linux/debugfs.h> > #include <linux/slab.h> > > +#include <asm/setup.h> > + > extern struct _ddebug __start___verbose[]; > extern struct _ddebug __stop___verbose[]; > > +#define DDEBUG_STRING_SIZE 1024 > + > /* dynamic_debug_enabled, and dynamic_debug_enabled2 are bitmasks in which > * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They > * use independent hash functions, to reduce the chance of false positives. > @@ -429,7 +434,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, > return 0; > } > > -static int ddebug_exec_query(char *query_string) > +int ddebug_exec_query(char *query_string) > { > unsigned int flags = 0, mask = 0; > struct ddebug_query query; > @@ -437,6 +442,9 @@ static int ddebug_exec_query(char *query_string) > int nwords; > char *words[MAXWORDS]; > > + if (verbose) > + printk(KERN_INFO "%s: got query: %s\n", __func__, query_string); > + > nwords = ddebug_tokenize(query_string, words, MAXWORDS); > if (nwords <= 0) > return -EINVAL; > @@ -450,10 +458,10 @@ static int ddebug_exec_query(char *query_string) > return 0; > } > > -static __initdata char ddebug_setup_string[1024]; > +static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE]; > static __init int ddebug_setup_query(char *str) > { > - if (strlen(str) >= 1024) { > + if (strlen(str) >= DDEBUG_STRING_SIZE) { > pr_warning("ddebug boot param string too large\n"); > return 0; > } > @@ -704,6 +712,76 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, > } > EXPORT_SYMBOL_GPL(ddebug_add_module); > > +/* We search for *ddebug* module params */ > +void ddebug_module_parse_args(const char *name, char* args, > + struct kernel_param *params, unsigned num) > +{ > + char ddebug[DDEBUG_STRING_SIZE], *param, *val, *args_it, *arg_dup_ptr; > + int i; > + > + /* > + * We must not modify the passed args string and need to store the > + * kstrdup pointer to be able to free memory later, TBD: find a way > + * to do this nicer > + */ > + arg_dup_ptr = args_it = kstrdup(args, GFP_KERNEL); > + > + if (verbose) > + printk(KERN_INFO "%s: Parsing ARGS: -%s- of %s\n", > + __func__, args_it, name); > + > + for (i = 0; i < num; i++) { > + if (!strcmp("ddebug", params[i].name)) > + pr_warning("Module %s uses reserved keyword " > + "*ddebug* as parameter\n", name); > + } > + > + /* Chew leading spaces */ > + args_it = skip_spaces(args_it); > + > + while (*args_it) { > + args_it = next_arg(args_it, ¶m, &val); > + if (verbose) > + printk(KERN_INFO "%s: Param: %s, val: %s\n", > + __func__, param, val); > + if (!strcmp(param, "ddebug")) { > + pr_info("Enabling debugging for module %s\n", name); > + snprintf(ddebug, DDEBUG_STRING_SIZE, "module %s +p", > + name); > + ddebug_exec_query(ddebug); > + } > + } > + kfree(arg_dup_ptr); > + if (verbose) > + printk(KERN_INFO "%s: Finished %s parsing\n", __func__, name); > +} > +/* We search for module.ddebug kernel boot params */ > +static void ddebug_boot_parse_args(void) > +{ > + char tmp_cmd_arr[COMMAND_LINE_SIZE], *tmp_cmd_ptr, *param, *val, *tmp; > + char module[MODULE_NAME_LEN], ddebug[DDEBUG_STRING_SIZE]; > + > + /* next_arg touches the passed buffer and chops each argument */ > + strlcpy(tmp_cmd_arr, saved_command_line, COMMAND_LINE_SIZE); > + /* Chew leading spaces */ > + tmp_cmd_ptr = skip_spaces(tmp_cmd_arr); > + > + while (*tmp_cmd_ptr) { > + tmp_cmd_ptr = next_arg(tmp_cmd_ptr, ¶m, &val); > + if (verbose) > + printk(KERN_INFO "%s: Param: %s, val: %s\n", > + __func__, param, val); > + tmp = strstr(param, ".ddebug"); > + if (tmp && strlen(tmp) == 7) { > + strlcpy(module, param, tmp - param + 1); > + pr_info("Enabling debugging for module %s\n", module); > + snprintf(ddebug, DDEBUG_STRING_SIZE, "module %s +p", > + module); > + ddebug_exec_query(ddebug); > + } > + } > +} > + > static void ddebug_table_free(struct ddebug_table *dt) > { > list_del_init(&dt->link); > @@ -805,6 +883,8 @@ static int __init dynamic_debug_init(void) > ddebug_setup_string); > } > > + ddebug_boot_parse_args(); > + > out_free: > if (ret) > ddebug_remove_all_tables(); > -- > 1.6.0.2 > Hi, So i'm wondering if need to support the module.ddebug on the command line? The ddebug_query="module foo +p" format that you introduced does the same thing. Also, we can't put those large char[] arrays on the kernel stack. They probably should be global. thanks, -Jason ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 2010-09-17 19:54 ` Jason Baron @ 2010-09-17 21:52 ` Thomas Renninger 2010-09-20 18:44 ` Jason Baron 0 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-17 21:52 UTC (permalink / raw) To: Jason Baron; +Cc: bjorn.helgaas, gregkh, linux-kernel > Hi, > > So i'm wondering if need to support the module.ddebug on the command > line? Yep, that would make things a bit easier... People would e.g. have to use ddebug_query="module pnp +p" (which already is available with the patch that is queued in linux-next) instead of pnp.ddebug. Not that obvious or say user friendly, though. > The ddebug_query="module foo +p" format that you introduced does > the same thing. No that does not work for real (not built-in) modules. Give it a try... The stuff needs to be set up when the module is loaded. If you have a real module declared as =m You need to call "module foo +p" when the module gets/got loaded. But ddebug_query="..." only gets executed once, when dynamic debug gets set up, far before any module got loaded. > Also, we can't put those large char[] arrays on the kernel stack. They > probably should be global. Where exactly, the command line(*args)? Thomas ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 2010-09-17 21:52 ` Thomas Renninger @ 2010-09-20 18:44 ` Jason Baron 2010-09-24 12:18 ` Thomas Renninger ` (5 more replies) 0 siblings, 6 replies; 23+ messages in thread From: Jason Baron @ 2010-09-20 18:44 UTC (permalink / raw) To: Thomas Renninger; +Cc: bjorn.helgaas, gregkh, linux-kernel On Fri, Sep 17, 2010 at 11:52:46PM +0200, Thomas Renninger wrote: > > Hi, > > > > So i'm wondering if need to support the module.ddebug on the command > > line? > Yep, that would make things a bit easier... > People would e.g. have to use ddebug_query="module pnp +p" (which > already is available with the patch that is queued in linux-next) > instead of pnp.ddebug. Not that obvious or say user friendly, though. > > > The ddebug_query="module foo +p" format that you introduced does > > the same thing. > No that does not work for real (not built-in) modules. Give it a try... > The stuff needs to be set up when the module is loaded. > If you have a real module declared as =m > You need to call "module foo +p" when the module gets/got loaded. > But ddebug_query="..." only gets executed once, when > dynamic debug gets set up, far before any module got loaded. > ok, to be consistent, if passing 'ddebug' as a module parameter when a module loads, we also need for module.ddebug to work, as that is how other module parameters work. > > Also, we can't put those large char[] arrays on the kernel stack. They > > probably should be global. > Where exactly, the command line(*args)? > The character arrays, that put COMMAND_LINE_SIZE and DDEBUG_STRING_SIZE on the stack are too large. Also, ddebug_boot_parse_args() should be marked as '__init' since it only used on boot. thanks, -Jason ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 2010-09-20 18:44 ` Jason Baron @ 2010-09-24 12:18 ` Thomas Renninger 2010-09-24 12:28 ` Dynamic Debug module.ddebug fake param enhancements V4 Thomas Renninger ` (4 subsequent siblings) 5 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:18 UTC (permalink / raw) To: Jason Baron; +Cc: bjorn.helgaas, gregkh, linux-kernel On Monday 20 September 2010 08:44:41 pm Jason Baron wrote: > On Fri, Sep 17, 2010 at 11:52:46PM +0200, Thomas Renninger wrote: > > > Hi, > > > > > > So i'm wondering if need to support the module.ddebug on the command > > > line? > > > > Yep, that would make things a bit easier... > > People would e.g. have to use ddebug_query="module pnp +p" (which > > already is available with the patch that is queued in linux-next) > > instead of pnp.ddebug. Not that obvious or say user friendly, though. > > > > > The ddebug_query="module foo +p" format that you introduced does > > > the same thing. > > > > No that does not work for real (not built-in) modules. Give it a try... > > The stuff needs to be set up when the module is loaded. > > If you have a real module declared as =m > > You need to call "module foo +p" when the module gets/got loaded. > > But ddebug_query="..." only gets executed once, when > > dynamic debug gets set up, far before any module got loaded. > > ok, to be consistent, if passing 'ddebug' as a module parameter when a > module loads, we also need for module.ddebug to work, as that is how > other module parameters work. > > > > Also, we can't put those large char[] arrays on the kernel stack. They > > > probably should be global. > > > > Where exactly, the command line(*args)? > > The character arrays, that put COMMAND_LINE_SIZE I dynamically malloc (kstrdup) the command line now. > and DDEBUG_STRING_SIZE I reuse an __initdata var I already have for that. > on the stack are too large. Also, ddebug_boot_parse_args() should be > marked as '__init' since it only used on boot. Yep. I'll repost all 4 patches: - The first is the ddebug fake parameter. - 2x pnp compile in one namespace - minor compile fixups if DEBUGP is defined in kernel/modules.c Thanks, Thomas ^ permalink raw reply [flat|nested] 23+ messages in thread
* Dynamic Debug module.ddebug fake param enhancements V4 2010-09-20 18:44 ` Jason Baron 2010-09-24 12:18 ` Thomas Renninger @ 2010-09-24 12:28 ` Thomas Renninger 2010-09-24 14:56 ` Bjorn Helgaas 2010-09-24 12:28 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 Thomas Renninger ` (3 subsequent siblings) 5 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:28 UTC (permalink / raw) To: gregkh; +Cc: linux-kernel, bjorn.helgaas, jbaron The patches are intended for Greg's tree and depend on 3 other dynamic debug patches which already are in linux-next, but not in the vanilla kernel yet. [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 V3 -> V4: Do not put that large arrays on the stack, make one func __init [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in -> Compile PNP subsystem in a separate pnp module namespace [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug is compiled in -> minor compile fixup Only the two PNP patches really belong together. If someone e.g. complains about the PNP patches, please still submit the rest. Thanks, Thomas ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-24 12:28 ` Dynamic Debug module.ddebug fake param enhancements V4 Thomas Renninger @ 2010-09-24 14:56 ` Bjorn Helgaas 2010-09-27 8:25 ` Thomas Renninger 0 siblings, 1 reply; 23+ messages in thread From: Bjorn Helgaas @ 2010-09-24 14:56 UTC (permalink / raw) To: Thomas Renninger; +Cc: gregkh, linux-kernel, jbaron On Friday, September 24, 2010 06:28:27 am Thomas Renninger wrote: > The patches are intended for Greg's tree and depend on 3 other > dynamic debug patches which already are in linux-next, but not in > the vanilla kernel yet. > > [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 > V3 -> V4: Do not put that large arrays on the stack, make one func __init > > [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace > [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in > -> Compile PNP subsystem in a separate pnp module namespace > > [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug is compiled in > -> minor compile fixup > > Only the two PNP patches really belong together. > If someone e.g. complains about the PNP patches, please still submit the rest. I confess that I don't understand the objective here (only because I haven't taken enough time to read and understand the patches). Some examples of how you expect to use this would probably help me understand. And if you can compare that with the current, more difficult way, that would be even better. I don't know if it's relevant, but I plan to change some of the pnp_dbg() uses to dev_printk(KERN_DEBUG). Specifically, mainline already logs all PCI device BARs with KERN_DEBUG, so that information is always in dmesg. PNP currently uses pnp_dbg() for the corresponding ACPI device resource usage, so to get that information, I often have to request another boot with CONFIG_PNP_DEBUG_MESSAGES=y and "pnp.debug". I want to convert those resource messages to dev_printk(KERN_DEBUG) so they're just always in dmesg. Bjorn ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-24 14:56 ` Bjorn Helgaas @ 2010-09-27 8:25 ` Thomas Renninger 2010-09-27 15:09 ` Bjorn Helgaas 0 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-27 8:25 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: gregkh, linux-kernel, jbaron On Friday 24 September 2010 16:56:16 Bjorn Helgaas wrote: > On Friday, September 24, 2010 06:28:27 am Thomas Renninger wrote: > > The patches are intended for Greg's tree and depend on 3 other > > dynamic debug patches which already are in linux-next, but not in > > the vanilla kernel yet. > > > > [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 > > V3 -> V4: Do not put that large arrays on the stack, make one func __init > > > > [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace > > [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in > > -> Compile PNP subsystem in a separate pnp module namespace > > > > [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug is compiled in > > -> minor compile fixup > > > > Only the two PNP patches really belong together. > > If someone e.g. complains about the PNP patches, please still submit the rest. > > I confess that I don't understand the objective here (only because > I haven't taken enough time to read and understand the patches). > > Some examples of how you expect to use this would probably help me > understand. And if you can compare that with the current, more > difficult way, that would be even better. Yep: Currently you do have to compile in PNP_DEBUG (or similar) to get some interesting resource debug messages. > > I don't know if it's relevant, but I plan to change some of the > pnp_dbg() uses to dev_printk(KERN_DEBUG). That would mess up dynamic debug with these messages. Both, dev_dbg and dev_printk(KERN_DEBUG..) has advantages and disadvantages. Below some background about dev_dbg combined with CONFIG_DYNAMIC_DEBUG. > Specifically, mainline > already logs all PCI device BARs with KERN_DEBUG, so that information > is always in dmesg. PNP currently uses pnp_dbg() for the corresponding > ACPI device resource usage, so to get that information, I often have > to request another boot with CONFIG_PNP_DEBUG_MESSAGES=y and "pnp.debug". Yep, the idea is that this is not necessary anymore. But dynamic debug has an advantage compared to printk(KERN_DEBUG.. You can explicitly define which module or even which file you want to enable the debug messages (with this patch(es) the whole pnp code would be compiled into one built-in module namespace). E.g. pnp.ddebug boot param would enable all dev_dbg and pr_debug messages in: driver/pnp/* -r One disadvantage: this doesn't really work with (all) pci code, because some of the PCI initialization is a way too early for ddebug (e.g. early quirks). > I want to convert those resource messages to dev_printk(KERN_DEBUG) so > they're just always in dmesg. I hit the same, e.g. with pnp and driver/acpi/ec.c, there are some dev_dbg in there... with dynamic debug you can enable ec.c debug messages by: acpi.ddebug (because nearly all in drivers/acpi/* -r is compiled into a global acpi module namespace, I got the idea for pnp- Makefile prefix from there). Or you can even specify the file: ddebug_query="file drivers/acpi/ec.c +p" or ddebug_query="file ec.c +p" (afaik works as well) all other dev_dbg and pr_debug messages stay hidden. SLE11-SP1 already has DYNAMIC_DEBUG enabled More info: Documentation/dynamic-debug-howto.txt If you take a kernel from here: ftp://ftp.suse.com/pub/projects/kernel/kotd/master I added my patches there for some testing now. There the additional boot params query_ddebug="" and module.ddebug are described in the source package, in: Documentation/dynamic-debug-howto.txt You can simply run a: pnp.ddebug to see quite some pnp output without CONFIG_PNP_DEBUG_MESSAGES defined. What do you think (dev_dbg vs printk(KERN_DEBUG...)? Thomas ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-27 8:25 ` Thomas Renninger @ 2010-09-27 15:09 ` Bjorn Helgaas 2010-09-28 12:25 ` Thomas Renninger 0 siblings, 1 reply; 23+ messages in thread From: Bjorn Helgaas @ 2010-09-27 15:09 UTC (permalink / raw) To: Thomas Renninger; +Cc: gregkh, linux-kernel, jbaron On Monday, September 27, 2010 02:25:46 am Thomas Renninger wrote: > What do you think (dev_dbg vs printk(KERN_DEBUG...)? Well, 99% of the time, what I want is simply the resource usage of all the devices in the system. Currently, a dmesg log gives me that for PCI devices. I plan to change PNP so the dmesg log will also contain that for PNP devices. That's simple and requires no user action at all and no extra boots. The times when we need more extensive debugging are rare enough that I'm not sure it's worth keeping them compiled into the kernel, even if they are turned off by default (I understand the tradeoff from a distro point of view might be different). With the exception of the ones in pnp/resource.c that I want to convert to dev_printk(KERN_DEBUG), I think all the pnp_dbg() uses are things I used during PNP development and haven't ever needed since. Bjorn ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-27 15:09 ` Bjorn Helgaas @ 2010-09-28 12:25 ` Thomas Renninger 2010-09-28 14:22 ` Bjorn Helgaas 0 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-28 12:25 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: gregkh, linux-kernel, jbaron Greg: Do you mind pushing the first (1/4, V4) and the last (4/4) patch into your tree for linux-next and leave the two PNP patches out, please. More PNP related discussion, below. On Monday 27 September 2010 17:09:18 Bjorn Helgaas wrote: > On Monday, September 27, 2010 02:25:46 am Thomas Renninger wrote: > > > What do you think (dev_dbg vs printk(KERN_DEBUG...)? ... > With the exception of the ones in pnp/resource.c that I want to convert > to dev_printk(KERN_DEBUG), I think all the pnp_dbg() uses are things > I used during PNP development and haven't ever needed since. Ok. Sounds sane. I used the PNP parts as it nicely showed what the module.ddebug boot param is doing, but I agree it hasn't much advantage for PNP. Whatabout compiling pnp in one module namespace, the first of the two PNP patches? I do not see an urgent need/advantage, it would just be a general cleanup. PNP could then make use of moduleparam.h interface instead of using __setup(..). E.g. attached patch would be an on top patch which provides no functional change, just that a pnp.debug would be a module param: cat /sys/module/pnp/parameters/debug Again there is not much use for this with pnp as all should be processed at boot time. But theoretically one could enable pnp.debug at runtime :) (or it should get hidden with 0000 perms if not needed). It's more a general cleanup, further pnp boot params can be pnp.xy module params then. Bjoern: If you like them I can repost these two: (PNP build in one module namespace and below) Thomas --------- PNP: Set up pnp_debug via module and not via boot param. Cleanup only, no functional change (pnp.debug can be enabled and disabled at runtime, but that's not a real enhancement). This one depends on another PNP cleanup patch: PNP: Compile all pnp built-in stuff in one module namespace Signed-off-by: Thomas Renninger <trenn@suse.de> diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 88b3cde..9801918 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -218,10 +218,5 @@ subsys_initcall(pnp_init); int pnp_debug; #if defined(CONFIG_PNP_DEBUG_MESSAGES) -static int __init pnp_debug_setup(char *__unused) -{ - pnp_debug = 1; - return 1; -} -__setup("pnp.debug", pnp_debug_setup); +module_param_named(debug, pnp_debug, int, 0644); #endif ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-28 12:25 ` Thomas Renninger @ 2010-09-28 14:22 ` Bjorn Helgaas 2010-10-06 20:59 ` Greg KH 0 siblings, 1 reply; 23+ messages in thread From: Bjorn Helgaas @ 2010-09-28 14:22 UTC (permalink / raw) To: Thomas Renninger; +Cc: gregkh, linux-kernel, jbaron On Tuesday, September 28, 2010 06:25:18 am Thomas Renninger wrote: > Greg: Do you mind pushing the first (1/4, V4) and the last (4/4) > patch into your tree for linux-next and leave the two PNP patches > out, please. > > More PNP related discussion, below. > > On Monday 27 September 2010 17:09:18 Bjorn Helgaas wrote: > > On Monday, September 27, 2010 02:25:46 am Thomas Renninger wrote: > > > > > What do you think (dev_dbg vs printk(KERN_DEBUG...)? > ... > > With the exception of the ones in pnp/resource.c that I want to convert > > to dev_printk(KERN_DEBUG), I think all the pnp_dbg() uses are things > > I used during PNP development and haven't ever needed since. > > Ok. Sounds sane. > I used the PNP parts as it nicely showed what the > module.ddebug boot param is doing, but I agree it hasn't much > advantage for PNP. > > Whatabout compiling pnp in one module namespace, the first > of the two PNP patches? [2/4] looks reasonable to me. > E.g. attached patch would be an on top patch which provides no > functional change, just that a pnp.debug would be a module param: > cat /sys/module/pnp/parameters/debug As does the one below. > --------- > PNP: Set up pnp_debug via module and not via boot param. > > Cleanup only, no functional change (pnp.debug can be enabled > and disabled at runtime, but that's not a real enhancement). > > This one depends on another PNP cleanup patch: > PNP: Compile all pnp built-in stuff in one module namespace > > Signed-off-by: Thomas Renninger <trenn@suse.de> > > diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c > index 88b3cde..9801918 100644 > --- a/drivers/pnp/core.c > +++ b/drivers/pnp/core.c > @@ -218,10 +218,5 @@ subsys_initcall(pnp_init); > int pnp_debug; > > #if defined(CONFIG_PNP_DEBUG_MESSAGES) > -static int __init pnp_debug_setup(char *__unused) > -{ > - pnp_debug = 1; > - return 1; > -} > -__setup("pnp.debug", pnp_debug_setup); > +module_param_named(debug, pnp_debug, int, 0644); > #endif > ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Dynamic Debug module.ddebug fake param enhancements V4 2010-09-28 14:22 ` Bjorn Helgaas @ 2010-10-06 20:59 ` Greg KH 0 siblings, 0 replies; 23+ messages in thread From: Greg KH @ 2010-10-06 20:59 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Thomas Renninger, gregkh, linux-kernel, jbaron On Tue, Sep 28, 2010 at 08:22:11AM -0600, Bjorn Helgaas wrote: > On Tuesday, September 28, 2010 06:25:18 am Thomas Renninger wrote: > > Greg: Do you mind pushing the first (1/4, V4) and the last (4/4) > > patch into your tree for linux-next and leave the two PNP patches > > out, please. I've applied them now. > > More PNP related discussion, below. > > > > On Monday 27 September 2010 17:09:18 Bjorn Helgaas wrote: > > > On Monday, September 27, 2010 02:25:46 am Thomas Renninger wrote: > > > > > > > What do you think (dev_dbg vs printk(KERN_DEBUG...)? > > ... > > > With the exception of the ones in pnp/resource.c that I want to convert > > > to dev_printk(KERN_DEBUG), I think all the pnp_dbg() uses are things > > > I used during PNP development and haven't ever needed since. > > > > Ok. Sounds sane. > > I used the PNP parts as it nicely showed what the > > module.ddebug boot param is doing, but I agree it hasn't much > > advantage for PNP. > > > > Whatabout compiling pnp in one module namespace, the first > > of the two PNP patches? > > [2/4] looks reasonable to me. And this one. > > > E.g. attached patch would be an on top patch which provides no > > functional change, just that a pnp.debug would be a module param: > > cat /sys/module/pnp/parameters/debug > > As does the one below. And this one. So that left 3/4 out of the series applied to my tree. If this is incorrect, please let me know. thanks, greg k-h ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 2010-09-20 18:44 ` Jason Baron 2010-09-24 12:18 ` Thomas Renninger 2010-09-24 12:28 ` Dynamic Debug module.ddebug fake param enhancements V4 Thomas Renninger @ 2010-09-24 12:28 ` Thomas Renninger 2010-10-06 21:16 ` Greg KH 2010-09-24 12:28 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger ` (2 subsequent siblings) 5 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:28 UTC (permalink / raw) To: gregkh; +Cc: linux-kernel, bjorn.helgaas, jbaron, Thomas Renninger Dynamic Debug allows enabling of pr_debug and dev_dbg messages at runtime. This is controlled via /sys/kernel/debug/dynamic_debug/control. One major drawback is that the whole initialization of a module cannot be tracked, because ddebug is only aware of debug strings of loaded modules. But this is the most interesting part... This patch introduces a fake module parameter module.ddebug(not shown in /sys/module/*/parameters, thus it does not use any resources/memory). If a module passes ddebug as a module parameter (e.g. via module.ddebug kernel boot param or via "modprobe module ddebug"), all debug strings of this module get activated by issuing "module module_name +p" internally (not via sysfs) when the module gets loaded. Possible enhancements for the future if ddebug might get extended with further flags: module.ddebug=flags Then module.ddebug="p" would be the same as module.ddebug, but if there is a "x" ddebug flag added, one could pass: module.ddebug="xp" which would result in such a dynamic debug query: module module_name +xp Modules must not use "ddebug" as module parameter or it will get ignored. If it's tried, a warning will show up at module load time that it will get ignored (only works for not built-in modules). Tested with (additional added pr_debug messages): options hp-wmi ddebug in modprobe.conf -> works and pr_debug messages issued at module initialization time show up. Also "p" flag gets set for the whole hp-wmi module: grep hp-wmi /sys/../dynamic_debug/control also tested with compiled-in modules, e.g. pnp.ddebug and an additional patch later in the patch series which instruments pnp code to work with ddebug. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- Documentation/dynamic-debug-howto.txt | 28 ++++++++++- include/linux/dynamic_debug.h | 15 ++++++ include/linux/moduleparam.h | 3 + kernel/module.c | 1 + kernel/params.c | 13 +++++- lib/dynamic_debug.c | 89 +++++++++++++++++++++++++++++++- 6 files changed, 144 insertions(+), 5 deletions(-) diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt index 58ea64a..ebbbbdd 100644 --- a/Documentation/dynamic-debug-howto.txt +++ b/Documentation/dynamic-debug-howto.txt @@ -213,7 +213,7 @@ Note also that there is no convenient syntax to remove all the flags at once, you need to use "-psc". -Debug messages during boot process +Debug Messages during Boot Process ================================== To be able to activate debug messages during the boot process, @@ -232,6 +232,32 @@ PCI (or other devices) initialization also is a hot candidate for using this boot parameter for debugging purposes. +Debug Messages at Module Initialization Time +============================================ + +Enabling debug messages inside a module is only possible if the module itself +is loaded already. If you unload a module, the dynamic debug flags associated +to its debug messages are lost. +Therefore, enabling debug messages that get processed at module initialization +time through the <debugfs>/dynamic_debug/control interface is not possible. +Instead, a "ddebug" module paramter can be passed: + + - via kernel boot parameter: + module.ddebug + + - as an ordinary module parameter via modprobe + modprobe module ddebug + + - or the parameter can be used permanently via modprobe.conf(.local) + options module ddebug + +The ddebug option is not implemented as an ordinary module parameter and thus +will not show up in /sys/module/module_name/parameters/ddebug +The settings can get reverted through the sysfs interface again when the +module got loaded as soon as debug messages are not needed anymore: +echo "module module_name -p" > <debugfs>/dynamic_debug/control +as described in the "Command Language Reference" chapter above. + Examples ======== diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 52c0da4..56c0c3a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -39,8 +39,13 @@ struct _ddebug { int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); +struct kernel_param; + #if defined(CONFIG_DYNAMIC_DEBUG) extern int ddebug_remove_module(const char *mod_name); +extern int ddebug_exec_query(char *query_string); +extern void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, unsigned num); #define __dynamic_dbg_enabled(dd) ({ \ int __ret = 0; \ @@ -77,6 +82,16 @@ static inline int ddebug_remove_module(const char *mod) { return 0; } +static inline int ddebug_exec_query(char *query_string) +{ + return 0; +} +static incline void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, + unsigned num) +{ + return 0; +} #define dynamic_pr_debug(fmt, ...) \ do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 9d2f183..5cec3cc 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -405,4 +405,7 @@ static inline void module_param_sysfs_remove(struct module *mod) { } #endif +/* For being able to parse parameters the same way params.c does */ +extern char *next_arg(char *args, char **param, char **val); + #endif /* _LINUX_MODULE_PARAMS_H */ diff --git a/kernel/module.c b/kernel/module.c index d0b5f8d..3912e12 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2628,6 +2628,7 @@ static struct module *load_module(void __user *umod, list_add_rcu(&mod->list, &modules); mutex_unlock(&module_mutex); + ddebug_module_parse_args(mod->name, mod->args, mod->kp, mod->num_kp); /* Module is ready to execute: parsing args may do that. */ err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL); if (err < 0) diff --git a/kernel/params.c b/kernel/params.c index 08107d1..44950c3 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -107,6 +107,16 @@ static int parse_one(char *param, } } + /* + * Ignore ddebug module params and module.ddebug boot params: + * Documentation/dynamic-debug-howto.txt + */ + tmp = strstr(param, ".ddebug"); + if (parameq(param, "ddebug") || (tmp && strlen(tmp) == 7)) { + DEBUGP("Ignoring ddebug parameter %s\n", param); + return 0; + } + if (handle_unknown) { DEBUGP("Unknown argument: calling %p\n", handle_unknown); return handle_unknown(param, val); @@ -118,7 +128,7 @@ static int parse_one(char *param, /* You can use " around spaces, but can't escape ". */ /* Hyphens and underscores equivalent in parameter names. */ -static char *next_arg(char *args, char **param, char **val) +char *next_arg(char *args, char **param, char **val) { unsigned int i, equals = 0; int in_quote = 0, quoted = 0; @@ -713,6 +723,7 @@ void module_param_sysfs_remove(struct module *mod) void destroy_params(const struct kernel_param *params, unsigned num) { unsigned int i; + char *tmp; for (i = 0; i < num; i++) if (params[i].ops->free) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a687d90..482ddc2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -10,6 +10,7 @@ */ #include <linux/kernel.h> +#include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kallsyms.h> @@ -27,9 +28,13 @@ #include <linux/debugfs.h> #include <linux/slab.h> +#include <asm/setup.h> + extern struct _ddebug __start___verbose[]; extern struct _ddebug __stop___verbose[]; +#define DDEBUG_STRING_SIZE 1024 + /* dynamic_debug_enabled, and dynamic_debug_enabled2 are bitmasks in which * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They * use independent hash functions, to reduce the chance of false positives. @@ -429,7 +434,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, return 0; } -static int ddebug_exec_query(char *query_string) +int ddebug_exec_query(char *query_string) { unsigned int flags = 0, mask = 0; struct ddebug_query query; @@ -437,6 +442,9 @@ static int ddebug_exec_query(char *query_string) int nwords; char *words[MAXWORDS]; + if (verbose) + printk(KERN_INFO "%s: got query: %s\n", __func__, query_string); + nwords = ddebug_tokenize(query_string, words, MAXWORDS); if (nwords <= 0) return -EINVAL; @@ -450,10 +458,10 @@ static int ddebug_exec_query(char *query_string) return 0; } -static __initdata char ddebug_setup_string[1024]; +static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE]; static __init int ddebug_setup_query(char *str) { - if (strlen(str) >= 1024) { + if (strlen(str) >= DDEBUG_STRING_SIZE) { pr_warning("ddebug boot param string too large\n"); return 0; } @@ -704,6 +712,78 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, } EXPORT_SYMBOL_GPL(ddebug_add_module); +/* We search for *ddebug* module params */ +void ddebug_module_parse_args(const char *name, char* args, + struct kernel_param *params, unsigned num) +{ + char *ddebug, *param, *val, *args_it, *arg_dup_ptr; + int i; + + /* + * We must not modify the passed args string and need to store the + * kstrdup pointer to be able to free memory later, TBD: find a way + * to do this nicer + */ + arg_dup_ptr = args_it = kstrdup(args, GFP_KERNEL); + ddebug = kzalloc(DDEBUG_STRING_SIZE, GFP_KERNEL); + if (verbose) + printk(KERN_INFO "%s: Parsing ARGS: -%s- of %s\n", + __func__, args_it, name); + + for (i = 0; i < num; i++) { + if (!strcmp("ddebug", params[i].name)) + pr_warning("Module %s uses reserved keyword " + "*ddebug* as parameter\n", name); + } + + /* Chew leading spaces */ + args_it = skip_spaces(args_it); + + while (*args_it) { + args_it = next_arg(args_it, ¶m, &val); + if (verbose) + printk(KERN_INFO "%s: Param: %s, val: %s\n", + __func__, param, val); + if (!strcmp(param, "ddebug")) { + pr_info("Enabling debugging for module %s\n", name); + snprintf(ddebug, DDEBUG_STRING_SIZE, "module %s +p", + name); + ddebug_exec_query(ddebug); + } + } + kfree(arg_dup_ptr); + kfree(ddebug); +} + +/* We search for module.ddebug kernel boot params */ +static void __init ddebug_boot_parse_args(void) +{ + char *param, *val, *tmp, *args_it, *arg_dup_ptr; + char module[MODULE_NAME_LEN]; + + /* next_arg touches the passed buffer and chops each argument */ + arg_dup_ptr = args_it = kstrdup(saved_command_line, GFP_KERNEL); + + /* Chew leading spaces */ + args_it = skip_spaces(args_it); + + while (*args_it) { + args_it = next_arg(args_it, ¶m, &val); + if (verbose) + printk(KERN_INFO "%s: Param: %s, val: %s\n", + __func__, param, val); + tmp = strstr(param, ".ddebug"); + if (tmp && strlen(tmp) == 7) { + strlcpy(module, param, tmp - param + 1); + pr_info("Enabling debugging for module %s\n", module); + snprintf(ddebug_setup_string, DDEBUG_STRING_SIZE, + "module %s +p", module); + ddebug_exec_query(ddebug_setup_string); + } + } + kfree(arg_dup_ptr); +} + static void ddebug_table_free(struct ddebug_table *dt) { list_del_init(&dt->link); @@ -805,6 +885,9 @@ static int __init dynamic_debug_init(void) ddebug_setup_string); } + /* Must be called after above -> ddebug_setup_string gets reused */ + ddebug_boot_parse_args(); + out_free: if (ret) ddebug_remove_all_tables(); -- 1.6.4.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 2010-09-24 12:28 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 Thomas Renninger @ 2010-10-06 21:16 ` Greg KH 2010-10-06 21:40 ` Thomas Renninger 0 siblings, 1 reply; 23+ messages in thread From: Greg KH @ 2010-10-06 21:16 UTC (permalink / raw) To: Thomas Renninger; +Cc: gregkh, linux-kernel, bjorn.helgaas, jbaron On Fri, Sep 24, 2010 at 02:28:28PM +0200, Thomas Renninger wrote: > Dynamic Debug allows enabling of pr_debug and dev_dbg messages at runtime. > This is controlled via /sys/kernel/debug/dynamic_debug/control. > One major drawback is that the whole initialization of a module cannot be > tracked, because ddebug is only aware of debug strings of loaded modules. > But this is the most interesting part... > > This patch introduces a fake module parameter module.ddebug(not shown in > /sys/module/*/parameters, thus it does not use any resources/memory). > > If a module passes ddebug as a module parameter (e.g. via module.ddebug > kernel boot param or via "modprobe module ddebug"), all debug strings of this > module get activated by issuing "module module_name +p" internally > (not via sysfs) when the module gets loaded. > > Possible enhancements for the future if ddebug might get extended with > further flags: > module.ddebug=flags > Then module.ddebug="p" would be the same as module.ddebug, but if there > is a "x" ddebug flag added, one could pass: > module.ddebug="xp" > which would result in such a dynamic debug query: > module module_name +xp > > Modules must not use "ddebug" as module parameter or it will get ignored. > If it's tried, a warning will show up at module load time that it will get > ignored (only works for not built-in modules). > > Tested with (additional added pr_debug messages): > options hp-wmi ddebug > in modprobe.conf > -> works and pr_debug messages issued at module initialization time show > up. Also "p" flag gets set for the whole hp-wmi module: > grep hp-wmi /sys/../dynamic_debug/control > also tested with compiled-in modules, e.g. pnp.ddebug and an additional > patch later in the patch series which instruments pnp code to work with ddebug. I don't think you actually built this patch, as it dies: kernel/params.c: In function ‘parse_one’: kernel/params.c:114:2: error: ‘tmp’ undeclared (first use in this function) kernel/params.c:114:2: note: each undeclared identifier is reported only once for each function it appears in kernel/params.c: In function ‘destroy_params’: kernel/params.c:726:8: warning: unused variable ‘tmp’ I've dropped all 4 from my queue now, care to resend when they work properly? thanks, greg k-h ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 2010-10-06 21:16 ` Greg KH @ 2010-10-06 21:40 ` Thomas Renninger 2010-10-06 21:51 ` Greg KH 0 siblings, 1 reply; 23+ messages in thread From: Thomas Renninger @ 2010-10-06 21:40 UTC (permalink / raw) To: Greg KH; +Cc: gregkh, linux-kernel, bjorn.helgaas, jbaron On Wednesday 06 October 2010 11:16:04 pm Greg KH wrote: > On Fri, Sep 24, 2010 at 02:28:28PM +0200, Thomas Renninger wrote: > > Dynamic Debug allows enabling of pr_debug and dev_dbg messages at > > runtime. This is controlled via /sys/kernel/debug/dynamic_debug/control. > > One major drawback is that the whole initialization of a module cannot be > > tracked, because ddebug is only aware of debug strings of loaded modules. > > But this is the most interesting part... > > > > This patch introduces a fake module parameter module.ddebug(not shown in > > /sys/module/*/parameters, thus it does not use any resources/memory). > > > > If a module passes ddebug as a module parameter (e.g. via module.ddebug > > kernel boot param or via "modprobe module ddebug"), all debug strings of > > this module get activated by issuing "module module_name +p" internally > > (not via sysfs) when the module gets loaded. > > > > Possible enhancements for the future if ddebug might get extended with > > further flags: > > module.ddebug=flags > > Then module.ddebug="p" would be the same as module.ddebug, but if there > > is a "x" ddebug flag added, one could pass: > > module.ddebug="xp" > > which would result in such a dynamic debug query: > > module module_name +xp > > > > Modules must not use "ddebug" as module parameter or it will get ignored. > > If it's tried, a warning will show up at module load time that it will > > get ignored (only works for not built-in modules). > > > > Tested with (additional added pr_debug messages): > > options hp-wmi ddebug > > in modprobe.conf > > -> works and pr_debug messages issued at module initialization time show > > up. Also "p" flag gets set for the whole hp-wmi module: > > grep hp-wmi /sys/../dynamic_debug/control > > also tested with compiled-in modules, e.g. pnp.ddebug and an additional > > patch later in the patch series which instruments pnp code to work with > > ddebug. > > I don't think you actually built this patch, as it dies: > kernel/params.c: In function ‘parse_one’: > kernel/params.c:114:2: error: ‘tmp’ undeclared (first use in this function) > kernel/params.c:114:2: note: each undeclared identifier is reported only > once for each function it appears in kernel/params.c: In function > ‘destroy_params’: > kernel/params.c:726:8: warning: unused variable ‘tmp’ Strange, I added them to the latest SUSE factory kernel already and I didn't do much more than copying (and slightly adjusting?). Can you give me a pointer to your git tree and branch you want the patches based on, iirc I based them on latest Linus master branch. Sorry and thanks, Thomas ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 2010-10-06 21:40 ` Thomas Renninger @ 2010-10-06 21:51 ` Greg KH 0 siblings, 0 replies; 23+ messages in thread From: Greg KH @ 2010-10-06 21:51 UTC (permalink / raw) To: Thomas Renninger; +Cc: gregkh, linux-kernel, bjorn.helgaas, jbaron On Wed, Oct 06, 2010 at 11:40:52PM +0200, Thomas Renninger wrote: > On Wednesday 06 October 2010 11:16:04 pm Greg KH wrote: > > On Fri, Sep 24, 2010 at 02:28:28PM +0200, Thomas Renninger wrote: > > > Dynamic Debug allows enabling of pr_debug and dev_dbg messages at > > > runtime. This is controlled via /sys/kernel/debug/dynamic_debug/control. > > > One major drawback is that the whole initialization of a module cannot be > > > tracked, because ddebug is only aware of debug strings of loaded modules. > > > But this is the most interesting part... > > > > > > This patch introduces a fake module parameter module.ddebug(not shown in > > > /sys/module/*/parameters, thus it does not use any resources/memory). > > > > > > If a module passes ddebug as a module parameter (e.g. via module.ddebug > > > kernel boot param or via "modprobe module ddebug"), all debug strings of > > > this module get activated by issuing "module module_name +p" internally > > > (not via sysfs) when the module gets loaded. > > > > > > Possible enhancements for the future if ddebug might get extended with > > > further flags: > > > module.ddebug=flags > > > Then module.ddebug="p" would be the same as module.ddebug, but if there > > > is a "x" ddebug flag added, one could pass: > > > module.ddebug="xp" > > > which would result in such a dynamic debug query: > > > module module_name +xp > > > > > > Modules must not use "ddebug" as module parameter or it will get ignored. > > > If it's tried, a warning will show up at module load time that it will > > > get ignored (only works for not built-in modules). > > > > > > Tested with (additional added pr_debug messages): > > > options hp-wmi ddebug > > > in modprobe.conf > > > -> works and pr_debug messages issued at module initialization time show > > > up. Also "p" flag gets set for the whole hp-wmi module: > > > grep hp-wmi /sys/../dynamic_debug/control > > > also tested with compiled-in modules, e.g. pnp.ddebug and an additional > > > patch later in the patch series which instruments pnp code to work with > > > ddebug. > > > > I don't think you actually built this patch, as it dies: > > kernel/params.c: In function ‘parse_one’: > > kernel/params.c:114:2: error: ‘tmp’ undeclared (first use in this function) > > kernel/params.c:114:2: note: each undeclared identifier is reported only > > once for each function it appears in kernel/params.c: In function > > ‘destroy_params’: > > kernel/params.c:726:8: warning: unused variable ‘tmp’ > Strange, I added them to the latest SUSE factory kernel already and I didn't > do much more than copying (and slightly adjusting?). > > Can you give me a pointer to your git tree and branch you want the > patches based on, iirc I based them on latest Linus master branch. Try them on top of linux-next, which has my patches in it. Or use my quilt tree, which is on kernel.org (and in the MAINTAINERS file.) thanks, greg k-h ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace 2010-09-20 18:44 ` Jason Baron ` (2 preceding siblings ...) 2010-09-24 12:28 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 Thomas Renninger @ 2010-09-24 12:28 ` Thomas Renninger 2010-09-24 12:28 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger 2010-09-24 12:28 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger 5 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:28 UTC (permalink / raw) To: gregkh; +Cc: linux-kernel, bjorn.helgaas, jbaron, Thomas Renninger before, dynamic debug info (/sys/kernel/debug/dynamic_debug/control) showed the file name as module name of each dynamic debug message (in square brackets): drivers/pnp/core.c:198 [core]pnp_add_device p "%s device, IDs%s (%s)\012" drivers/pnp/resource.c:619 [resource]pnp_add_bus_resource p " add %pr\012" .. drivers/pnp/pnpacpi/core.c:89 [core]pnpacpi_set_resources p "set resources\012" .. With this patch the module name will be pnp for all "drivers/pnp/* -r" code: drivers/pnp/core.c:198 [pnp]pnp_add_device p "%s device, IDs%s (%s)\012" drivers/pnp/resource.c:619 [pnp]pnp_add_bus_resource p " add %pr\012" .. drivers/pnp/pnpacpi/core.c:112 [pnp]pnpacpi_disable_resources p "disable resources\012" This has advantages: - Any pnp code can make use of the moduleparam.h interface, the modules will show up as pnp.param. - Passing pnp.ddebug as kernel boot param will enable all pnp debug messages with my previous patch and CONFIG_DYNAMIC_DEBUG enabled. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- drivers/pnp/Makefile | 6 ++++-- drivers/pnp/isapnp/Makefile | 6 +++--- drivers/pnp/pnpacpi/Makefile | 3 ++- drivers/pnp/pnpbios/Makefile | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/pnp/Makefile b/drivers/pnp/Makefile index 8de3775..bfba893 100644 --- a/drivers/pnp/Makefile +++ b/drivers/pnp/Makefile @@ -2,11 +2,13 @@ # Makefile for the Linux Plug-and-Play Support. # -obj-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o +obj-y := pnp.o + +pnp-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o obj-$(CONFIG_PNPACPI) += pnpacpi/ obj-$(CONFIG_PNPBIOS) += pnpbios/ obj-$(CONFIG_ISAPNP) += isapnp/ # pnp_system_init goes after pnpacpi/pnpbios init -obj-y += system.o +pnp-y += system.o diff --git a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile index cac18bb..6e607aa 100644 --- a/drivers/pnp/isapnp/Makefile +++ b/drivers/pnp/isapnp/Makefile @@ -1,7 +1,7 @@ # # Makefile for the kernel ISAPNP driver. # +obj-y += pnp.o +pnp-y := core.o compat.o -isapnp-proc-$(CONFIG_PROC_FS) = proc.o - -obj-y := core.o compat.o $(isapnp-proc-y) +pnp-$(CONFIG_PROC_FS) += proc.o diff --git a/drivers/pnp/pnpacpi/Makefile b/drivers/pnp/pnpacpi/Makefile index 905326f..40c93da 100644 --- a/drivers/pnp/pnpacpi/Makefile +++ b/drivers/pnp/pnpacpi/Makefile @@ -1,5 +1,6 @@ # # Makefile for the kernel PNPACPI driver. # +obj-y += pnp.o -obj-y := core.o rsparser.o +pnp-y := core.o rsparser.o diff --git a/drivers/pnp/pnpbios/Makefile b/drivers/pnp/pnpbios/Makefile index 3cd3ed7..240b0ff 100644 --- a/drivers/pnp/pnpbios/Makefile +++ b/drivers/pnp/pnpbios/Makefile @@ -1,7 +1,8 @@ # # Makefile for the kernel PNPBIOS driver. # +obj-y := pnp.o -pnpbios-proc-$(CONFIG_PNPBIOS_PROC_FS) = proc.o +pnp-y := core.o bioscalls.o rsparser.o -obj-y := core.o bioscalls.o rsparser.o $(pnpbios-proc-y) +pnp-$(CONFIG_PNPBIOS_PROC_FS) += proc.o -- 1.6.4.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in 2010-09-20 18:44 ` Jason Baron ` (3 preceding siblings ...) 2010-09-24 12:28 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger @ 2010-09-24 12:28 ` Thomas Renninger 2010-09-24 12:28 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger 5 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:28 UTC (permalink / raw) To: gregkh; +Cc: linux-kernel, bjorn.helgaas, jbaron, Thomas Renninger This allows usage of generic pnp.ddebug debug parameter instead of pnp.debug PNP specific parameter. I wonder whether CONFIG_PNP_DEBUG_MESSAGES can vanish totally with this or at some time. Only advantage having it is: If you are restricted and your kernel must not exceed X bytes, you cannot compile in PNP debug messages only, but you have to compile in all debug messages. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- drivers/pnp/base.h | 8 ++++++-- drivers/pnp/core.c | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 0bab84e..1f7f9bd 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -170,12 +170,16 @@ struct pnp_resource *pnp_add_bus_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t end); -extern int pnp_debug; - +#if defined(CONFIG_DYNAMIC_DEBUG) +#define pnp_dbg(dev, format, arg...) \ + ({ dev_dbg(dev, format, ## arg); 0; }) +#else #if defined(CONFIG_PNP_DEBUG_MESSAGES) +extern int pnp_debug; #define pnp_dbg(dev, format, arg...) \ ({ if (pnp_debug) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; }) #else #define pnp_dbg(dev, format, arg...) \ ({ if (0) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; }) #endif +#endif diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 88b3cde..fe834ac 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -215,9 +215,21 @@ static int __init pnp_init(void) subsys_initcall(pnp_init); -int pnp_debug; +#if defined(CONFIG_DYNAMIC_DEBUG) +static int __init pnp_debug_setup(char *__unused) +{ + printk(KERN_INFO "DYNAMIC_DEBUG enabled use pnp.ddebug instead of " + "pnp.debug boot param\n"); + return 1; +} +__setup("pnp.debug", pnp_debug_setup); + +#else #if defined(CONFIG_PNP_DEBUG_MESSAGES) + +int pnp_debug; + static int __init pnp_debug_setup(char *__unused) { pnp_debug = 1; @@ -225,3 +237,5 @@ static int __init pnp_debug_setup(char *__unused) } __setup("pnp.debug", pnp_debug_setup); #endif + +#endif -- 1.6.4.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug is compiled in 2010-09-20 18:44 ` Jason Baron ` (4 preceding siblings ...) 2010-09-24 12:28 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger @ 2010-09-24 12:28 ` Thomas Renninger 5 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-24 12:28 UTC (permalink / raw) To: gregkh; +Cc: linux-kernel, bjorn.helgaas, jbaron, Thomas Renninger Fixes these warnings: kernel/module.c: In function ‘layout_sections’: kernel/module.c:1776: error: ‘name’ undeclared (first use in this function) kernel/module.c:1776: error: (Each undeclared identifier is reported only once kernel/module.c:1776: error: for each function it appears in.) kernel/module.c: In function ‘move_module’: kernel/module.c:2394: warning: format ‘%lx’ expects type ‘long unsigned int’, but argument 2 has type ‘Elf64_Addr’ if DEBUGP is defined in kernel/module.c Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Greg KH <gregkh@suse.de> CC: jbaron@redhat.com CC: lkml <linux-kernel@vger.kernel.org> --- kernel/module.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 3912e12..66e4361 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1773,7 +1773,6 @@ static void layout_sections(struct module *mod, struct load_info *info) || strstarts(sname, ".init")) continue; s->sh_entsize = get_offset(mod, &mod->core_size, s, i); - DEBUGP("\t%s\n", name); } if (m == 0) mod->core_text_size = mod->core_size; @@ -2390,8 +2389,8 @@ static int move_module(struct module *mod, struct load_info *info) memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size); /* Update sh_addr to point to copy in image. */ shdr->sh_addr = (unsigned long)dest; - DEBUGP("\t0x%lx %s\n", - shdr->sh_addr, info->secstrings + shdr->sh_name); + DEBUGP("\t0x%p %s\n", + (void *)shdr->sh_addr, info->secstrings + shdr->sh_name); } return 0; -- 1.6.4.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace 2010-09-15 22:11 Dynamic Debug module.ddebug fake param enhancements Thomas Renninger 2010-09-15 22:11 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 Thomas Renninger @ 2010-09-15 22:11 ` Thomas Renninger 2010-09-15 22:11 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger 2010-09-15 22:11 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger 3 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-15 22:11 UTC (permalink / raw) To: trenn; +Cc: bjorn.helgaas, gregkh, jbaron, linux-kernel before, dynamic debug info (/sys/kernel/debug/dynamic_debug/control) showed the file name as module name of each dynamic debug message (in square brackets): drivers/pnp/core.c:198 [core]pnp_add_device p "%s device, IDs%s (%s)\012" drivers/pnp/resource.c:619 [resource]pnp_add_bus_resource p " add %pr\012" .. drivers/pnp/pnpacpi/core.c:89 [core]pnpacpi_set_resources p "set resources\012" .. With this patch the module name will be pnp for all "drivers/pnp/* -r" code: drivers/pnp/core.c:198 [pnp]pnp_add_device p "%s device, IDs%s (%s)\012" drivers/pnp/resource.c:619 [pnp]pnp_add_bus_resource p " add %pr\012" .. drivers/pnp/pnpacpi/core.c:112 [pnp]pnpacpi_disable_resources p "disable resources\012" This has advantages: - Any pnp code can make use of the moduleparam.h interface, the modules will show up as pnp.param. - Passing pnp.ddebug as kernel boot param will enable all pnp debug messages with my previous patch and CONFIG_DYNAMIC_DEBUG enabled. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- drivers/pnp/Makefile | 6 ++++-- drivers/pnp/isapnp/Makefile | 6 +++--- drivers/pnp/pnpacpi/Makefile | 3 ++- drivers/pnp/pnpbios/Makefile | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/pnp/Makefile b/drivers/pnp/Makefile index 8de3775..bfba893 100644 --- a/drivers/pnp/Makefile +++ b/drivers/pnp/Makefile @@ -2,11 +2,13 @@ # Makefile for the Linux Plug-and-Play Support. # -obj-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o +obj-y := pnp.o + +pnp-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o obj-$(CONFIG_PNPACPI) += pnpacpi/ obj-$(CONFIG_PNPBIOS) += pnpbios/ obj-$(CONFIG_ISAPNP) += isapnp/ # pnp_system_init goes after pnpacpi/pnpbios init -obj-y += system.o +pnp-y += system.o diff --git a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile index cac18bb..6e607aa 100644 --- a/drivers/pnp/isapnp/Makefile +++ b/drivers/pnp/isapnp/Makefile @@ -1,7 +1,7 @@ # # Makefile for the kernel ISAPNP driver. # +obj-y += pnp.o +pnp-y := core.o compat.o -isapnp-proc-$(CONFIG_PROC_FS) = proc.o - -obj-y := core.o compat.o $(isapnp-proc-y) +pnp-$(CONFIG_PROC_FS) += proc.o diff --git a/drivers/pnp/pnpacpi/Makefile b/drivers/pnp/pnpacpi/Makefile index 905326f..40c93da 100644 --- a/drivers/pnp/pnpacpi/Makefile +++ b/drivers/pnp/pnpacpi/Makefile @@ -1,5 +1,6 @@ # # Makefile for the kernel PNPACPI driver. # +obj-y += pnp.o -obj-y := core.o rsparser.o +pnp-y := core.o rsparser.o diff --git a/drivers/pnp/pnpbios/Makefile b/drivers/pnp/pnpbios/Makefile index 3cd3ed7..240b0ff 100644 --- a/drivers/pnp/pnpbios/Makefile +++ b/drivers/pnp/pnpbios/Makefile @@ -1,7 +1,8 @@ # # Makefile for the kernel PNPBIOS driver. # +obj-y := pnp.o -pnpbios-proc-$(CONFIG_PNPBIOS_PROC_FS) = proc.o +pnp-y := core.o bioscalls.o rsparser.o -obj-y := core.o bioscalls.o rsparser.o $(pnpbios-proc-y) +pnp-$(CONFIG_PNPBIOS_PROC_FS) += proc.o -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in 2010-09-15 22:11 Dynamic Debug module.ddebug fake param enhancements Thomas Renninger 2010-09-15 22:11 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 Thomas Renninger 2010-09-15 22:11 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger @ 2010-09-15 22:11 ` Thomas Renninger 2010-09-15 22:11 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger 3 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-15 22:11 UTC (permalink / raw) To: trenn; +Cc: bjorn.helgaas, gregkh, jbaron, linux-kernel This allows usage of generic pnp.ddebug debug parameter instead of pnp.debug PNP specific parameter. I wonder whether CONFIG_PNP_DEBUG_MESSAGES can vanish totally with this or at some time. Only advantage having it is: If you are restricted and your kernel must not exceed X bytes, you cannot compile in PNP debug messages only, but you have to compile in all debug messages. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Jason Baron <jbaron@redhat.com> CC: Greg KH <gregkh@suse.de> CC: lkml <linux-kernel@vger.kernel.org> --- drivers/pnp/base.h | 8 ++++++-- drivers/pnp/core.c | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 0bab84e..1f7f9bd 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -170,12 +170,16 @@ struct pnp_resource *pnp_add_bus_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t end); -extern int pnp_debug; - +#if defined(CONFIG_DYNAMIC_DEBUG) +#define pnp_dbg(dev, format, arg...) \ + ({ dev_dbg(dev, format, ## arg); 0; }) +#else #if defined(CONFIG_PNP_DEBUG_MESSAGES) +extern int pnp_debug; #define pnp_dbg(dev, format, arg...) \ ({ if (pnp_debug) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; }) #else #define pnp_dbg(dev, format, arg...) \ ({ if (0) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; }) #endif +#endif diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 88b3cde..fe834ac 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -215,9 +215,21 @@ static int __init pnp_init(void) subsys_initcall(pnp_init); -int pnp_debug; +#if defined(CONFIG_DYNAMIC_DEBUG) +static int __init pnp_debug_setup(char *__unused) +{ + printk(KERN_INFO "DYNAMIC_DEBUG enabled use pnp.ddebug instead of " + "pnp.debug boot param\n"); + return 1; +} +__setup("pnp.debug", pnp_debug_setup); + +#else #if defined(CONFIG_PNP_DEBUG_MESSAGES) + +int pnp_debug; + static int __init pnp_debug_setup(char *__unused) { pnp_debug = 1; @@ -225,3 +237,5 @@ static int __init pnp_debug_setup(char *__unused) } __setup("pnp.debug", pnp_debug_setup); #endif + +#endif -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug is compiled in 2010-09-15 22:11 Dynamic Debug module.ddebug fake param enhancements Thomas Renninger ` (2 preceding siblings ...) 2010-09-15 22:11 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger @ 2010-09-15 22:11 ` Thomas Renninger 3 siblings, 0 replies; 23+ messages in thread From: Thomas Renninger @ 2010-09-15 22:11 UTC (permalink / raw) To: trenn; +Cc: bjorn.helgaas, gregkh, jbaron, linux-kernel Fixes these warnings: kernel/module.c: In function ‘layout_sections’: kernel/module.c:1776: error: ‘name’ undeclared (first use in this function) kernel/module.c:1776: error: (Each undeclared identifier is reported only once kernel/module.c:1776: error: for each function it appears in.) kernel/module.c: In function ‘move_module’: kernel/module.c:2394: warning: format ‘%lx’ expects type ‘long unsigned int’, but argument 2 has type ‘Elf64_Addr’ if DEBUGP is defined in kernel/module.c Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Greg KH <gregkh@suse.de> CC: jbaron@redhat.com CC: lkml <linux-kernel@vger.kernel.org> --- kernel/module.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 3912e12..66e4361 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1773,7 +1773,6 @@ static void layout_sections(struct module *mod, struct load_info *info) || strstarts(sname, ".init")) continue; s->sh_entsize = get_offset(mod, &mod->core_size, s, i); - DEBUGP("\t%s\n", name); } if (m == 0) mod->core_text_size = mod->core_size; @@ -2390,8 +2389,8 @@ static int move_module(struct module *mod, struct load_info *info) memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size); /* Update sh_addr to point to copy in image. */ shdr->sh_addr = (unsigned long)dest; - DEBUGP("\t0x%lx %s\n", - shdr->sh_addr, info->secstrings + shdr->sh_name); + DEBUGP("\t0x%p %s\n", + (void *)shdr->sh_addr, info->secstrings + shdr->sh_name); } return 0; -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 23+ messages in thread
end of thread, other threads:[~2010-10-06 21:51 UTC | newest] Thread overview: 23+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-09-15 22:11 Dynamic Debug module.ddebug fake param enhancements Thomas Renninger 2010-09-15 22:11 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V3 Thomas Renninger 2010-09-17 19:54 ` Jason Baron 2010-09-17 21:52 ` Thomas Renninger 2010-09-20 18:44 ` Jason Baron 2010-09-24 12:18 ` Thomas Renninger 2010-09-24 12:28 ` Dynamic Debug module.ddebug fake param enhancements V4 Thomas Renninger 2010-09-24 14:56 ` Bjorn Helgaas 2010-09-27 8:25 ` Thomas Renninger 2010-09-27 15:09 ` Bjorn Helgaas 2010-09-28 12:25 ` Thomas Renninger 2010-09-28 14:22 ` Bjorn Helgaas 2010-10-06 20:59 ` Greg KH 2010-09-24 12:28 ` [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4 Thomas Renninger 2010-10-06 21:16 ` Greg KH 2010-10-06 21:40 ` Thomas Renninger 2010-10-06 21:51 ` Greg KH 2010-09-24 12:28 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger 2010-09-24 12:28 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger 2010-09-24 12:28 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger 2010-09-15 22:11 ` [PATCH 2/4] PNP: Compile all pnp built-in stuff in one module namespace Thomas Renninger 2010-09-15 22:11 ` [PATCH 3/4] PNP: Use dev_dbg instead of dev_printk(KERN_DEBUG.. if DYNAMIC_DEBUG is compiled in Thomas Renninger 2010-09-15 22:11 ` [PATCH 4/4] kernel/module.c: Fix compiler warnings if debug " Thomas Renninger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox