From patchwork Thu Feb 6 23:10:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 24268 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9FDBC20445 for ; Thu, 6 Feb 2014 23:11:05 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf3879317pab.1 for ; Thu, 06 Feb 2014 15:11:04 -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: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; bh=jcF6CQJBx4KUwvbHB48mbZyE17pe00G6sg4KW7wb++I=; b=aKkZmRVxzlKcdOkjC0XVp7kMb5tdevxlZAcLTuH1ZkNThUnbTQ1Za3bQIIkWcPW1Mm A1aqTIxr6Ca9BRmxd7nGLzJSVQEdcsmG8vKdIysjQe//23w4RzHGKGcmRpGjXoPuw63t PCLaA3WeV3e5ADFqRgSR1eQH6WolvivjT1EdbjvypHZpM/009AnvkOVBQnwW1+1C/zga NmqGJrfxD/wxzl0ktlHDt+k8ZPwxOmHjeiWg9tJ0kOdGnf7nHlRLJdlFp7os12HQBQiL y979rm/hls1jpm/8o7C71NJx8gAZ6VjT3cOcbwZn126gSCa0w2Gnb0ITteqHZRxsWIZ2 LspA== X-Gm-Message-State: ALoCoQlXugG2LxU5yc0fjEwjMBa4hMEz8qk2EFR93CL+tdDwxOHOgtap9eXMjxCSJ9IBA9BXCiGw X-Received: by 10.66.222.105 with SMTP id ql9mr2350546pac.9.1391728264722; Thu, 06 Feb 2014 15:11:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.139 with SMTP id 11ls807524qgn.84.gmail; Thu, 06 Feb 2014 15:11:04 -0800 (PST) X-Received: by 10.220.99.72 with SMTP id t8mr7741236vcn.10.1391728264518; Thu, 06 Feb 2014 15:11:04 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id b2si669363vcy.85.2014.02.06.15.11.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Feb 2014 15:11:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ik5so2018102vcb.37 for ; Thu, 06 Feb 2014 15:11:04 -0800 (PST) X-Received: by 10.53.0.230 with SMTP id bb6mr2093105vdd.39.1391728264421; Thu, 06 Feb 2014 15:11:04 -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.220.174.196 with SMTP id u4csp52574vcz; Thu, 6 Feb 2014 15:11:03 -0800 (PST) X-Received: by 10.67.8.102 with SMTP id dj6mr3667075pad.10.1391728262999; Thu, 06 Feb 2014 15:11:02 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk2si2630146pab.245.2014.02.06.15.11.00; Thu, 06 Feb 2014 15:11:01 -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 S1754791AbaBFXKz (ORCPT + 27 others); Thu, 6 Feb 2014 18:10:55 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:50027 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754747AbaBFXKt (ORCPT ); Thu, 6 Feb 2014 18:10:49 -0500 Received: by mail-wi0-f169.google.com with SMTP id e4so323481wiv.2 for ; Thu, 06 Feb 2014 15:10:48 -0800 (PST) X-Received: by 10.180.37.193 with SMTP id a1mr1400299wik.52.1391728248185; Thu, 06 Feb 2014 15:10:48 -0800 (PST) Received: from mai.arqiva.lan (host-231-197-68-109.arq1.ldn.uk.sharedband.net. [109.68.197.231]) by mx.google.com with ESMTPSA id fm3sm2675334wib.8.2014.02.06.15.10.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Feb 2014 15:10:47 -0800 (PST) From: Daniel Lezcano To: peterz@infradead.org, mingo@kernel.org Cc: alex.shi@linaro.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org Subject: [PATCH V2 3/3] sched: Move idle_stamp up to the core Date: Thu, 6 Feb 2014 23:10:37 +0000 Message-Id: <1391728237-4441-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391728237-4441-1-git-send-email-daniel.lezcano@linaro.org> References: <1391728237-4441-1-git-send-email-daniel.lezcano@linaro.org> 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: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 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: , The idle_balance modifies the idle_stamp field of the rq, making this information to be shared across core.c and fair.c. As we can know if the cpu is going to idle or not with the previous patch, let's encapsulate the idle_stamp information in core.c by moving it up to the caller. The idle_balance function returns true in case a balancing occured and the cpu won't be idle, false if no balance happened and the cpu is going idle. Cc: mingo@kernel.org Cc: alex.shi@linaro.org Cc: peterz@infradead.org Signed-off-by: Daniel Lezcano Signed-off-by: Peter Zijlstra Reviewed-by: Alex Shi --- kernel/sched/core.c | 13 +++++++++++-- kernel/sched/fair.c | 14 ++++++-------- kernel/sched/sched.h | 8 +------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 16b97dd..428ee4c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2704,8 +2704,17 @@ need_resched: pre_schedule(rq, prev); - if (unlikely(!rq->nr_running)) - idle_balance(rq); +#ifdef CONFIG_SMP + if (unlikely(!rq->nr_running)) { + /* + * We must set idle_stamp _before_ calling idle_balance(), such + * that we measure the duration of idle_balance() as idle time. + */ + rq->idle_stamp = rq_clock(rq); + if (idle_balance(rq)) + rq->idle_stamp = 0; + } +#endif put_prev_task(rq, prev); next = pick_next_task(rq); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5ebc681..04fea77 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6531,7 +6531,7 @@ out: * idle_balance is called by schedule() if this_cpu is about to become * idle. Attempts to pull tasks from other CPUs. */ -void idle_balance(struct rq *this_rq) +int idle_balance(struct rq *this_rq) { struct sched_domain *sd; int pulled_task = 0; @@ -6539,10 +6539,8 @@ void idle_balance(struct rq *this_rq) u64 curr_cost = 0; int this_cpu = this_rq->cpu; - this_rq->idle_stamp = rq_clock(this_rq); - if (this_rq->avg_idle < sysctl_sched_migration_cost) - return; + return 0; /* * Drop the rq->lock, but keep IRQ/preempt disabled. @@ -6580,10 +6578,8 @@ void idle_balance(struct rq *this_rq) interval = msecs_to_jiffies(sd->balance_interval); if (time_after(next_balance, sd->last_balance + interval)) next_balance = sd->last_balance + interval; - if (pulled_task) { - this_rq->idle_stamp = 0; + if (pulled_task) break; - } } rcu_read_unlock(); @@ -6594,7 +6590,7 @@ void idle_balance(struct rq *this_rq) * A task could have be enqueued in the meantime */ if (this_rq->nr_running && !pulled_task) - return; + return 1; if (pulled_task || time_after(jiffies, this_rq->next_balance)) { /* @@ -6606,6 +6602,8 @@ void idle_balance(struct rq *this_rq) if (curr_cost > this_rq->max_idle_balance_cost) this_rq->max_idle_balance_cost = curr_cost; + + return pulled_task; } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1436219..c08c070 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1176,17 +1176,11 @@ extern const struct sched_class idle_sched_class; extern void update_group_power(struct sched_domain *sd, int cpu); extern void trigger_load_balance(struct rq *rq); -extern void idle_balance(struct rq *this_rq); +extern int idle_balance(struct rq *this_rq); extern void idle_enter_fair(struct rq *this_rq); extern void idle_exit_fair(struct rq *this_rq); -#else /* CONFIG_SMP */ - -static inline void idle_balance(struct rq *rq) -{ -} - #endif extern void sysrq_sched_debug_show(void);