Prev: [PATCH] NFS: Add a missing unlock into nfs_access_cache_shrinker()
Next: Perf trace event parse errors for KVM events
From: Roman Fietze on 26 May 2010 08:40 Hello Jason, hello list, If I'm not wrong one could only enable any dynamic debugging flag after a module had been completely loaded, using debugfs. This makes it impossible to use dev_dbg or pr_debug e.g. inside the module init function or any function called by it. My patch works by replacing _DPRINTK_FLAGS_DEFAULT after including all kernel headers in my module source file and some small patch inside dynamic_debug.c setting up the internal variables already when loading a module with flags unequal to zero. This patch can of course be optimized somewhat by reusing existing variables. Subject: [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time This allows to use e.g. pr_debug right from the beginning, e.g. in the module init function. - the module must redefine _DPRINTK_FLAGS_DEFAULT, e.g. #undef _DPRINTK_FLAGS_DEFAULT #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT - when a module is loaded and the flags are not zero, the enabled count and hash masks are enabled right away Signed-off-by: Roman Fietze <roman.fietze(a)telemotive.de> --- lib/dynamic_debug.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d6b8b9b..d10466e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -656,6 +656,8 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, { struct ddebug_table *dt; char *new_name; + size_t i; + char flagbuf[8]; dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) @@ -671,6 +673,22 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, dt->ddebugs = tab; mutex_lock(&ddebug_lock); + for (i = 0 ; i < dt->num_ddebugs ; i++) { + struct _ddebug *dp = &dt->ddebugs[i]; + + if (dp->flags) { + dt->num_enabled++; + dynamic_debug_enabled |= (1LL << dp->primary_hash); + dynamic_debug_enabled2 |= (1LL << dp->secondary_hash); + if (verbose) + printk(KERN_INFO + "ddebug: added %s:%d [%s]%s %s\n", + dp->filename, dp->lineno, + dt->mod_name, dp->function, + ddebug_describe_flags(dp, flagbuf, + sizeof(flagbuf))); + } + } list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); -- 1.7.1 -- Roman Fietze Telemotive AG B�ro M�hlhausen Breitwiesen 73347 M�hlhausen Tel.: +49(0)7335/18493-45 http://www.telemotive.de -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |