Re: [tip: sched/core] sched/debug: Change SCHED_WARN_ON() to WARN_ON_ONCE()
From: Ingo Molnar
Date: Tue Mar 25 2025 - 05:42:41 EST
* Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Thu, Mar 20, 2025 at 09:00:05AM -0000, tip-bot2 for Ingo Molnar wrote:
> > The following commit has been merged into the sched/core branch of tip:
> >
> > Commit-ID: f7d2728cc032a23fccb5ecde69793a38eb30ba5c
> > Gitweb: https://git.kernel.org/tip/f7d2728cc032a23fccb5ecde69793a38eb30ba5c
> > Author: Ingo Molnar <mingo@xxxxxxxxxx>
> > AuthorDate: Mon, 17 Mar 2025 11:42:52 +01:00
> > Committer: Ingo Molnar <mingo@xxxxxxxxxx>
> > CommitterDate: Wed, 19 Mar 2025 22:20:53 +01:00
> >
> > sched/debug: Change SCHED_WARN_ON() to WARN_ON_ONCE()
> >
> > The scheduler has this special SCHED_WARN() facility that
> > depends on CONFIG_SCHED_DEBUG.
> >
> > Since CONFIG_SCHED_DEBUG is getting removed, convert
> > SCHED_WARN() to WARN_ON_ONCE().
> >
> > Note that the warning output isn't 100% equivalent:
> >
> > #define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
> >
> > Because SCHED_WARN_ON() would output the 'x' condition
> > as well, while WARN_ONCE() will only show a backtrace.
> >
> > Hopefully these are rare enough to not really matter.
> >
> > If it does, we should probably introduce a new WARN_ON()
> > variant that outputs the condition in stringified form,
> > or improve WARN_ON() itself.
>
> So those strings really were useful, trouble is WARN_ONCE() generates
> utter crap code compared to WARN_ON_ONCE(), but since SCHED_DEBUG that
> doesn't really matter.
Why wouldn't it matter? CONFIG_SCHED_DEBUG was turned on for 99.9999%
of Linux users, ie. we generated crap code for most of our users.
And as a side effect of using the standard WARN_ON_ONCE() primitive we
now generate better code, at the expense of harder to interpret debug
output, right?
Ie. CONFIG_SCHED_DEBUG has obfuscated crappy code generation under the
"it's only debugging code" pretense, right?
> Also, last time I measured, there was a measurable performance
> difference between SCHED_DEBUG=n and SCHED_DEBUG=y.
Which 99.9999% of Linux users are affected by. The config option
basically did nothing for them but hide this overhead...
Thanks,
Ingo