[COMMON] cpufreq_schedutil: select idle cpu for scaling
authorPark Bumgyu <bumgyu.park@samsung.com>
Fri, 19 Jan 2018 08:05:55 +0000 (17:05 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:30:22 +0000 (17:30 +0900)
Change-Id: Ice84c50845dcd96689a51f481d969a557c84667a
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
kernel/sched/cpufreq_schedutil.c

index 1860ff391d2fb6ed86ef9442df09b5b6d3bf4a8a..c06b2b886ddefee2ccbcf9566104359a1d655513 100644 (file)
@@ -165,10 +165,34 @@ static bool sugov_up_down_rate_limit(struct sugov_policy *sg_policy, u64 time,
        return false;
 }
 
+static int sugov_select_scaling_cpu(void)
+{
+       int cpu;
+       cpumask_t mask;
+
+       cpumask_clear(&mask);
+       cpumask_and(&mask, cpu_coregroup_mask(0), cpu_online_mask);
+
+       /* Idle core of the boot cluster is selected to scaling cpu */
+       for_each_cpu(cpu, &mask)
+               if (idle_cpu(cpu))
+                       return cpu;
+
+       /* if panic_cpu is not Little core, mask will be empty */
+       if (unlikely(!cpumask_weight(&mask))) {
+               cpu = atomic_read(&panic_cpu);
+               if (cpu != PANIC_CPU_INVALID)
+                       return cpu;
+       }
+
+       return cpumask_weight(&mask) - 1;
+}
+
 static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
                                unsigned int next_freq)
 {
        struct cpufreq_policy *policy = sg_policy->policy;
+       int cpu;
 
        if (sg_policy->next_freq == next_freq)
                return;
@@ -187,8 +211,12 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
                policy->cur = next_freq;
                trace_cpu_frequency(next_freq, smp_processor_id());
        } else {
+               cpu = sugov_select_scaling_cpu();
+               if (cpu < 0)
+                       return;
+
                sg_policy->work_in_progress = true;
-               irq_work_queue(&sg_policy->irq_work);
+               irq_work_queue_on(&sg_policy->irq_work, cpu);
        }
 }