Re: [tip: sched/core] sched/debug: Change SCHED_WARN_ON() to WARN_ON_ONCE()

From: Peter Zijlstra
Date: Mon Mar 24 2025 - 08:00:10 EST


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.

Also, last time I measured, there was a measurable performance
difference between SCHED_DEBUG=n and SCHED_DEBUG=y.