From patchwork Thu Apr 25 17:23:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 2489221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 1FEB0DF5B1 for ; Thu, 25 Apr 2013 17:30:16 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVPxO-0001kr-Fo; Thu, 25 Apr 2013 17:27:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVPwN-0006ug-DR; Thu, 25 Apr 2013 17:26:39 +0000 Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVPuw-0006io-B0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2013 17:25:27 +0000 Received: by mail-we0-f177.google.com with SMTP id s47so2025857wey.8 for ; Thu, 25 Apr 2013 10:25:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=xPZRij73XJhUQmfI2iK0B4k2cK+AQVL5VJr2oz4Af2Q=; b=B5r6wOxS2dVpSHmHzh4RJAjLdzMupQGBItMXZiQWfZUx6qxAYaUcQ0fPQ+D/jnq2D2 oigA8ZRNAlpmXsM41UYgYHpLaJ91KOjVKpbbvLNsEQP7e20/oSfHErwX4IG5MyDqHuZE cQvriq2j3tG0YpN9GdI+30hg3EUCHrGqtQPxM6hAVwKufjRYw0d57zmauYGmd5uo+znu 2YX1gIeiRaKKAjRPf/KU1n3ysqynwQaWd5yb3UrasnacnE+XT8VUYUnV7A29aFkXVoGL zNAZ4nX+KwTWYTJ7U9GJA1xruf0xtsDKEJGkinAdsZPykpRdVYKnXBSVB+L0XyXajyOV Iilg== X-Received: by 10.194.90.108 with SMTP id bv12mr59545483wjb.4.1366910707981; Thu, 25 Apr 2013 10:25:07 -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 q13sm12311485wie.8.2013.04.25.10.25.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 10:25:07 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, peterz@infradead.org, mingo@kernel.org, linux@arm.linux.org.uk, pjt@google.com, santosh.shilimkar@ti.com, Morten.Rasmussen@arm.com, chander.kashyap@linaro.org, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com Subject: [PATCH 09/14] sched: evaluate the activity level of the system Date: Thu, 25 Apr 2013 19:23:25 +0200 Message-Id: <1366910611-20048-10-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366910611-20048-1-git-send-email-vincent.guittot@linaro.org> References: <1366910611-20048-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQmii+u+S5lmW4MJUifV/Eh4jrAE+mbRrzQxya+dhBHVMs1Mrdd0t1ASguJlGrVgl2en5oMX X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130425_132510_986897_1FCF13C2 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: len.brown@intel.com, l.majewski@samsung.com, Vincent Guittot , corbet@lwn.net, amit.kucheria@linaro.org, tglx@linutronix.de, paulmck@linux.vnet.ibm.com, arjan@linux.intel.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org We evaluate the activity level of CPUs, groups and domains in order to define how many CPUs are required to handle the current activity. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 954adfd..234ecdd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3465,7 +3465,22 @@ static int check_pack_buddy(int cpu, struct task_struct *p) return true; return false; +} + +static int get_cpu_activity(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + u32 sum = rq->avg.runnable_avg_sum; + u32 period = rq->avg.runnable_avg_period; + + sum = min(sum, period); + + if (sum == period) { + u32 overload = rq->nr_running > 1 ? 1 : 0; + return power_of(cpu) + overload; + } + return (sum * power_of(cpu)) / period; } /* @@ -4355,6 +4370,7 @@ struct sd_lb_stats { struct sched_group *busiest; /* Busiest group in this sd */ struct sched_group *this; /* Local group in this sd */ unsigned long total_load; /* Total load of all groups in sd */ + unsigned long total_activity; /* Total activity of all groups in sd */ unsigned long total_pwr; /* Total power of all groups in sd */ unsigned long avg_load; /* Average load across all groups in sd */ @@ -4383,6 +4399,7 @@ struct sd_lb_stats { struct sg_lb_stats { unsigned long avg_load; /*Avg load across the CPUs of the group */ unsigned long group_load; /* Total load over the CPUs of the group */ + unsigned long group_activity; /* Total activity of the group */ unsigned long sum_nr_running; /* Nr tasks running in the group */ unsigned long sum_weighted_load; /* Weighted load of group's tasks */ unsigned long group_capacity; @@ -4629,6 +4646,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, } sgs->group_load += load; + sgs->group_activity += get_cpu_activity(i); sgs->sum_nr_running += nr_running; sgs->sum_weighted_load += weighted_cpuload(i); if (idle_cpu(i)) @@ -4752,6 +4770,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, return; sds->total_load += sgs.group_load; + sds->total_activity += sgs.group_activity; sds->total_pwr += sg->sgp->power; /*