mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yuntao Wang <yuntao.wang@linux.dev>
To: akpm@linux-foundation.org
Cc: jbaron@akamai.com, jim.cromie@gmail.com,
	linux-kernel@vger.kernel.org, yuntao.wang@linux.dev
Subject: Re: [PATCH 1/2] dyndbg: fix incorrect mod_ct value in dynamic_debug_init()
Date: Sun, 30 Aug 2026 12:01:05 +0800	[thread overview]
Message-ID: <20260830040105.67865-1-yuntao.wang@linux.dev> (raw)
In-Reply-To: <20260829202306.67cf6ff7223b1bc33b57730d@linux-foundation.org>

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
> >

  reply	other threads:[~2026-08-30  4:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 12:18 [PATCH 0/2] " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260830040105.67865-1-yuntao.wang@linux.dev \
    --to=yuntao.wang@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®