[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140415130301.GL11182@twins.programming.kicks-ass.net>
Date: Tue, 15 Apr 2014 15:03:01 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: linux-kernel@...r.kernel.org, mingo@...e.hu, rjw@...ysocki.net,
nicolas.pitre@...aro.org, linux-pm@...r.kernel.org,
alex.shi@...aro.org, vincent.guittot@...aro.org,
morten.rasmussen@....com
Subject: Re: [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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists