Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util()

Peter Zijlstra
2026-03-19T10:27:13Z

On Thu, Mar 19, 2026 at 11:01:03AM +0100, Uros Bizjak wrote:
> On Thu, Mar 19, 2026 at 10:02 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> > That fastpath is definitely better; the slowpath is worse, but that is
> > in part because the compilers are stupid and cannot eliminate
> > static_branch().
>
> asm gotos are implicitly volatile because they are control flow
> primitives. The compiler will *not* remove them.

Yes, but I want ponies ;-)

if (static_branch_unlikely(&foo)) {
if (static_branch_unlikely(&foo)) {
/* A */
} else {
/* B */
}
/* C */
}

Is a very common occurence. And we all know this really should be:

if (static_branch_unlikely(&foo)) {
/* A */
/* C */
}

So how can we make this happen? IMO marking those functions __const
should tell the compiler that yes, it can elimintate them.

You should not try and protect the user. If they use __const
incorrectly, they get to keep the pieces and all that.