From patchwork Tue Jan 21 11:17:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 23433 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B2E4203BE for ; Tue, 21 Jan 2014 11:31:02 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id jt11sf15229550pbb.2 for ; Tue, 21 Jan 2014 03:31:01 -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:message-id:user-agent :date:from:to:cc:subject:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe :content-disposition; bh=U39gh9f0Q2IjorCZQC8iQJAMOZ+a4fZB88ClSR7OTjY=; b=YQjOha5DHjCgK0i6X0iFnTYuZbMRWfRkIoxtHiATrPoVMyvFUICZePyfqzAQn4duY3 enKVWbzw1sJPi5uiudZ+u0S1/sw1SN9OKyDwpAIgA9JrOTeBzdu/qoRLlCpjChnxZ2zB BGQi76uKe4JGIohrMn8ZlWg+PiJ+O+x9hJXtQROqDBt/SH8M0dKiRqWX9z9B+7O4PS33 cFXWZ1l1BidtfVOuRfw7XP8mtSKXAKha41UliYCUF1y5WNBJB4gPo5O25uXnqOfdSMfO m3w+gzibxGBx9GE11WmkprDIfGwsPeW1wjLZgbfEo3/LfELu/JRSqsx8LersWnUKH3qK CWyQ== X-Gm-Message-State: ALoCoQl6zhbFWx2/N7MU9DcXRqKWmuQ55gLg25x7LcfnIvRg2PXHqyFzvClzXD0F69RONlCe+Ril X-Received: by 10.67.14.70 with SMTP id fe6mr8289621pad.15.1390303861767; Tue, 21 Jan 2014 03:31:01 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.102 with SMTP id a93ls1237665qga.33.gmail; Tue, 21 Jan 2014 03:31:01 -0800 (PST) X-Received: by 10.221.20.199 with SMTP id qp7mr3504724vcb.24.1390303861529; Tue, 21 Jan 2014 03:31:01 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id u8si1843526vcz.76.2014.01.21.03.31.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Jan 2014 03:31:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so2367445veb.35 for ; Tue, 21 Jan 2014 03:31:01 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr14113504vco.18.1390303861455; Tue, 21 Jan 2014 03:31:01 -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 u4csp111118vcz; Tue, 21 Jan 2014 03:31:00 -0800 (PST) X-Received: by 10.69.8.225 with SMTP id dn1mr24434032pbd.54.1390303853491; Tue, 21 Jan 2014 03:30:53 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qx4si5064632pbc.165.2014.01.21.03.30.52; Tue, 21 Jan 2014 03:30:52 -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 S932076AbaAULaH (ORCPT + 27 others); Tue, 21 Jan 2014 06:30:07 -0500 Received: from merlin.infradead.org ([205.233.59.134]:51869 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754099AbaAUL3Y (ORCPT ); Tue, 21 Jan 2014 06:29:24 -0500 Received: from dhcp-077-248-225-117.chello.nl ([77.248.225.117] helo=twins) by merlin.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5ZWC-0002WT-9B; Tue, 21 Jan 2014 11:29:20 +0000 Received: by twins (Postfix, from userid 0) id E0F8F821E87E; Tue, 21 Jan 2014 12:29:03 +0100 (CET) Message-Id: <20140121112258.410353740@infradead.org> User-Agent: quilt/0.60-1 Date: Tue, 21 Jan 2014 12:17:57 +0100 From: Peter Zijlstra To: linux-kernel@vger.kernel.org Cc: mingo@kernel.org, daniel.lezcano@linaro.org, pjt@google.com, bsegall@google.com, Peter Zijlstra Subject: [PATCH 3/9] sched: Move idle_stamp up to the core References: <20140121111754.580142558@infradead.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: peterz@infradead.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 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: , Content-Disposition: inline; filename=daniel_lezcano-3_sched-move_idle_stamp_up_to_the_core.patch From: Daniel Lezcano 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: alex.shi@linaro.org Cc: peterz@infradead.org Cc: mingo@kernel.org Signed-off-by: Daniel Lezcano Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1389949444-14821-3-git-send-email-daniel.lezcano@linaro.org --- kernel/sched/core.c | 2 +- kernel/sched/fair.c | 14 ++++++-------- kernel/sched/sched.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2680,7 +2680,7 @@ static void __sched __schedule(void) pre_schedule(rq, prev); if (unlikely(!rq->nr_running)) - idle_balance(rq); + rq->idle_stamp = idle_balance(rq) ? 0 : rq_clock(rq); put_prev_task(rq, prev); next = pick_next_task(rq); --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6359,7 +6359,7 @@ static int load_balance(int this_cpu, st * 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; @@ -6367,10 +6367,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. @@ -6408,10 +6406,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(); @@ -6422,7 +6418,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)) { /* @@ -6434,6 +6430,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; } /* --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1176,7 +1176,7 @@ extern const struct sched_class idle_sch 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);