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

From: Patrick Bellasi
Date: Tue Jun 30 2020 - 10:56:00 EST



Hi Qais,
sorry for commenting on v5 with a v6 already posted, but...
... I cannot keep up with your re-spinning rate ;)

More importantly, perhaps you missed to comment on one of my previous
points.

Will have a better look at the rest of v6 later today.

Cheers,
Patrick

On Tue, Jun 30, 2020 at 11:46:24 +0200, Qais Yousef <qais.yousef@xxxxxxx> wrote...
> On 06/30/20 10:11, Patrick Bellasi wrote:
>> On Mon, Jun 29, 2020 at 18:26:33 +0200, Qais Yousef <qais.yousef@xxxxxxx> wrote...

[...]

>> > +
>> > +static inline bool uclamp_is_enabled(void)
>> > +{
>> > + return static_branch_likely(&sched_uclamp_used);
>> > +}
>>
>> Looks like here we mix up terms, which can be confusing.
>> AFAIKS, we use:
>> - *_enabled for the sched class flags (compile time)
>> - *_used for the user-space opting in (run time)
>
> I wanted to add a comment here.
>
> I can rename it to uclamp_is_used() if you want.

In my previous message I was mostly asking about this:

>> Thus, perhaps we can just use the same pattern used by the
>> sched_numa_balancing static key:
>>
>> $ git grep sched_numa_balancing
>> kernel/sched/core.c:DEFINE_STATIC_KEY_FALSE(sched_numa_balancing);
>> kernel/sched/core.c: static_branch_enable(&sched_numa_balancing);
>> kernel/sched/core.c: static_branch_disable(&sched_numa_balancing);
>> kernel/sched/core.c: int state = static_branch_likely(&sched_numa_balancing);
>> kernel/sched/fair.c: if (!static_branch_likely(&sched_numa_balancing))
>> kernel/sched/fair.c: if (!static_branch_likely(&sched_numa_balancing))
>> kernel/sched/fair.c: if (!static_branch_likely(&sched_numa_balancing))
>> kernel/sched/fair.c: if (static_branch_unlikely(&sched_numa_balancing))
>> kernel/sched/sched.h:extern struct static_key_false sched_numa_balancing;
>>
>> IOW: unconditionally define sched_uclamp_used as non static in core.c,
>> and use it directly on schedutil too.

So, what about this instead of adding the (renamed) method above?