combine dprintk and dynamic printk
Subsystems (8)
PATCH 1/2 combine dprintk and dynamic printk
hi,
This patch combines Greg Bank's dprintk() work with the existing dynamic printk patchset, we are now calling it 'dynamic debug'.
The new feature of this patchset is a richer /debugfs control file interface, (an example output from my system is at the bottom), which allows fined grained control over the the debug output. The output can be controlled by function, file, module, format string, and line number.
for example, enabled all debug messages in module 'nf_conntrack':
echo -n 'module nf_conntrack +p' > /mnt/debugfs/dynamic_debug/control
to disable them:
echo -n 'module nf_conntrack -p' > /mnt/debugfs/dynamic_debug/control
A further explanation can be found in the documentation patch.
thanks,
-Jason and Greg
---
Documentation/kernel-parameters.txt | 5 include/asm-generic/vmlinux.lds.h | 15 - include/linux/device.h | 2 include/linux/dynamic_debug.h | 88 ++++ include/linux/dynamic_printk.h | 93 ---- include/linux/kernel.h | 4 kernel/module.c | 25 - lib/Kconfig.debug | 2 lib/Makefile | 2 lib/dynamic_debug.c | 756 +++++++++++++++++++++++++++++++++++ lib/dynamic_printk.c | 414 ------------------- net/netfilter/nf_conntrack_pptp.c | 2 scripts/Makefile.lib | 2 13 files changed, 867 insertions(+), 543 deletions(-) create mode 100644 include/linux/dynamic_debug.h delete mode 100644 include/linux/dynamic_printk.h create mode 100644 lib/dynamic_debug.c delete mode 100644 lib/dynamic_printk.c
Documentation/kernel-parameters.txt +0 -5
@@ -1819,11 +1819,6 @@ and is between 256 and 4096 characters. It is defined in the file autoconfiguration. Ranges are in pairs (memory base and size). - dynamic_printk Enables pr_debug()/dev_dbg() calls if - CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. - These can also be switched on/off via - <debugfs>/dynamic_printk/modules - print-fatal-signals= [KNL] debug: print fatal signals print-fatal-signals=1: print segfault info to
include/asm-generic/vmlinux.lds.h +6 -9
@@ -80,6 +80,11 @@ VMLINUX_SYMBOL(__start___tracepoints) = .; \ *(__tracepoints ) \ VMLINUX_SYMBOL(__stop___tracepoints) = .; \ +/* implement dynamic printk debug */ \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__start___verbose) = .; \ + *(__verbose ) \ + VMLINUX_SYMBOL(__stop___verbose) = .; \ LIKELY_PROFILE() \BRANCH_PROFILE ()
@@ -309,15 +314,7 @@ CPU_DISCARD(init.data) \ CPU_DISCARD(init.rodata) \ MEM_DISCARD(init.data) \ -MEM_DISCARD (init.rodata) \ - /* implement dynamic printk debug */ \ - VMLINUX_SYMBOL(__start___verbose_strings) = .; \ - *(__verbose_strings ) \ - VMLINUX_SYMBOL(__stop___verbose_strings) = .; \ - . = ALIGN(8); \ - VMLINUX_SYMBOL(__start___verbose) = .; \ - *(__verbose ) \ - VMLINUX_SYMBOL(__stop___verbose) = .; + MEM_DISCARD(init.rodata)#define INIT_TEXT \ *(.init.text) \
include/linux/device.h +1 -1
@@ -568,7 +568,7 @@ extern const char *dev_driver_string(const struct device *dev);#if defined(DEBUG ) #define dev_dbg(dev, format, arg...) \ dev_printk(KERN_DEBUG , dev , format , ## arg) -#elif defined(CONFIG_DYNAMIC_PRINTK_DEBUG ) +#elif defined(CONFIG_DYNAMIC_DEBUG )#define dev_dbg (dev, format, ...) do { \ dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ } while (0)
include/linux/dynamic_debug.h new file +88 -0
88 lines not on this page · raw message
include/linux/dynamic_printk.h deleted +0 -93
93 lines not on this page · raw message
include/linux/kernel.h +2 -2
@@ -16,7 +16,7 @@#include <linux/log2.h> #include <linux/typecheck.h> #include <linux/ratelimit.h> -#include <linux/dynamic_printk.h> +#include <linux/dynamic_debug.h> #include <asm/byteorder.h> #include <asm/bug.h>
@@ -358,7 +358,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)#if defined(DEBUG )#define pr_debug (fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#elif defined(CONFIG_DYNAMIC_PRINTK_DEBUG ) +#elif defined(CONFIG_DYNAMIC_DEBUG )#define pr_debug (fmt, ...) do { \ dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ } while (0)
kernel/module.c +10 -15
@@ -821,7 +821,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)mutex_lock (&module_mutex);/* Store the name of the last unloaded module for diagnostic purposes */ strlcpy (last_unloaded_module, mod->name,sizeof (last_unloaded_module)); -unregister_dynamic_debug_module (mod->name); +ddebug_remove_module (mod->name);free_module (mod); out:
@@ -1823,19 +1823,13 @@ static inline void add_kallsyms(struct module *mod, }#endif /* CONFIG_KALLSYMS */ -static void dynamic_printk_setup (struct mod_debug *debug,unsigned int num) +static void dynamic_debug_setup (struct _ddebug *debug,unsigned int num) { -#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG -unsigned int i; - -for (i =0 ; i < num; i++) { -register_dynamic_debug_module (debug[i].modname, - debug[i].type, - debug[i].logical_modname, - debug[i].flag_names, - debug[i].hash, debug[i].hash2); - } -#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ +#ifdef CONFIG_DYNAMIC_DEBUG +if (ddebug_add_module (debug, num, debug->modname)) +printk (KERN_ERR "dynamic debug error adding module: %s\n" , + debug->modname); +#endif }static void *module_alloc_update_bounds (unsigned long size)
@@ -2201,12 +2195,13 @@ static noinline struct module *load_module(void __user *umod,add_kallsyms (mod, sechdrs, symindex, strindex, secstrings);if (!mod->taints) { -struct mod_debug *debug; +struct _ddebug *debug;unsigned int num_debug; debug =section_objs (hdr, sechdrs, secstrings,"__verbose" ,sizeof (*debug), &num_debug); -dynamic_printk_setup (debug, num_debug); +if (debug) +dynamic_debug_setup (debug, num_debug); }/* sechdrs[0].sh_size is always zero */
lib/Kconfig.debug +1 -1
@@ -851,7 +851,7 @@ menuconfig BUILD_DOCSRC Say N if you are unsure. -config DYNAMIC_PRINTK_DEBUG +config DYNAMIC_DEBUG bool "Enable dynamic printk() call support" default n depends on PRINTK
lib/Makefile +1 -1
@@ -82,7 +82,7 @@ obj-$(CONFIG_HAVE_LMB) += lmb.o obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o -obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o +obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o hostprogs-y := gen_crc32table clean-files := crc32table.h
lib/dynamic_debug.c new file +756 -0
756 lines not on this page · raw message
lib/dynamic_printk.c deleted +0 -414
414 lines not on this page · raw message
net/netfilter/nf_conntrack_pptp.c +1 -1
@@ -66,7 +66,7 @@ void struct nf_conntrack_expect *exp) __read_mostly;EXPORT_SYMBOL_GPL (nf_nat_pptp_hook_expectfn); -#if defined(DEBUG ) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG ) +#if defined(DEBUG ) || defined(CONFIG_DYNAMIC_DEBUG )/* PptpControlMessageType names */ const char *const pptp_msg_name[] = { "UNKNOWN_MESSAGE",
scripts/Makefile.lib +1 -1
@@ -97,7 +97,7 @@ modname_flags = $(if $(filter 1,$(words $(modname))),\ -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") #hash values -ifdef CONFIG_DYNAMIC_PRINTK_DEBUG +ifdef CONFIG_DYNAMIC_DEBUG debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\ -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))" else