aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJason Baron <jbaron@redhat.com>2008-08-12 16:46:19 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-16 12:24:47 -0400
commit346e15beb5343c2eb8216d820f2ed8f150822b08 (patch)
tree6433cf2980bbfbed4a9482c5edb156fc8371e071 /kernel
parent33376c1c043c05077b4ac79c33804266f6c45e49 (diff)
driver core: basic infrastructure for per-module dynamic debug messages
Base infrastructure to enable per-module debug messages. I've introduced CONFIG_DYNAMIC_PRINTK_DEBUG, which when enabled centralizes control of debugging statements on a per-module basis in one /proc file, currently, <debugfs>/dynamic_printk/modules. When, CONFIG_DYNAMIC_PRINTK_DEBUG, is not set, debugging statements can still be enabled as before, often by defining 'DEBUG' for the proper compilation unit. Thus, this patch set has no affect when CONFIG_DYNAMIC_PRINTK_DEBUG is not set. The infrastructure currently ties into all pr_debug() and dev_dbg() calls. That is, if CONFIG_DYNAMIC_PRINTK_DEBUG is set, all pr_debug() and dev_dbg() calls can be dynamically enabled/disabled on a per-module basis. Future plans include extending this functionality to subsystems, that define their own debug levels and flags. Usage: Dynamic debugging is controlled by the debugfs file, <debugfs>/dynamic_printk/modules. This file contains a list of the modules that can be enabled. The format of the file is as follows: <module_name> <enabled=0/1> . . . <module_name> : Name of the module in which the debug call resides <enabled=0/1> : whether the messages are enabled or not For example: snd_hda_intel enabled=0 fixup enabled=1 driver enabled=0 Enable a module: $echo "set enabled=1 <module_name>" > dynamic_printk/modules Disable a module: $echo "set enabled=0 <module_name>" > dynamic_printk/modules Enable all modules: $echo "set enabled=1 all" > dynamic_printk/modules Disable all modules: $echo "set enabled=0 all" > dynamic_printk/modules Finally, passing "dynamic_printk" at the command line enables debugging for all modules. This mode can be turned off via the above disable command. [gkh: minor cleanups and tweaks to make the build work quietly] Signed-off-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c
index d5fcd24e5aff..c52700667292 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
784 mutex_lock(&module_mutex); 784 mutex_lock(&module_mutex);
785 /* Store the name of the last unloaded module for diagnostic purposes */ 785 /* Store the name of the last unloaded module for diagnostic purposes */
786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
787 unregister_dynamic_debug_module(mod->name);
787 free_module(mod); 788 free_module(mod);
788 789
789 out: 790 out:
@@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod,
1783} 1784}
1784#endif /* CONFIG_KALLSYMS */ 1785#endif /* CONFIG_KALLSYMS */
1785 1786
1787#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
1788static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex)
1789{
1790 struct mod_debug *debug_info;
1791 unsigned long pos, end;
1792 unsigned int num_verbose;
1793
1794 pos = sechdrs[verboseindex].sh_addr;
1795 num_verbose = sechdrs[verboseindex].sh_size /
1796 sizeof(struct mod_debug);
1797 end = pos + (num_verbose * sizeof(struct mod_debug));
1798
1799 for (; pos < end; pos += sizeof(struct mod_debug)) {
1800 debug_info = (struct mod_debug *)pos;
1801 register_dynamic_debug_module(debug_info->modname,
1802 debug_info->type, debug_info->logical_modname,
1803 debug_info->flag_names, debug_info->hash,
1804 debug_info->hash2);
1805 }
1806}
1807#else
1808static inline void dynamic_printk_setup(Elf_Shdr *sechdrs,
1809 unsigned int verboseindex)
1810{
1811}
1812#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
1813
1786static void *module_alloc_update_bounds(unsigned long size) 1814static void *module_alloc_update_bounds(unsigned long size)
1787{ 1815{
1788 void *ret = module_alloc(size); 1816 void *ret = module_alloc(size);
@@ -1831,6 +1859,7 @@ static noinline struct module *load_module(void __user *umod,
1831#endif 1859#endif
1832 unsigned int markersindex; 1860 unsigned int markersindex;
1833 unsigned int markersstringsindex; 1861 unsigned int markersstringsindex;
1862 unsigned int verboseindex;
1834 struct module *mod; 1863 struct module *mod;
1835 long err = 0; 1864 long err = 0;
1836 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1865 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -2117,6 +2146,7 @@ static noinline struct module *load_module(void __user *umod,
2117 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); 2146 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
2118 markersstringsindex = find_sec(hdr, sechdrs, secstrings, 2147 markersstringsindex = find_sec(hdr, sechdrs, secstrings,
2119 "__markers_strings"); 2148 "__markers_strings");
2149 verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose");
2120 2150
2121 /* Now do relocations. */ 2151 /* Now do relocations. */
2122 for (i = 1; i < hdr->e_shnum; i++) { 2152 for (i = 1; i < hdr->e_shnum; i++) {
@@ -2167,6 +2197,7 @@ static noinline struct module *load_module(void __user *umod,
2167 marker_update_probe_range(mod->markers, 2197 marker_update_probe_range(mod->markers,
2168 mod->markers + mod->num_markers); 2198 mod->markers + mod->num_markers);
2169#endif 2199#endif
2200 dynamic_printk_setup(sechdrs, verboseindex);
2170 err = module_finalize(hdr, sechdrs, mod); 2201 err = module_finalize(hdr, sechdrs, mod);
2171 if (err < 0) 2202 if (err < 0)
2172 goto cleanup; 2203 goto cleanup;