Re: [PATCH v3 6/9] sched: Kill select_task_rq()'s sd_flag parameter
From: Valentin Schneider
Date: Thu Apr 16 2020 - 06:25:57 EST
Hi Vincent,
Thanks for taking a look at this.
On 16/04/20 08:42, Vincent Guittot wrote:
>> @@ -6622,13 +6622,25 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>> * preempt must be disabled.
>> */
>> static int
>> -select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags)
>> +select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
>> {
>> + int sync = (wake_flags & WF_SYNC) && !(current->flags & PF_EXITING);
>> struct sched_domain *tmp, *sd = NULL;
>> int cpu = smp_processor_id();
>> int new_cpu = prev_cpu;
>> int want_affine = 0;
>> - int sync = (wake_flags & WF_SYNC) && !(current->flags & PF_EXITING);
>> + int sd_flag;
>> +
>> + switch (wake_flags & (WF_TTWU | WF_FORK | WF_EXEC)) {
>
> You remove a function parameter, which was directly set with the right
> flag, but then you add a switch case to recreate this sd_flag
> internally. Not sure we can say that it's real benefit
>
It is indeed the contentious point of this series (IMO). Still, it has a
few things going for it:
1) only CFS is helped by that extra parameter
2) with patch 9, I need a control flow to pick up the right cached pointer
anyway; the alternative would be to do something like the unsavoury:
DEFINE_PER_CPU(struct sched_domain __rcu *, sd_balance_flags[3]);
...
update_top_cache_domain()
{
per_cpu(sd_balance_flags[0], cpu) = highest_flag_domain(cpu, SD_BALANCE_EXEC);
per_cpu(sd_balance_flags[1], cpu) = highest_flag_domain(cpu, SD_BALANCE_FORK);
per_cpu(sd_balance_flags[2], cpu) = highest_flag_domain(cpu, SD_BALANCE_WAKE);
}
...
select_task_rq_fair()
{
// Whatever sort of shady constant time conversion you can think of
int index = !!(wake_flags & WF_FORK) + 2 * !!(wake_flags & WF_TTWU)
sd_flag = SD_BALANCE_EXEC << index;
sd = per_cpu(sd_balance_flags[index], cpu);
}
>> + case WF_TTWU:
>> + sd_flag = SD_BALANCE_WAKE;
>> + break;
>> + case WF_FORK:
>> + sd_flag = SD_BALANCE_FORK;
>> + break;
>> + default:
>> + sd_flag = SD_BALANCE_EXEC;
>> + }
>>
>> if (sd_flag & SD_BALANCE_WAKE) {
>> record_wakee(p);