lkml.org 
[lkml]   [2014]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCHC 3/3] sched/fair: use the idle state info to choose the idlest cpu
On Fri, Mar 28, 2014 at 01:29:56PM +0100, Daniel Lezcano wrote:
> @@ -4336,20 +4337,53 @@ static int
> find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
> {
> unsigned long load, min_load = ULONG_MAX;
> - int idlest = -1;
> + unsigned int min_exit_latency = UINT_MAX;
> + u64 idle_stamp, min_idle_stamp = ULONG_MAX;
> +
> + struct rq *rq;
> + struct cpuidle_power *power;
> +
> + int cpu_idle = -1;
> + int cpu_busy = -1;
> int i;
>
> /* Traverse only the allowed CPUs */
> for_each_cpu_and(i, sched_group_cpus(group), tsk_cpus_allowed(p)) {
> - load = weighted_cpuload(i);
>
> - if (load < min_load || (load == min_load && i == this_cpu)) {
> - min_load = load;
> - idlest = i;
> + if (idle_cpu(i)) {
> +
> + rq = cpu_rq(i);
> + power = rq->power;
> + idle_stamp = rq->idle_stamp;
> +
> + /* The cpu is idle since a shorter time */
> + if (idle_stamp < min_idle_stamp) {
> + min_idle_stamp = idle_stamp;
> + cpu_idle = i;
> + continue;
> + }
> +
> + /* The cpu is idle but the exit_latency is shorter */
> + if (power && power->exit_latency < min_exit_latency) {
> + min_exit_latency = power->exit_latency;
> + cpu_idle = i;
> + continue;
> + }

Aside from the arguments made by Nico (which I agree with), depending on
the life time rules of the power object we might need
smp_read_barrier_depends() between reading and using.

If all these objects are static and never change content we do not, if
there's dynamic objects involved we probably should.


\
 
 \ /
  Last update: 2014-04-15 15:21    [W:0.338 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site