Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161868AbbBDSe4 (ORCPT ); Wed, 4 Feb 2015 13:34:56 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:41670 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966926AbbBDSbp (ORCPT ); Wed, 4 Feb 2015 13:31:45 -0500 From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: vincent.guittot@linaro.org, dietmar.eggemann@arm.com, yuyang.du@intel.com, preeti@linux.vnet.ibm.com, mturquette@linaro.org, nico@linaro.org, rjw@rjwysocki.net, juri.lelli@arm.com, linux-kernel@vger.kernel.org Subject: [RFCv3 PATCH 42/48] sched: Introduce energy awareness into find_busiest_queue Date: Wed, 4 Feb 2015 18:31:19 +0000 Message-Id: <1423074685-6336-43-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423074685-6336-1-git-send-email-morten.rasmussen@arm.com> References: <1423074685-6336-1-git-send-email-morten.rasmussen@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2159 Lines: 66 From: Dietmar Eggemann In case that after the gathering of sched domain statistics the current load balancing operation is still in energy-aware mode and a least efficient sched group has been found, detect the least efficient cpu by comparing the cpu efficiency (ratio between cpu usage and cpu energy consumption) among all cpus of the least efficient sched group. cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Dietmar Eggemann --- kernel/sched/fair.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 199ffff..48cd5b5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7216,6 +7216,37 @@ static struct rq *find_busiest_queue(struct lb_env *env, unsigned long busiest_load = 0, busiest_capacity = 1; int i; + if (env->use_ea) { + struct rq *costliest = NULL; + unsigned long costliest_usage = 1024, costliest_energy = 1; + + for_each_cpu_and(i, sched_group_cpus(group), env->cpus) { + unsigned long usage = get_cpu_usage(i); + struct rq *rq = cpu_rq(i); + struct sched_domain *sd = rcu_dereference(rq->sd); + struct energy_env eenv = { + .sg_top = sd->groups, + .usage_delta = 0, + .src_cpu = -1, + .dst_cpu = -1, + }; + unsigned long energy = sched_group_energy(&eenv); + + /* + * We're looking for the minimal cpu efficiency + * min(u_i / e_i), crosswise multiplication leads to + * u_i * e_j < u_j * e_i with j as previous minimum. + */ + if (usage * costliest_energy < costliest_usage * energy) { + costliest_usage = usage; + costliest_energy = energy; + costliest = rq; + } + } + + return costliest; + } + for_each_cpu_and(i, sched_group_cpus(group), env->cpus) { unsigned long capacity, wl; enum fbq_type rt; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/