From patchwork Fri Oct 18 11:52:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 21126 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 9F90C246F1 for ; Fri, 18 Oct 2013 11:54:04 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wm4sf9151466obc.4 for ; Fri, 18 Oct 2013 04:54:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=u/3kNOtqcmaza5XwKDfK3K1bvPjBqrbO0SbZ6nB8vys=; b=e7/vQL7EWmy5V6ULXT9MCIT4hK6gRI88MQfYCvpCuMQIXaPz1KX6hB1CKGFf58gqJM hQVi+gfeG5KfODKGmCk1XDv1g9gN8NtSPtxoAObmwx/HxIpgAHlmv0SzdrIAjrsTwjcK vPiTeuk17etx1OSOsH3kcYB8zDBiJC4vD0J72zYlqiVCI+EWOVag4fPB2x2CJaw8klJw 2cx1UHaw3dHMw16DSOoVPpbSL2dq/sxaP+169WQ+QfBvLzNBX58j+E87nNDfKqGsleId vaVSrDd0R6X2cKrhQ7HyFA4wPnnTxQmi+wTMg+6b+zLF/RxjLyBTSRMGQOFwnvks1hQS hebg== X-Received: by 10.182.186.73 with SMTP id fi9mr519915obc.48.1382097244266; Fri, 18 Oct 2013 04:54:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.196 with SMTP id m4ls1292716qem.27.gmail; Fri, 18 Oct 2013 04:54:04 -0700 (PDT) X-Received: by 10.220.142.140 with SMTP id q12mr189985vcu.21.1382097244116; Fri, 18 Oct 2013 04:54:04 -0700 (PDT) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id bb4si239761vcb.0.2013.10.18.04.54.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:54:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id w8so1110843vbj.14 for ; Fri, 18 Oct 2013 04:54:04 -0700 (PDT) X-Gm-Message-State: ALoCoQkbsjELBj/8/9RV5i+WX8RrQ2Gxu7Yu8Y8P7PvCCLjH0hm6ZiUPAGhhKzBvxwsYfS8nQ8si X-Received: by 10.220.58.1 with SMTP id e1mr1765822vch.0.1382097243996; Fri, 18 Oct 2013 04:54:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp29497vcz; Fri, 18 Oct 2013 04:54:03 -0700 (PDT) X-Received: by 10.180.208.49 with SMTP id mb17mr2593034wic.64.1382097242972; Fri, 18 Oct 2013 04:54:02 -0700 (PDT) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx.google.com with ESMTPS id lq4si409481wjb.143.2013.10.18.04.54.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:54:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.177 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=209.85.212.177; Received: by mail-wi0-f177.google.com with SMTP id h11so850393wiv.10 for ; Fri, 18 Oct 2013 04:54:02 -0700 (PDT) X-Received: by 10.195.13.45 with SMTP id ev13mr2234843wjd.20.1382097242542; Fri, 18 Oct 2013 04:54:02 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id lr3sm25000673wic.5.2013.10.18.04.54.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:54:02 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, pjt@google.com, Morten.Rasmussen@arm.com, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com, linaro-kernel@lists.linaro.org Cc: rjw@sisk.pl, paulmck@linux.vnet.ibm.com, corbet@lwn.net, tglx@linutronix.de, len.brown@intel.com, arjan@linux.intel.com, amit.kucheria@linaro.org, l.majewski@samsung.com, Vincent Guittot Subject: [RFC][PATCH v5 13/14] sched: differantiate idle cpu Date: Fri, 18 Oct 2013 13:52:26 +0200 Message-Id: <1382097147-30088-13-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> References: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The cost for waking up of a core varies according to its current idle state. This includes C-state and intermediate state when some sync between cores is required to reach a deep C-state. Waking up a CPU in a deep C-state for running a short task is not efficient from both a power and a performance point of view. We should take into account the wake up latency of an idle CPU when the scheduler looks for the best CPU to use for a waking task. The wake up latency of a CPU is computed into a load that can be directly compared with task load and other CPUs load. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ad8b99a..4863dad 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -394,6 +394,20 @@ static int check_nohz_packing(int cpu) return false; } + +int sched_get_idle_load(int cpu) +{ + struct sched_pm *stat = &per_cpu(sched_stat, cpu); + int latency = atomic_read(&(stat->wake_latency)); + /* + * Transform the current wakeup latency (us) into an idle load that + * will be compared to task load to decide if it's worth to wake up + * the cpu. The current formula is quite simple but give good + * approximation in the range [0:10ms] + */ + return (latency * 21) >> 10; +} + #else /* CONFIG_SCHED_PACKING_TASKS */ static inline bool is_packing_cpu(int cpu) @@ -416,6 +430,10 @@ static inline int check_nohz_packing(int cpu) return false; } +static inline int sched_get_idle_load(int cpu) +{ + return 0; +} #endif /* CONFIG_SCHED_PACKING_TASKS */ #endif /* CONFIG_SMP */ @@ -3207,6 +3225,8 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) /* Used instead of source_load when we know the type == 0 */ static unsigned long weighted_cpuload(const int cpu) { + if (idle_cpu(cpu)) + return sched_get_idle_load(cpu); return cpu_rq(cpu)->cfs.runnable_load_avg; } @@ -3655,6 +3675,8 @@ static int select_idle_sibling(struct task_struct *p, int target) if (i == target || !idle_cpu(i) || !is_packing_cpu(i)) goto next; + if (weighted_cpuload(i) > p->se.avg.load_avg_contrib) + goto next; } target = cpumask_first_and(sched_group_cpus(sg),