All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 00/25] dynamic-debug enhancements
@ 2011-11-30 20:27 Jim Cromie
  2011-12-06 18:59 ` Jim Cromie
  2011-12-12 23:12 ` [patch 00/23] dynamic-debug enhancements Jim Cromie
  0 siblings, 2 replies; 44+ messages in thread
From: Jim Cromie @ 2011-11-30 20:27 UTC (permalink / raw)
  To: LKML

this patchset adds
- dynamic-debug during module initialization
- multiple queries in ddebug_query, module.dyndbg

Unlike previous versions, it drops the pending-query approach in
favor of  "fake module parameters"proposed by Thomas Renninger
    https://lkml.org/lkml/2010/9/15/397

Its based upon 3.2-rc3, since that has several patches to
include/linux/dynamic_debug.h
that are not in driver-core-next, and theyd need to be handled eventually.

1 - trivial bug in kernel/module.c under DEBUGP
2 - whitespace
3-12 dyndbg cleanups
13-17 multiple queries
18-25 dynamic-debug during module initialization




[jimc@groucho linux-2.6]$ git diff --stat v3.2-rc3..HEAD
 Documentation/dynamic-debug-howto.txt |   76 ++++++--
 drivers/pnp/base.h                    |    8 +-
 drivers/pnp/core.c                    |   13 ++
 include/linux/device.h                |    8 +-
 include/linux/dynamic_debug.h         |   31 +++-
 include/linux/kernel.h                |   10 +
 include/linux/moduleparam.h           |    4 +
 include/linux/netdevice.h             |    8 +-
 include/linux/printk.h                |    8 +-
 kernel/module.c                       |   47 ++---
 kernel/params.c                       |   27 ++-
 lib/dynamic_debug.c                   |  349 +++++++++++++++++++++++++--------
 12 files changed, 430 insertions(+), 159 deletions(-)

^ permalink raw reply	[flat|nested] 44+ messages in thread
* [PATCH 01/25] kernel/module.c: fix compile err, warnings under ifdef DEBUGP, switch to pr_debug
@ 2011-12-12 23:12 jim.cromie
  2011-12-12 23:12 ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie
  0 siblings, 1 reply; 44+ messages in thread
From: jim.cromie @ 2011-12-12 23:12 UTC (permalink / raw)
  To: jbaron; +Cc: greg, linux-kernel, Jim Cromie

From: Jim Cromie <jim.cromie@gmail.com>

Note: this combines 2 patches, which Rusty has added to his tree, so
Ive moved latter up to front of patchset, and folded them together.
It should be a noop once it merges with Rusty's tree.

1. resubmit of https://lkml.org/lkml/2010/9/15/399 4/4 patch
with tiny mod.

Fixes these warnings, err if DEBUGP is defined in kernel/module.c:

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’

2. replace DEBUGP with pr_debug

Use more flexible pr_debug.  This allows:

  echo "module module +p" > /dbg/dynamic_debug/control

to turn on debug messages when needed.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 kernel/module.c |   46 ++++++++++++++++++++--------------------------
 kernel/params.c |   14 ++++----------
 2 files changed, 24 insertions(+), 36 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 178333c..39a7888 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -62,12 +62,6 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/module.h>
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(fmt , a...)
-#endif
-
 #ifndef ARCH_SHF_SMALL
 #define ARCH_SHF_SMALL 0
 #endif
@@ -410,7 +404,7 @@ const struct kernel_symbol *find_symbol(const char *name,
 		return fsa.sym;
 	}
 
-	DEBUGP("Failed to find symbol %s\n", name);
+	pr_debug("Failed to find symbol %s\n", name);
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(find_symbol);
@@ -600,11 +594,11 @@ static int already_uses(struct module *a, struct module *b)
 
 	list_for_each_entry(use, &b->source_list, source_list) {
 		if (use->source == a) {
-			DEBUGP("%s uses %s!\n", a->name, b->name);
+			pr_debug("%s uses %s!\n", a->name, b->name);
 			return 1;
 		}
 	}
-	DEBUGP("%s does not use %s!\n", a->name, b->name);
+	pr_debug("%s does not use %s!\n", a->name, b->name);
 	return 0;
 }
 
@@ -619,7 +613,7 @@ static int add_module_usage(struct module *a, struct module *b)
 {
 	struct module_use *use;
 
-	DEBUGP("Allocating new usage for %s.\n", a->name);
+	pr_debug("Allocating new usage for %s.\n", a->name);
 	use = kmalloc(sizeof(*use), GFP_ATOMIC);
 	if (!use) {
 		printk(KERN_WARNING "%s: out of memory loading\n", a->name);
@@ -663,7 +657,7 @@ static void module_unload_free(struct module *mod)
 	mutex_lock(&module_mutex);
 	list_for_each_entry_safe(use, tmp, &mod->target_list, target_list) {
 		struct module *i = use->target;
-		DEBUGP("%s unusing %s\n", mod->name, i->name);
+		pr_debug("%s unusing %s\n", mod->name, i->name);
 		module_put(i);
 		list_del(&use->source_list);
 		list_del(&use->target_list);
@@ -761,7 +755,7 @@ static void wait_for_zero_refcount(struct module *mod)
 	/* Since we might sleep for some time, release the mutex first */
 	mutex_unlock(&module_mutex);
 	for (;;) {
-		DEBUGP("Looking at refcount...\n");
+		pr_debug("Looking at refcount...\n");
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (module_refcount(mod) == 0)
 			break;
@@ -804,7 +798,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 	if (mod->state != MODULE_STATE_LIVE) {
 		/* FIXME: if (force), slam module count and wake up
                    waiter --RR */
-		DEBUGP("%s already dying\n", mod->name);
+		pr_debug("%s already dying\n", mod->name);
 		ret = -EBUSY;
 		goto out;
 	}
@@ -1057,7 +1051,7 @@ static int check_version(Elf_Shdr *sechdrs,
 
 		if (versions[i].crc == maybe_relocated(*crc, crc_owner))
 			return 1;
-		DEBUGP("Found checksum %lX vs module %lX\n",
+		pr_debug("Found checksum %lX vs module %lX\n",
 		       maybe_relocated(*crc, crc_owner), versions[i].crc);
 		goto bad_version;
 	}
@@ -1834,7 +1828,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 		case SHN_COMMON:
 			/* We compiled with -fno-common.  These are not
 			   supposed to happen.  */
-			DEBUGP("Common symbol: %s\n", name);
+			pr_debug("Common symbol: %s\n", name);
 			printk("%s: please compile with -fno-common\n",
 			       mod->name);
 			ret = -ENOEXEC;
@@ -1842,7 +1836,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 
 		case SHN_ABS:
 			/* Don't need to do anything */
-			DEBUGP("Absolute symbol: 0x%08lx\n",
+			pr_debug("Absolute symbol: 0x%08lx\n",
 			       (long)sym[i].st_value);
 			break;
 
@@ -1966,7 +1960,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
 	for (i = 0; i < info->hdr->e_shnum; i++)
 		info->sechdrs[i].sh_entsize = ~0UL;
 
-	DEBUGP("Core section allocation order:\n");
+	pr_debug("Core section allocation order:\n");
 	for (m = 0; m < ARRAY_SIZE(masks); ++m) {
 		for (i = 0; i < info->hdr->e_shnum; ++i) {
 			Elf_Shdr *s = &info->sechdrs[i];
@@ -1978,7 +1972,7 @@ 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);
+			pr_debug("\t%s\n", sname);
 		}
 		switch (m) {
 		case 0: /* executable */
@@ -1995,7 +1989,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
 		}
 	}
 
-	DEBUGP("Init section allocation order:\n");
+	pr_debug("Init section allocation order:\n");
 	for (m = 0; m < ARRAY_SIZE(masks); ++m) {
 		for (i = 0; i < info->hdr->e_shnum; ++i) {
 			Elf_Shdr *s = &info->sechdrs[i];
@@ -2008,7 +2002,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
 				continue;
 			s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
 					 | INIT_OFFSET_MASK);
-			DEBUGP("\t%s\n", sname);
+			pr_debug("\t%s\n", sname);
 		}
 		switch (m) {
 		case 0: /* executable */
@@ -2189,7 +2183,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
 	symsect->sh_flags |= SHF_ALLOC;
 	symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
 					 info->index.sym) | INIT_OFFSET_MASK;
-	DEBUGP("\t%s\n", info->secstrings + symsect->sh_name);
+	pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
 
 	src = (void *)info->hdr + symsect->sh_offset;
 	nsrc = symsect->sh_size / sizeof(*src);
@@ -2211,7 +2205,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
 	strsect->sh_flags |= SHF_ALLOC;
 	strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
 					 info->index.str) | INIT_OFFSET_MASK;
-	DEBUGP("\t%s\n", info->secstrings + strsect->sh_name);
+	pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
 
 	/* Append room for core symbols' strings at end of core part. */
 	info->stroffs = mod->core_size;
@@ -2621,7 +2615,7 @@ static int move_module(struct module *mod, struct load_info *info)
 	mod->module_init = ptr;
 
 	/* Transfer each section which specifies SHF_ALLOC */
-	DEBUGP("final section addresses:\n");
+	pr_debug("final section addresses:\n");
 	for (i = 0; i < info->hdr->e_shnum; i++) {
 		void *dest;
 		Elf_Shdr *shdr = &info->sechdrs[i];
@@ -2639,8 +2633,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);
+		pr_debug("\t0x%p %s\n",
+		       (void *)shdr->sh_addr, info->secstrings + shdr->sh_name);
 	}
 
 	return 0;
@@ -2811,7 +2805,7 @@ static struct module *load_module(void __user *umod,
 	struct module *mod;
 	long err;
 
-	DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n",
+	pr_debug("load_module: umod=%p, len=%lu, uargs=%p\n",
 	       umod, len, uargs);
 
 	/* Copy in the blobs from userspace, check they are vaguely sane. */
diff --git a/kernel/params.c b/kernel/params.c
index 65aae11..9240664 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -25,12 +25,6 @@
 #include <linux/slab.h>
 #include <linux/ctype.h>
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(fmt, a...)
-#endif
-
 /* Protects all parameters, and incidentally kmalloced_param list. */
 static DEFINE_MUTEX(param_lock);
 
@@ -105,7 +99,7 @@ static int parse_one(char *param,
 			/* No one handled NULL, so do it here. */
 			if (!val && params[i].ops->set != param_set_bool)
 				return -EINVAL;
-			DEBUGP("They are equal!  Calling %p\n",
+			pr_debug("They are equal!  Calling %p\n",
 			       params[i].ops->set);
 			mutex_lock(&param_lock);
 			err = params[i].ops->set(val, &params[i]);
@@ -115,11 +109,11 @@ static int parse_one(char *param,
 	}
 
 	if (handle_unknown) {
-		DEBUGP("Unknown argument: calling %p\n", handle_unknown);
+		pr_debug("Unknown argument: calling %p\n", handle_unknown);
 		return handle_unknown(param, val);
 	}
 
-	DEBUGP("Unknown argument `%s'\n", param);
+	pr_debug("Unknown argument `%s'\n", param);
 	return -ENOENT;
 }
 
@@ -184,7 +178,7 @@ int parse_args(const char *name,
 {
 	char *param, *val;
 
-	DEBUGP("Parsing ARGS: %s\n", args);
+	pr_debug("Parsing ARGS: %s\n", args);
 
 	/* Chew leading spaces */
 	args = skip_spaces(args);
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 44+ messages in thread
* [patch 00/25] dynamic-debug during module initialization
@ 2011-11-30 19:56 jim.cromie
  2011-11-30 19:56 ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie
  0 siblings, 1 reply; 44+ messages in thread
From: jim.cromie @ 2011-11-30 19:56 UTC (permalink / raw)
  To: jbaron; +Cc: greg, joe, bart.vanassche, linux-kernel

This patchset adds
- dynamic-debug during module initialization
- multiple queries

Unlike previous versions, this drops pending-query approach in
favor of "fake module parameter" approach proposed by Thomas Renninger.
    https://lkml.org/lkml/2010/9/15/397

Its based upon v3.2-rc3, cuz it includes a few adjustments to
dynamic_debug.h which are not in driver-core-next atm.


1	bug-fix for kernel/module.c under DEBUGP
2	whitespace cleanup
3-12	dynamic-debug cleanups, should be relatively uncontroversial
13-17	multiple queries in ddebug_query="..."

18-25	fake module parameter
20	maybe fold into 18 (kept separate since 18 is Thomas's work)
23	*.dyndbg=...
25	BUILD_BUG_DECL (likely discussion point ;-)

[jimc@groucho linux-2.6]$ git diff --stat v3.2-rc3..HEAD
 Documentation/dynamic-debug-howto.txt |   76 ++++++--
 drivers/pnp/base.h                    |    8 +-
 drivers/pnp/core.c                    |   13 ++
 include/linux/device.h                |    8 +-
 include/linux/dynamic_debug.h         |   31 +++-
 include/linux/kernel.h                |   10 +
 include/linux/moduleparam.h           |    4 +
 include/linux/netdevice.h             |    8 +-
 include/linux/printk.h                |    8 +-
 kernel/module.c                       |   47 ++---
 kernel/params.c                       |   27 ++-
 lib/dynamic_debug.c                   |  349 +++++++++++++++++++++++++--------
 12 files changed, 430 insertions(+), 159 deletions(-)



^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2011-12-13 14:48 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30 20:27 [patch 00/25] dynamic-debug enhancements Jim Cromie
2011-12-06 18:59 ` Jim Cromie
2011-12-06 19:11   ` [patch 00/24 ] dynamic debug enhancements: multi-queries during mod-init jim.cromie
2011-12-06 19:11     ` [PATCH 01/25] kernel/module.c: fix compile err, warnings under ifdef DEBUGP jim.cromie
2011-12-06 19:11     ` [PATCH 02/25] dynamic_debug: fix whitespace complaints from scripts/cleanfile jim.cromie
2011-12-06 19:11     ` [PATCH 03/25] dynamic_debug: drop enabled field from struct _ddebug, use _DPRINTK_FLAGS_PRINT jim.cromie
2011-12-06 19:11     ` [PATCH 04/25] dynamic_debug: make dynamic-debug supersede DEBUG ccflag jim.cromie
2011-12-06 19:11     ` [PATCH 05/25] dynamic_debug: change verbosity at runtime jim.cromie
2011-12-06 19:11     ` [PATCH 06/25] dynamic_debug: replace strcpy with strlcpy, in ddebug_setup_query() jim.cromie
2011-12-06 19:11     ` [PATCH 07/25] dynamic_debug: pr_err() call should not depend upon verbosity jim.cromie
2011-12-06 19:11     ` [PATCH 08/25] dynamic_debug: drop explicit !=NULL checks jim.cromie
2011-12-06 19:11     ` [PATCH 09/25] dynamic_debug: describe_flags with '=[pmflt_]*' jim.cromie
2011-12-06 19:11     ` [PATCH 10/25] dynamic_debug: tighten up error checking on debug queries jim.cromie
2011-12-06 19:11     ` [PATCH 11/25] dynamic_debug: early return if _ddebug table is empty jim.cromie
2011-12-06 19:11     ` [PATCH 12/25] dynamic_debug: reduce lineno field to a saner 18 bits jim.cromie
2011-12-06 19:11     ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie
2011-12-06 19:11     ` [PATCH 14/25] dynamic_debug: enlarge command/query write buffer jim.cromie
2011-12-06 19:11     ` [PATCH 15/25] dynamic_debug: add trim_prefix() to provide source-root relative paths jim.cromie
2011-12-06 19:11     ` [PATCH 16/25] dynamic_debug: factor vpr_info_dq out of ddebug_parse_query jim.cromie
2011-12-06 19:11     ` [PATCH 17/25] dynamic_debug: process multiple debug-queries on a line jim.cromie
2011-12-06 19:11     ` [PATCH 18/25] dynamic_debug: Introduce global fake module param $module.dyndbg jim.cromie
2011-12-07  1:01       ` Rusty Russell
2011-12-07  8:33         ` Jim Cromie
2011-12-07 10:59           ` Rusty Russell
2011-12-08 17:10       ` Jason Baron
2011-12-08 18:12         ` Jim Cromie
2011-12-06 19:11     ` [PATCH 19/25] pnp: if CONFIG_DYNAMIC_DEBUG, use pnp.dyndbg instead of pnp.debug jim.cromie
2011-12-06 19:11     ` [PATCH 20/25] dynamic_debug: add modname arg to exec_query callchain jim.cromie
2011-12-06 19:11     ` [PATCH 21/25] kernel/module: replace DEBUGP with pr_debug jim.cromie
2011-12-07  1:07       ` Rusty Russell
2011-12-08 15:41         ` Jason Baron
2011-12-08 18:17           ` Jim Cromie
2011-12-06 19:11     ` [PATCH 22/25] dynamic_debug: protect "dyndbg" fake module param name at compile-time jim.cromie
2011-12-06 19:11     ` [PATCH 23/25] dynamic_debug: update Documentation/kernel-parameters.txt, Kconfig.debug jim.cromie
2011-12-06 19:11     ` [PATCH 24/25] dynamic_debug: remove unneeded includes jim.cromie
2011-12-12 22:05     ` [patch 00/24 ] dynamic debug enhancements: multi-queries during mod-init Greg KH
     [not found]       ` <CAJfuBxzeKzmOCo00Ew8xAp9EmU0QZ3zjOkRcdEMzYrtx_b9+kA@mail.gmail.com>
2011-12-13  4:17         ` Jim Cromie
2011-12-13  4:25           ` Greg KH
2011-12-13  7:00             ` Jim Cromie
2011-12-13  7:44               ` Greg KH
2011-12-13 14:48       ` Jason Baron
2011-12-12 23:12 ` [patch 00/23] dynamic-debug enhancements Jim Cromie
  -- strict thread matches above, loose matches on Subject: below --
2011-12-12 23:12 [PATCH 01/25] kernel/module.c: fix compile err, warnings under ifdef DEBUGP, switch to pr_debug jim.cromie
2011-12-12 23:12 ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie
2011-11-30 19:56 [patch 00/25] dynamic-debug during module initialization jim.cromie
2011-11-30 19:56 ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.