From patchwork Thu Jul 3 16:26:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 33035 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A67A203AC for ; Thu, 3 Jul 2014 16:26:44 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf1919324oag.10 for ; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=6TyZFwzoE5aShj3CvJjC9m+OPGENPiznsV3Ji4L6Qlo=; b=CUlUj9PHGGjXF6XEXQColqSSj8SvEFHEVGX/3wilp23b0xtgArI+2Q9uvwIN8aMlcr nOFJfU4ulgAH0xhBxFxYlCht/4ZAbeRIX/OPp8OMM5nhpANfz4fzcYaRVFdkiGDqsUnd GLHCqX4Q36aqVmlzzZ31Lm1hj1ZuFVosiKH8HQV/O0ebf1QjF90j96UlRmHo/PtcOka9 fg/yXd4cUL38tyug+04F3fswx3UT5Qxh8aS+I7DAljQ1a4VUN0J6cHiu/ms1WEIqwf1x B3GBKNDGP1VutpMe3tNNd+aBDlj6x48NgxZ1MW5zqpodCeOA++cEEZfHWVCErXn2mDc0 lQFg== X-Gm-Message-State: ALoCoQmEAp1ayssyZ7Or7GvTFY5qzFwJ0K/LwGlxhiefQ8yBHuYG1rf+1JDZfHHsQ+OOBT8b7d7E X-Received: by 10.182.66.198 with SMTP id h6mr2816818obt.12.1404404803920; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.168 with SMTP id h37ls565290qgd.62.gmail; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) X-Received: by 10.58.46.34 with SMTP id s2mr1402576vem.49.1404404803805; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id nh6si14420273vec.57.2014.07.03.09.26.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id i13so490340veh.22 for ; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) X-Received: by 10.52.0.177 with SMTP id 17mr4061966vdf.12.1404404803735; Thu, 03 Jul 2014 09:26:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp390325vcb; Thu, 3 Jul 2014 09:26:43 -0700 (PDT) X-Received: by 10.70.94.42 with SMTP id cz10mr5022949pdb.107.1404404802826; Thu, 03 Jul 2014 09:26:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zm3si33328779pac.97.2014.07.03.09.26.42; Thu, 03 Jul 2014 09:26:42 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759386AbaGCQ02 (ORCPT + 27 others); Thu, 3 Jul 2014 12:26:28 -0400 Received: from service87.mimecast.com ([91.220.42.44]:45941 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759364AbaGCQ0Z (ORCPT ); Thu, 3 Jul 2014 12:26:25 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 03 Jul 2014 17:26:23 +0100 Received: from e103034-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Jul 2014 17:26:23 +0100 From: Morten Rasmussen To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, mingo@kernel.org Cc: rjw@rjwysocki.net, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, preeti@linux.vnet.ibm.com, Dietmar.Eggemann@arm.com, pjt@google.com Subject: [RFCv2 PATCH 21/23] sched: Use energy model in select_idle_sibling Date: Thu, 3 Jul 2014 17:26:08 +0100 Message-Id: <1404404770-323-22-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> References: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 03 Jul 2014 16:26:23.0850 (UTC) FILETIME=[87DDD4A0:01CF96DB] X-MC-Unique: 114070317262314501 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: morten.rasmussen@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Make select_idle_sibling() consider energy when picking an idle cpu. This implies having to look beyond sd_llc. Otherwise, consolidating short frequently running tasks on fewer llc domains will not happen when that is feasible. The fix is to start select_idle_sibling() at the highest sched_domain level. A more refined approach causing less overhead will be considered later. That could be to only look beyond sd_llc occasionally. Only idle cpus are still considered. A more aggressive energy conserving approach could go further and consider partially utilized cpus. Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index aebf3e2..a32d6eb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4747,9 +4747,19 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu) */ static int select_idle_sibling(struct task_struct *p, int target) { - struct sched_domain *sd; + struct sched_domain *sd = NULL, *tmp; struct sched_group *sg; int i = task_cpu(p); + int target_nrg; + int nrg_min, nrg_cpu = -1; + + if (energy_aware()) { + /* When energy-aware, go above sd_llc */ + for_each_domain(target, tmp) + sd = tmp; + + goto loop; + } if (idle_cpu(target)) return target; @@ -4764,6 +4774,10 @@ static int select_idle_sibling(struct task_struct *p, int target) * Otherwise, iterate the domains and find an elegible idle cpu. */ sd = rcu_dereference(per_cpu(sd_llc, target)); + +loop: + target_nrg = nrg_min = energy_diff_task(target, p); + for_each_lower_domain(sd) { sg = sd->groups; do { @@ -4772,16 +4786,35 @@ static int select_idle_sibling(struct task_struct *p, int target) goto next; for_each_cpu(i, sched_group_cpus(sg)) { + int nrg_diff; + if (energy_aware()) { + if (!idle_cpu(i)) + continue; + + nrg_diff = energy_diff_task(i, p); + if (nrg_diff < nrg_min) { + nrg_min = nrg_diff; + nrg_cpu = i; + } + } + if (i == target || !idle_cpu(i)) goto next; } - target = cpumask_first_and(sched_group_cpus(sg), - tsk_cpus_allowed(p)); - goto done; + if (!energy_aware()) { + target = cpumask_first_and(sched_group_cpus(sg), + tsk_cpus_allowed(p)); + goto done; + } next: sg = sg->next; } while (sg != sd->groups); + + if (nrg_cpu >= 0) { + target = nrg_cpu; + goto done; + } } done: return target;