From patchwork Mon Jun 30 16:05:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 32779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 388E5203C0 for ; Mon, 30 Jun 2014 16:08:36 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id v10sf40101428pde.7 for ; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) 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=Bb966FwfiMeg3Ob//j3pgX6T1cSTU70UhUneq+21LYI=; b=Mo6a0MbvF/4uugLkNpf3Vn8h2eQl17OIMpl4zm+HzSnbYm2jW4IgkjuhxK6ly+C8iQ tp7IkxUkvrZLvZADCzGfN5YmjdLb6lGOmXUdpT8lWnXfnwtsg62K2CbmMAeFJb8JVuyG anrJ3Ygl16nwpyBIk8z9ffwe8EZEynlFlnGPREi2fjNafOHudWj81yDfjNj1EuVzWigK odeCOvxQsBCff6oGZiRAgpxOlee0Z2cN/M4SiRJM81YEV/wav5uql8qnQsMRKuKf7Lc8 ZtQL+mhf1tWoho3lHkSHhQ2ICMFo6eOrvDZ9hLBSHB2WPtzwvxqi/N6lqRqFBipvYiUy mhbQ== X-Gm-Message-State: ALoCoQk+hvU0ffY65/MWSDSFiF5gsqB3Qjphq1znuiaoqGqXMQgFOgE+rkBD3S1rk1StlQICIsqa X-Received: by 10.66.122.101 with SMTP id lr5mr22710833pab.19.1404144515553; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.166 with SMTP id d35ls1565830qge.3.gmail; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) X-Received: by 10.221.55.70 with SMTP id vx6mr22285167vcb.23.1404144515375; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id z3si227203vdv.84.2014.06.30.09.08.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 09:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so8327586veb.20 for ; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) X-Received: by 10.58.112.65 with SMTP id io1mr1309353veb.61.1404144515279; Mon, 30 Jun 2014 09:08:35 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp151330vcb; Mon, 30 Jun 2014 09:08:34 -0700 (PDT) X-Received: by 10.66.231.237 with SMTP id tj13mr53007484pac.136.1404144514562; Mon, 30 Jun 2014 09:08:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yl3si23650985pbb.96.2014.06.30.09.08.33; Mon, 30 Jun 2014 09:08:33 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756164AbaF3QIY (ORCPT + 27 others); Mon, 30 Jun 2014 12:08:24 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:40964 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756568AbaF3QHE (ORCPT ); Mon, 30 Jun 2014 12:07:04 -0400 Received: by mail-wi0-f177.google.com with SMTP id r20so6303747wiv.10 for ; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) X-Received: by 10.180.149.175 with SMTP id ub15mr30935715wib.53.1404144422542; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) Received: from lmenx30s.lme.st.com (LPuteaux-656-01-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id lo18sm32896271wic.1.2014.06.30.09.07.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 09:07:01 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, efault@gmx.de, nicolas.pitre@linaro.org, linaro-kernel@lists.linaro.org, daniel.lezcano@linaro.org, dietmar.eggemann@arm.com, Vincent Guittot Subject: [PATCH v3 10/12] sched: get CPU's utilization statistic Date: Mon, 30 Jun 2014 18:05:41 +0200 Message-Id: <1404144343-18720-11-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404144343-18720-1-git-send-email-vincent.guittot@linaro.org> References: <1404144343-18720-1-git-send-email-vincent.guittot@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: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) 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: , Monitor the utilization level of each group of each sched_domain level. The utilization is the amount of cpu_power that is currently used on a CPU or group of CPUs. We use the runnable_avg_sum and _period to evaluate this utilization level. In the special use case where the CPU is fully loaded by more than 1 task, the activity level is set above the cpu_power in order to reflect the overload of the CPU Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bdc5cb9..a6b4b25 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4047,6 +4047,11 @@ static unsigned long capacity_of(int cpu) return cpu_rq(cpu)->cpu_capacity; } +static unsigned long capacity_orig_of(int cpu) +{ + return cpu_rq(cpu)->cpu_capacity_orig; +} + static unsigned long cpu_avg_load_per_task(int cpu) { struct rq *rq = cpu_rq(cpu); @@ -4437,6 +4442,18 @@ done: return target; } +static int get_cpu_utilization(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + u32 sum = rq->avg.runnable_avg_sum; + u32 period = rq->avg.runnable_avg_period; + + if (sum >= period) + return capacity_orig_of(cpu) + 1; + + return (sum * capacity_orig_of(cpu)) / period; +} + /* * select_task_rq_fair: Select target runqueue for the waking task in domains * that have the 'sd_flag' flag set. In practice, this is SD_BALANCE_WAKE, @@ -5517,6 +5534,7 @@ struct sg_lb_stats { unsigned long sum_weighted_load; /* Weighted load of group's tasks */ unsigned long load_per_task; unsigned long group_capacity; + unsigned long group_utilization; /* Total utilization of the group */ unsigned int sum_nr_running; /* Nr tasks running in the group */ unsigned int group_capacity_factor; unsigned int idle_cpus; @@ -5876,6 +5894,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, load = source_load(i, load_idx); sgs->group_load += load; + sgs->group_utilization += get_cpu_utilization(i); sgs->sum_nr_running += rq->cfs.h_nr_running; #ifdef CONFIG_NUMA_BALANCING sgs->nr_numa_running += rq->nr_numa_running; @@ -6043,7 +6062,6 @@ next_group: /* Now, start updating sd_lb_stats */ sds->total_load += sgs->group_load; sds->total_capacity += sgs->group_capacity; - sg = sg->next; } while (sg != env->sd->groups);