From patchwork Mon Jul 25 13:34:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 72719 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1150800qga; Mon, 25 Jul 2016 06:35:32 -0700 (PDT) X-Received: by 10.66.100.202 with SMTP id fa10mr29451172pab.106.1469453732596; Mon, 25 Jul 2016 06:35:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si13171613paj.25.2016.07.25.06.35.32; Mon, 25 Jul 2016 06:35:32 -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 S1752881AbcGYNfS (ORCPT + 29 others); Mon, 25 Jul 2016 09:35:18 -0400 Received: from foss.arm.com ([217.140.101.70]:33696 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752304AbcGYNfD (ORCPT ); Mon, 25 Jul 2016 09:35:03 -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 D07C0B7F; Mon, 25 Jul 2016 06:36:17 -0700 (PDT) Received: from e105550-lin.cambridge.arm.com (e105550-lin.cambridge.arm.com [10.1.211.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 696363F21A; Mon, 25 Jul 2016 06:35:01 -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, sgurrappadi@nvidia.com, freedom.tan@mediatek.com, keita.kobayashi.ym@renesas.com, linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCH v3 03/13] sched/fair: Optimize find_idlest_cpu() when there is no choice Date: Mon, 25 Jul 2016 14:34:20 +0100 Message-Id: <1469453670-2660-4-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469453670-2660-1-git-send-email-morten.rasmussen@arm.com> References: <1469453670-2660-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 Acked-by: Vincent Guittot 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 e7d50acd6028..c1c0aa8b300b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5229,6 +5229,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)) {