Re: [PATCH 2/2] sched/uclamp: Protect uclamp fast path code with static key

From: Valentin Schneider
Date: Fri Jun 19 2020 - 14:52:43 EST



On 19/06/20 18:25, Qais Yousef wrote:
> On 06/19/20 16:17, Valentin Schneider wrote:
>
> [...]
>
>> > But here this is
>> > just extra churn.
>> >
>> > If an imbalance has happend this means either:
>> >
>> > 1. enqueue/dequeue_task() is imablanced itself
>> > 2. uclamp_update_active() calls dec without inc.
>> >
>> > If 1 happened we have more reasons to be worried about. For 2 the function
>> > takes task_rq_lock() and does dec/inc in obvious way.
>> >
>>
>> True. I won't argue over the feasibility of the scenarios we are currently
>> aware of, my point was that if they do happen, it's nice to have debug
>> helps in the right places as the final breakage can happen much further
>> downstream.
>>
>> FWIW I don't like the diff I suggested at all, but if we can come up with a
>> cleverer scheme I think we should do it, as per the above.
>
> There's the fact as well that this whole thing is to deal with potentially
> avoid doing anything that is stricly not necessary in the fast path.
>
> keep in mind that my patch of introducing the sysctl is not accepted yet
> because it introduces such thing, but in that case it's not a debug only
> feature. CONFIG_SCHED_DEBUG do get enabled by distros because it exports a lot
> of useful info.

Sigh, true, but they really shouldn't. The whole point of having
SCHED_WARN_ON() is that it's a no-op on !SCHED_DEBUG kernels, which should
be any "production" kernel :(