dyndbg: let's use the module notifier callback
Subsystems (3)
Jason Baron
maintainercover dyndbg: let's use the module notifier callback
Hi,
Jim Cromie hit a BUG() while toggling jump label branches in a module before they were properly initialized. This isn't currently an issue, but will be as part of his pending classmap series. Seems like we should covert to using module callback notifier for dynamic debug anyways. First patch is just a cleanup.
Thanks,
-Jason
Jason Baron (2):
dyndbg: remove unused 'base' arg from __ddebug_add_module()
dyndbg: use the module notifier callbacks
include/linux/dynamic_debug.h | 13 ---------- include/linux/module.h | 3 +++ kernel/module/internal.h | 1 - kernel/module/main.c | 30 ++++++--------------- lib/dynamic_debug.c | 49 ++++++++++++++++++++++++++++------- 5 files changed, 51 insertions(+), 45 deletions(-)
Signature · 1 line
2.17.1
Jason Baron
maintainerPATCH 1/2 dyndbg: remove unused 'base' arg from __ddebug_add_module()
__ddebug_add_module() doesn't use the 'base' arg. Remove it.
--- lib/dynamic_debug.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
lib/dynamic_debug.c +4 -5
@@ -1223,8 +1223,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt,* Allocate a new ddebug_table for the given module * and add it to the global list. */ -static int __ddebug_add_module (struct _ddebug_info *di,unsigned int base, -const char *modname) +static int __ddebug_add_module (struct _ddebug_info *di,const char *modname) {struct ddebug_table *dt;
@@ -1265,7 +1264,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base,int ddebug_add_module (struct _ddebug_info *di,const char *modname) { -return __ddebug_add_module (di,0 , modname); +return __ddebug_add_module (di, modname); }/* helper for ddebug_dyndbg_(boot|module)_param_cb */
@@ -1408,7 +1407,7 @@ static int __init dynamic_debug_init(void) mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; - ret =__ddebug_add_module (&di, i - mod_sites, modname); + ret =__ddebug_add_module (&di, modname);if (ret) goto out_err;
@@ -1419,7 +1418,7 @@ static int __init dynamic_debug_init(void) } di.num_descs = mod_sites; di.descs = iter_mod_start; - ret =__ddebug_add_module (&di, i - mod_sites, modname); + ret =__ddebug_add_module (&di, modname);if (ret) goto out_err;
Signature · 1 line
2.17.1
Jason Baron
maintainerPATCH 2/2 dyndbg: use the module notifier callbacks
In reply to Jason BaronAs part of Jim Cromie's new dynamic debug classmap feature, the new code tries to toggle a jump label from dynamic_debug_setup(). However, dynamic_debug_setup() is called before the 'module_notify_list' notifier chain is invoked. And jump labels are initialized via the module notifier chain. Note this is an issue for a new feature not yet merged and doesn't affect any existing codepaths.
We could just move dynamic_debug_setup() earlier in load_module(). But let's instead ensure the ordering via the 'priority' in the module list notifier. This brings dynamic debug more in line with other subsystems and pulls code out of the core module code.
--- include/linux/dynamic_debug.h | 13 ---------- include/linux/module.h | 3 +++ kernel/module/internal.h | 1 - kernel/module/main.c | 30 ++++++---------------- lib/dynamic_debug.c | 48 +++++++++++++++++++++++++++++------ 5 files changed, 51 insertions(+), 44 deletions(-)
include/linux/dynamic_debug.h +0 -13
@@ -130,9 +130,6 @@ struct ddebug_class_param {#if defined(CONFIG_DYNAMIC_DEBUG_CORE ) -int ddebug_add_module (struct _ddebug_info *dyndbg,const char *modname); - -extern int ddebug_remove_module (const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
@@ -304,16 +301,6 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp);#include <linux/errno.h> #include <linux/printk.h> -static inline int ddebug_add_module (struct _ddebug_info *dinfo,const char *modname) -{ -return 0 ; -} - -static inline int ddebug_remove_module (const char *mod) -{ -return 0 ; -} -static inline int ddebug_dyndbg_module_param_cb (char *param,char *val,const char *modname) {
include/linux/module.h +3 -0
@@ -546,6 +546,9 @@ struct module {struct error_injection_entry *ei_funcs;unsigned int num_ei_funcs;#endif +#ifdef CONFIG_DYNAMIC_DEBUG_CORE +struct _ddebug_info dyndbg_info; +#endif }____cacheline_aligned __randomize_layout;#ifndef MODULE_ARCH_INIT #define MODULE_ARCH_INIT {}
kernel/module/internal.h +0 -1
@@ -63,7 +63,6 @@ struct load_info {Elf_Shdr *sechdrs;char *secstrings, *strtab;unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; -struct _ddebug_info dyndbg;bool sig_ok;#ifdef CONFIG_KALLSYMS unsigned long mod_kallsyms_init_off;
kernel/module/main.c +8 -22
@@ -1157,9 +1157,6 @@ static void free_module(struct module *mod) mod->state =MODULE_STATE_UNFORMED ;mutex_unlock (&module_mutex); -/* Remove dynamic debug info */ -ddebug_remove_module (mod->name); -/* Arch-specific cleanup. */ module_arch_cleanup (mod);
@@ -1591,19 +1588,6 @@ static void free_modinfo(struct module *mod) } } -static void dynamic_debug_setup (struct module *mod,struct _ddebug_info *dyndbg) -{ -if (!dyndbg->num_descs) -return ; -ddebug_add_module (dyndbg, mod->name); -} - -static void dynamic_debug_remove (struct module *mod,struct _ddebug_info *dyndbg) -{ -if (dyndbg->num_descs) -ddebug_remove_module (mod->name); -} -void *__weak module_alloc (unsigned long size) { return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
@@ -2109,10 +2093,14 @@ static int find_module_sections(struct module *mod, struct load_info *info)if (section_addr (info,"__obsparm" ))pr_warn ("%s: Ignoring obsolete parameters\n" , mod->name); - info->dyndbg.descs =section_objs (info,"__dyndbg" , -sizeof (*info->dyndbg.descs), &info->dyndbg.num_descs); - info->dyndbg.classes =section_objs (info,"__dyndbg_classes" , -sizeof (*info->dyndbg.classes), &info->dyndbg.num_classes); +#ifdef CONFIG_DYNAMIC_DEBUG_CORE + mod->dyndbg_info.descs =section_objs (info,"__dyndbg" , +sizeof (*mod->dyndbg_info.descs), + &mod->dyndbg_info.num_descs); + mod->dyndbg_info.classes =section_objs (info,"__dyndbg_classes" , +sizeof (*mod->dyndbg_info.classes), + &mod->dyndbg_info.num_classes); +#endif return 0 ; }
@@ -2824,7 +2812,6 @@ static int load_module(struct load_info *info, const char __user *uargs, }init_build_id (mod, info); -dynamic_debug_setup (mod, &info->dyndbg);/* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init (mod);
@@ -2888,7 +2875,6 @@ static int load_module(struct load_info *info, const char __user *uargs, ddebug_cleanup:ftrace_release_mod (mod); -dynamic_debug_remove (mod, &info->dyndbg);synchronize_rcu ();kfree (mod->args); free_arch_cleanup:
lib/dynamic_debug.c +40 -8
84 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 11 lines · Jason Baron
Hi,
Jim Cromie hit a
BUG()while toggling jump label branches in a module before they were properly initialized. This isn't currently an issue, but will be as part of his pending classmap series. Seems like we should covert to using module callback notifier for dynamic debug anyways. First patch is just a cleanup.
Quoted 7 lines
Thanks,
-Jason
Jason Baron (2):
dyndbg: remove unused 'base' arg from__ddebug_add_module()
dyndbg: use the module notifier callbacks
Ive rebased my set upon yours, and dropped my RFC-workaround patch. No panics on uninitialized jump-labels,
and test script works correctly.
I will include your commits in my next send, so theyre testable as a set.
thanks
Jim
Quoted 11 lines
include/linux/dynamic_debug.h | 13 ---------- include/linux/module.h | 3 +++ kernel/module/internal.h | 1 - kernel/module/main.c | 30 ++++++--------------- lib/dynamic_debug.c | 49 ++++++++++++++++++++++++++++------- 5 files changed, 51 insertions(+), 45 deletions(-)--
2.17.1