From patchwork Wed Jun 22 17:03:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 70669 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp14987qgy; Wed, 22 Jun 2016 10:03:30 -0700 (PDT) X-Received: by 10.66.249.161 with SMTP id yv1mr35230380pac.39.1466615008324; Wed, 22 Jun 2016 10:03:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vy4si841055pab.231.2016.06.22.10.03.28; Wed, 22 Jun 2016 10:03:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174AbcFVRCm (ORCPT + 30 others); Wed, 22 Jun 2016 13:02:42 -0400 Received: from foss.arm.com ([217.140.101.70]:49296 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753143AbcFVRCj (ORCPT ); Wed, 22 Jun 2016 13:02:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 847FB9C2; Wed, 22 Jun 2016 10:03:21 -0700 (PDT) Received: from e105550-lin.cambridge.arm.com (e105550-lin.cambridge.arm.com [10.1.207.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 068203F246; Wed, 22 Jun 2016 10:02:32 -0700 (PDT) From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: dietmar.eggemann@arm.com, yuyang.du@intel.com, vincent.guittot@linaro.org, mgalbraith@suse.de, linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCH v2 03/13] sched/fair: Optimize find_idlest_cpu() when there is no choice Date: Wed, 22 Jun 2016 18:03:14 +0100 Message-Id: <1466615004-3503-4-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466615004-3503-1-git-send-email-morten.rasmussen@arm.com> References: <1466615004-3503-1-git-send-email-morten.rasmussen@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the current find_idlest_group()/find_idlest_cpu() search we end up calling find_idlest_cpu() in a sched_group containing only one cpu in the end. Checking idle-states becomes pointless when there is no alternative, so bail out instead. cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 4 ++++ 1 file changed, 4 insertions(+) -- 1.9.1 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index eec8e29104f9..216db302e87d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5123,6 +5123,10 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu) int shallowest_idle_cpu = -1; int i; + /* Check if we have any choice */ + if (group->group_weight == 1) + return cpumask_first(sched_group_cpus(group)); + /* Traverse only the allowed CPUs */ for_each_cpu_and(i, sched_group_cpus(group), tsk_cpus_allowed(p)) { if (idle_cpu(i)) {