Re: [PATCH v2 9/9] sched/topology: Define and use shortcut pointers for wakeup sd_flag scan

From: Valentin Schneider
Date: Thu Mar 19 2020 - 08:23:25 EST



On Thu, Mar 19 2020, Dietmar Eggemann wrote:
> On 11.03.20 19:16, Valentin Schneider wrote:
>> @@ -6621,7 +6610,19 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
>>
>> rcu_read_lock();
>>
>> - sd = highest_flag_domain(cpu, sd_flag);
>> + switch (wake_flags & (WF_TTWU | WF_FORK | WF_EXEC)) {
>> + case WF_TTWU:
>> + sd_flag = SD_BALANCE_WAKE;
>> + sd = rcu_dereference(per_cpu(sd_balance_wake, cpu));
>
> IMHO, since we hard-code 0*SD_BALANCE_WAKE in sd_init(), sd would always
> be NULL, so !want_affine (i.e. wake_wide()) would still go sis().
>
> SD_BALANCE_WAKE is no a topology related sd_flag so it can't be set from
> outside. Since the sd->flags sysctl is now read-only, wouldn't this case
> be redundant?
>

On a purely mainline kernel, yes, 'sd' will always be NULL for
wakeups. I'm playing a bit more conservative here with SD_BALANCE_WAKE,
as I could see some folks using that flag in some ~franken~ downstream
kernels (I am not aware of any, however).

Also, to be fair we've only very recently gotten rid of the last
SD_BALANCE_WAKE user (asymmetric CPU capacity topologies), so I felt
like keeping it around for a bit before entirely killing it would be a
sane thing to do.

> [...]