Re: [PATCH] bug: Add the condition string to the CONFIG_DEBUG_BUGVERBOSE=y output

From: Ingo Molnar
Date: Wed Mar 26 2025 - 03:42:39 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Tue, 25 Mar 2025 at 15:42, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
> >
> > So something like the patch below?
> > [...]
> > After:
> >
> > WARNING: CPU: 0 PID: 0 at [ptr == 0 && 1] kernel/sched/core.c:8511 sched_init+0x20/0x410
> > ^^^^^^^^^^^^^^^
>
> Hmm. Is that the prettiest output ever? No. But it does seem workable,
> and the patch is simple.
>
> And I think the added condition string is useful, in that I often end
> up looking up warnings that other people report and where the line
> numbers have changed enough that it's not immediately obvious exactly
> which warning it is. Not only does it disambiguate which warning it
> is, it would probably often would obviate having to look it up
> entirely because the warning message is now more useful.

Yeah, that exactly was the original motivation for SCHED_WARN_ON():
core kernel code often gets backported on and changed by distributions,
so line numbers are fuzzy and with large functions it's sometimes
unclear exactly where the warning originated from.

> So I think I like it. Let's see how it works in practice.
>
> (I actually think the "CPU: 0 PID: 0" is likely the least useful part
> of that warning string, and maybe *that* should be moved away and
> make things a bit more legible, but I think that discussion might as
> well be part of that "Let's see how it works")

Okay!

The CPU and PID part is particularly useless, given that it's repeated
in the splat a few lines later:

------------[ cut here ]------------^M
WARNING: CPU: 0 PID: 0 at [ptr == 0 && 1] kernel/sched/core.c:8511 sched_init+0x20/0x410
Modules linked in:
CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.14.0-01616-g94d7af2844aa #4 PREEMPT(undef)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:sched_init+0x20/0x410

So I'll just remove it, which will turn this into:

WARNING: [ptr == 0 && 1] kernel/sched/core.c:8511 sched_init+0x20/0x410

Which is actually pretty nicely formatted IMHO and orders the
information by expected entropy: most constant, most valuable
information comes first.

BTW., there's also another option we still have open: by using a unique
character separator that isn't 0 we could split up the single string
into cond_str and FILE_str parts, and leave formatting to
architectures. But I don't think it's needed if we get rid of the "CPU:
PID:" noise though.

Ingo