Re: [RFC v5 4/6] sched/fair: Tune task wake-up logic to pack small background tasks on fewer cores

From: Parth Shah
Date: Wed Oct 09 2019 - 05:23:11 EST




On 10/8/19 6:58 PM, Hillf Danton wrote:
>
> On Mon, 7 Oct 2019 14:00:49 +0530 Parth Shah wrote:
>> +/*
>> + * Try to find a non idle core in the system based on few heuristics:
>> + * - Keep track of overutilized (>80% util) and busy (>12.5% util) CPUs
>> + * - If none CPUs are busy then do not select the core for task packing
>> + * - If atleast one CPU is busy then do task packing unless overutilized CPUs
>> + * count is < busy/2 CPU count
>> + * - Always select idle CPU for task packing
>> + */
>> +static int select_non_idle_core(struct task_struct *p, int prev_cpu, int target)
>> +{
>> + struct cpumask *cpus = this_cpu_cpumask_var_ptr(turbo_sched_mask);
>> + int iter_cpu, sibling;
>> +
>> + cpumask_and(cpus, cpu_online_mask, p->cpus_ptr);
>> +
>> + for_each_cpu_wrap(iter_cpu, cpus, prev_cpu) {
>> + int idle_cpu_count = 0, non_idle_cpu_count = 0;
>> + int overutil_cpu_count = 0;
>> + int busy_cpu_count = 0;
>> + int best_cpu = iter_cpu;
>> +
>> + for_each_cpu(sibling, cpu_smt_mask(iter_cpu)) {
>> + __cpumask_clear_cpu(sibling, cpus);
>> + if (idle_cpu(iter_cpu)) {
>
> Would you please elaborate the reasons that the iter cpu is checked idle
> more than once for finding a busy core?
>

Thanks for looking at the patches.
Could you please point me out where iter_cpu is checked more than once?

>> + idle_cpu_count++;
>> + best_cpu = iter_cpu;
>> + } else {
>> + non_idle_cpu_count++;
>> + if (cpu_overutilized(iter_cpu))
>> + overutil_cpu_count++;
>> + if (is_cpu_busy(cpu_util(iter_cpu)))
>> + busy_cpu_count++;
>> + }
>> + }
>> +
>