From patchwork Fri Jan 17 09:04:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 23306 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0D7A20540 for ; Fri, 17 Jan 2014 09:05:16 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf12342496oag.4 for ; Fri, 17 Jan 2014 01:05:16 -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=2GiBAkC0eO3rIp5OWGEIUPMgxfGQDE7HFx4t4QP9G6o=; b=MO61JVzcj4fBe7QqLHbZvB8ndEYHXSk38fDc+UXEaXRTGKToykyPre2LfjDc+b4esS MotHSUevfpW1MuqsQJoJTFKM9qItILNS+MwKX3tf50WOgY5haaB2QZfHBnQByZJUe1It 4wP3o5daF4afWqDs0+kBFa4awow7REg2rlpGdtwJqym3hoxfDDY8UYJ3ZwDGIdOltqwz QO+w9E2collGiyMVjGj+WEU1Pfei1iLn2QqF5yq9Oac3pLtPCNU65a+yCVL/GGNF6aIB emnmGJiY8hqUUhdSjoaudOXViEklMl+7MK1z+Mk2rV2BHarNAwnlDnIVVQTKwfJE2nNf +Yaw== X-Gm-Message-State: ALoCoQkBFhSRwqUOAwfscg0X0X2GnlPBBzjGMR8RF6GW/ubOBNxQhIXqmukijgSEhBGepZYNYwZq X-Received: by 10.182.108.136 with SMTP id hk8mr272321obb.11.1389949516001; Fri, 17 Jan 2014 01:05:16 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.35 with SMTP id c3ls1113740qed.83.gmail; Fri, 17 Jan 2014 01:05:15 -0800 (PST) X-Received: by 10.220.110.210 with SMTP id o18mr22819vcp.49.1389949515391; Fri, 17 Jan 2014 01:05:15 -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 gv8si4611649veb.44.2014.01.17.01.05.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 01:05:15 -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 ik5so1472272vcb.9 for ; Fri, 17 Jan 2014 01:05:15 -0800 (PST) X-Received: by 10.53.11.69 with SMTP id eg5mr293990vdd.54.1389949515284; Fri, 17 Jan 2014 01:05:15 -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 ey3csp4884ved; Fri, 17 Jan 2014 01:05:14 -0800 (PST) X-Received: by 10.68.195.4 with SMTP id ia4mr859799pbc.142.1389949512750; Fri, 17 Jan 2014 01:05:12 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tr4si9549823pab.237.2014.01.17.01.05.12; Fri, 17 Jan 2014 01:05:12 -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 S1752300AbaAQJFG (ORCPT + 26 others); Fri, 17 Jan 2014 04:05:06 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:64990 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751491AbaAQJEK (ORCPT ); Fri, 17 Jan 2014 04:04:10 -0500 Received: by mail-wi0-f170.google.com with SMTP id ex4so1744469wid.3 for ; Fri, 17 Jan 2014 01:04:08 -0800 (PST) X-Received: by 10.194.187.101 with SMTP id fr5mr747484wjc.76.1389949448679; Fri, 17 Jan 2014 01:04:08 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-359-206.w90-60.abo.wanadoo.fr. [90.60.118.206]) by mx.google.com with ESMTPSA id ju6sm8671745wjc.1.2014.01.17.01.04.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 01:04:08 -0800 (PST) From: Daniel Lezcano To: peterz@infradead.org, mingo@kernel.org Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, alex.shi@linaro.org Subject: [PATCH 3/4] sched: Move idle_stamp up to the core Date: Fri, 17 Jan 2014 10:04:03 +0100 Message-Id: <1389949444-14821-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389949444-14821-1-git-send-email-daniel.lezcano@linaro.org> References: <1389949444-14821-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. Signed-off-by: Daniel Lezcano --- kernel/sched/core.c | 2 +- kernel/sched/fair.c | 14 ++++++-------- kernel/sched/sched.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cf51601..b7e3635 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2680,7 +2680,7 @@ need_resched: 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); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 502c51c..49dfedb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6359,7 +6359,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; @@ -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; } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b0be4c6..970dd44 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1176,7 +1176,7 @@ 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);