From patchwork Wed Jan 15 04:07:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 23204 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E2C82066C for ; Wed, 15 Jan 2014 04:08:30 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id va2sf1837685obc.4 for ; Tue, 14 Jan 2014 20:08:29 -0800 (PST) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=kE5u880Sb1WzYW+D+3CX1XmFy2hTS2wV7Lx2XPc8DkE=; b=dkEO4CtNFDempmDMCCqv4g0FHqZzMrEPs7o+WayrcG5VBZCa0I+WuvMrNPpZuKBXsu ydx5PgGd5OMqPAlaQfiLjfUjtQCLdF65l3BNMbGxIGNGljI1ZNpZUEXSdUdIUvrav7n2 fUUtAPeQj8lOul32iBZB9B6YCPNhviggi8uNGAvnTORocoxn4fvJwqaUCk6ahLd2BTV4 K2Z6H0E0ZnpS0e2tMrbiJqF7TqpW6mEH6/1aCZukY9D7wonjbdtk2iPH6q+6dFttKAkq f0QnpdoLsGg3M3qWfKYgSuMfLd8vaA+XgJ7MnFWU6mWb8ikkz/ZI+/hxNYdhkfXb83Qx XMCA== X-Gm-Message-State: ALoCoQmnRDFNWh4Q9z9onAd5icrRu6tVYOqyxakjylQBfe2FaNHEMQVQQVGYsDcryiJ+apsJhuBB X-Received: by 10.182.241.129 with SMTP id wi1mr360obc.10.1389758909580; Tue, 14 Jan 2014 20:08:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.72.66 with SMTP id b2ls447066qev.36.gmail; Tue, 14 Jan 2014 20:08:28 -0800 (PST) X-Received: by 10.220.162.196 with SMTP id w4mr9292vcx.58.1389758908833; Tue, 14 Jan 2014 20:08:28 -0800 (PST) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id yt16si1038166vcb.117.2014.01.14.20.08.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 20:08:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id cz12so210615veb.12 for ; Tue, 14 Jan 2014 20:08:28 -0800 (PST) X-Received: by 10.52.241.103 with SMTP id wh7mr7709vdc.85.1389758908727; Tue, 14 Jan 2014 20:08:28 -0800 (PST) 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.59.13.131 with SMTP id ey3csp246831ved; Tue, 14 Jan 2014 20:08:28 -0800 (PST) X-Received: by 10.68.130.169 with SMTP id of9mr5909765pbb.79.1389758907756; Tue, 14 Jan 2014 20:08:27 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si2414778pbj.218.2014.01.14.20.08.27; Tue, 14 Jan 2014 20:08:27 -0800 (PST) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751694AbaAOEIV (ORCPT + 26 others); Tue, 14 Jan 2014 23:08:21 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:45758 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbaAOEIT (ORCPT ); Tue, 14 Jan 2014 23:08:19 -0500 Received: by mail-pa0-f43.google.com with SMTP id rd3so579919pab.30 for ; Tue, 14 Jan 2014 20:08:19 -0800 (PST) X-Received: by 10.66.144.227 with SMTP id sp3mr6067470pab.100.1389758899202; Tue, 14 Jan 2014 20:08:19 -0800 (PST) Received: from alex-shi.Home ([162.243.130.63]) by mx.google.com with ESMTPSA id gv10sm4799679pbd.0.2014.01.14.20.08.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 20:08:18 -0800 (PST) From: Alex Shi To: mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, fengguang.wu@intel.com, linaro-kernel@lists.linaro.org, Alex Shi Subject: [RFC PATCH] sched: find the latest idle cpu Date: Wed, 15 Jan 2014 12:07:59 +0800 Message-Id: <1389758879-19951-1-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.8.1.2 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: alex.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Currently we just try to find least load cpu. If some cpus idled, we just pick the first cpu in cpu mask. In fact we can get the interrupted idle cpu or the latest idled cpu, then we may get the benefit from both latency and power. The selected cpu maybe not the best, since other cpu may be interrupted during our selecting. But be captious costs too much. Signed-off-by: Alex Shi --- kernel/sched/fair.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c7395d9..fb52d26 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4167,6 +4167,26 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu) min_load = load; idlest = i; } +#ifdef CONFIG_NO_HZ_COMMON + /* + * Coarsely to get the latest idle cpu for shorter latency and + * possible power benefit. + */ + if (!min_load) { + struct tick_sched *ts = &per_cpu(tick_cpu_sched, i); + + s64 latest_wake = 0; + /* idle cpu doing irq */ + if (ts->inidle && !ts->idle_active) + idlest = i; + /* the cpu resched */ + else if (!ts->inidle) + idlest = i; + /* find latest idle cpu */ + else if (ktime_to_us(ts->idle_entrytime) > latest_wake) + idlest = i; + } +#endif } return idlest;