* [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init()
@ 2026-08-11 12:18 Yuntao Wang
2026-08-11 12:18 ` [PATCH 1/2] " Yuntao Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yuntao Wang @ 2026-08-11 12:18 UTC (permalink / raw)
To: Jason Baron, Jim Cromie; +Cc: Andrew Morton, linux-kernel, Yuntao Wang
Fix and clean up the dynamic_debug_init() function.
Yuntao Wang (2):
dyndbg: fix incorrect mod_ct value in dynamic_debug_init()
dyndbg: clean up dynamic_debug_init() to improve readability
lib/dynamic_debug.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() 2026-08-11 12:18 [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang @ 2026-08-11 12:18 ` Yuntao Wang 2026-08-30 3:23 ` Andrew Morton 2026-08-11 12:18 ` [PATCH 2/2] dyndbg: clean up dynamic_debug_init() to improve readability Yuntao Wang 2026-08-27 1:31 ` [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang 2 siblings, 1 reply; 6+ messages in thread From: Yuntao Wang @ 2026-08-11 12:18 UTC (permalink / raw) To: Jason Baron, Jim Cromie; +Cc: Andrew Morton, linux-kernel, Yuntao Wang Suppose all `struct _ddebug` instances belong to the same module, mod_ct should be 1, but it is currently 0. Fix it. Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev> --- lib/dynamic_debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 18a71a9108d3..16fad5454d6a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1456,6 +1456,8 @@ static int __init dynamic_debug_init(void) iter_mod_start = iter; } } + + mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; ret = ddebug_add_module(&di, modname); -- 2.55.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() 2026-08-11 12:18 ` [PATCH 1/2] " Yuntao Wang @ 2026-08-30 3:23 ` Andrew Morton 2026-08-30 4:01 ` Yuntao Wang 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2026-08-30 3:23 UTC (permalink / raw) To: Yuntao Wang; +Cc: Jason Baron, Jim Cromie, linux-kernel On Tue, 11 Aug 2026 20:18:30 +0800 Yuntao Wang <yuntao.wang@linux.dev> wrote: > Suppose all `struct _ddebug` instances belong to the same module, mod_ct > should be 1, but it is currently 0. Oh. Why. Does if (strcmp(modname, iter->modname)) { not evaluate to true in this situation? ie, more details please. > Fix it. What are the userspace-visible runtime effects of this bug? Thanks. > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -1456,6 +1456,8 @@ static int __init dynamic_debug_init(void) > iter_mod_start = iter; > } > } > + > + mod_ct++; > di.num_descs = mod_sites; > di.descs = iter_mod_start; > ret = ddebug_add_module(&di, modname); > -- > 2.55.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() 2026-08-30 3:23 ` Andrew Morton @ 2026-08-30 4:01 ` Yuntao Wang 0 siblings, 0 replies; 6+ messages in thread From: Yuntao Wang @ 2026-08-30 4:01 UTC (permalink / raw) To: akpm; +Cc: jbaron, jim.cromie, linux-kernel, yuntao.wang On Sat, 29 Aug 2026 20:23:06 -0700, Andrew Morton <akpm@linux-foundation.org> wrote: > On Tue, 11 Aug 2026 20:18:30 +0800 Yuntao Wang <yuntao.wang@linux.dev> wrote: > > > Suppose all `struct _ddebug` instances belong to the same module, mod_ct > > should be 1, but it is currently 0. > > Oh. Why. Does > > if (strcmp(modname, iter->modname)) { > > not evaluate to true in this situation? > > ie, more details please. > > > Fix it. > > What are the userspace-visible runtime effects of this bug? > > Thanks. Hi Andrew, mod_ct is incremented only when iter->modname changes, i.e. when the loop encounters the first _ddebug entry of a new module: if (strcmp(modname, iter->modname)) { mod_ct++; ... } If all _ddebug entries belong to the same module, strcmp() never returns nonzero, so mod_ct remains 0. However, the last (and in this case only) module is added after the loop: di.num_descs = mod_sites; di.descs = iter_mod_start; ret = ddebug_add_module(&di, modname); Thus, mod_ct should be incremented before adding this final module. The bug only affects the diagnostic message printed by vpr_info(): "%d prdebugs in %d modules, ..." It reports one fewer module than the actual number of modules. There is no userspace-visible runtime effect; the dynamic debug tables themselves are initialized correctly. Thanks, Yuntao > > --- a/lib/dynamic_debug.c > > +++ b/lib/dynamic_debug.c > > @@ -1456,6 +1456,8 @@ static int __init dynamic_debug_init(void) > > iter_mod_start = iter; > > } > > } > > + > > + mod_ct++; > > di.num_descs = mod_sites; > > di.descs = iter_mod_start; > > ret = ddebug_add_module(&di, modname); > > -- > > 2.55.0 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] dyndbg: clean up dynamic_debug_init() to improve readability 2026-08-11 12:18 [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang 2026-08-11 12:18 ` [PATCH 1/2] " Yuntao Wang @ 2026-08-11 12:18 ` Yuntao Wang 2026-08-27 1:31 ` [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang 2 siblings, 0 replies; 6+ messages in thread From: Yuntao Wang @ 2026-08-11 12:18 UTC (permalink / raw) To: Jason Baron, Jim Cromie; +Cc: Andrew Morton, linux-kernel, Yuntao Wang Keep variable assignments in the same order throughout the function to make the code easier to follow. No functional changes. Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev> --- lib/dynamic_debug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 16fad5454d6a..49334d1aa4b3 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1442,28 +1442,29 @@ static int __init dynamic_debug_init(void) i = mod_sites = mod_ct = 0; for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { - if (strcmp(modname, iter->modname)) { - mod_ct++; - di.num_descs = mod_sites; di.descs = iter_mod_start; + di.num_descs = mod_sites; ret = ddebug_add_module(&di, modname); if (ret) goto out_err; - mod_sites = 0; - modname = iter->modname; + mod_ct++; + iter_mod_start = iter; + modname = iter->modname; + mod_sites = 0; } } - mod_ct++; - di.num_descs = mod_sites; di.descs = iter_mod_start; + di.num_descs = mod_sites; ret = ddebug_add_module(&di, modname); if (ret) goto out_err; + mod_ct++; + ddebug_init_success = 1; vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), -- 2.55.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() 2026-08-11 12:18 [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang 2026-08-11 12:18 ` [PATCH 1/2] " Yuntao Wang 2026-08-11 12:18 ` [PATCH 2/2] dyndbg: clean up dynamic_debug_init() to improve readability Yuntao Wang @ 2026-08-27 1:31 ` Yuntao Wang 2 siblings, 0 replies; 6+ messages in thread From: Yuntao Wang @ 2026-08-27 1:31 UTC (permalink / raw) To: akpm, jbaron, jim.cromie; +Cc: yuntao.wang, linux-kernel Hi all, Just a gentle ping on this patch series. Any chance someone could take a look and review it? I'd really appreciate it. Thanks, Yuntao ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-30 4:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-08-11 12:18 [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang 2026-08-11 12:18 ` [PATCH 1/2] " Yuntao Wang 2026-08-30 3:23 ` Andrew Morton 2026-08-30 4:01 ` Yuntao Wang 2026-08-11 12:18 ` [PATCH 2/2] dyndbg: clean up dynamic_debug_init() to improve readability Yuntao Wang 2026-08-27 1:31 ` [PATCH 0/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init() Yuntao Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®