From patchwork Mon Jul 28 17:51:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 34403 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB759202E4 for ; Mon, 28 Jul 2014 18:01:56 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id ty20sf5045719lab.7 for ; Mon, 28 Jul 2014 11:01:54 -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=eqfvQdo+kSlqmGfsoRGKvrxD4YJP3bJXFyf2I56wnWY=; b=C1uUcCjagnKBFd3n+OG7C/mTN5NtB5nj0RUYB9VFY6go7ICICqQeX/q710b87KY3mg nGPhEU3UvCQomsRV30ctrXNYBfXewH6VNwKx+JFYwd1oU+tWGf4ZnQnWCS9eVBo2FFvr uLROvxlbfKNmvb/Xyhs8925UBoenBK66lOuYtPYmNoBWLq7h5IHMQ+hg9xz2PtqvMPXC eJ8fYENTUDL5kaRqmZxspdjKlhproF9KgOG2SnSBAuYaeG7HuBGeCgPwe7fGGD0yk9iq 32V1gPAxGX2kFj6MEnKT5Lbj3PJoCENxlVvolI79zqBRGn+jSl7Yhx46RQwCexA7rbH0 ++9A== X-Gm-Message-State: ALoCoQkGnhljvaJp+ySEMQG/hil1lXOD0fKYxZfVJwLCfnL2Af52d23KPuE7AW5CpTAZM+6X33po X-Received: by 10.112.128.193 with SMTP id nq1mr3612234lbb.0.1406570514115; Mon, 28 Jul 2014 11:01:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.76 with SMTP id 70ls1977284qgu.92.gmail; Mon, 28 Jul 2014 11:01:53 -0700 (PDT) X-Received: by 10.220.252.198 with SMTP id mx6mr2616680vcb.15.1406570513865; Mon, 28 Jul 2014 11:01:53 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ad18si12996446vec.43.2014.07.28.11.01.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Jul 2014 11:01:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so11651152vcb.23 for ; Mon, 28 Jul 2014 11:01:53 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr3614718vdb.86.1406570513779; Mon, 28 Jul 2014 11:01:53 -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 tc5csp186414vcb; Mon, 28 Jul 2014 11:01:53 -0700 (PDT) X-Received: by 10.68.253.73 with SMTP id zy9mr1861462pbc.114.1406570058673; Mon, 28 Jul 2014 10:54:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qc2si9288155pdb.307.2014.07.28.10.54.15 for ; Mon, 28 Jul 2014 10:54:18 -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 S1751982AbaG1RyE (ORCPT + 26 others); Mon, 28 Jul 2014 13:54:04 -0400 Received: from mail-we0-f182.google.com ([74.125.82.182]:46225 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751684AbaG1Rw4 (ORCPT ); Mon, 28 Jul 2014 13:52:56 -0400 Received: by mail-we0-f182.google.com with SMTP id k48so7860142wev.27 for ; Mon, 28 Jul 2014 10:52:55 -0700 (PDT) X-Received: by 10.194.222.230 with SMTP id qp6mr51806325wjc.23.1406569975089; Mon, 28 Jul 2014 10:52:55 -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 ex4sm33758149wic.2.2014.07.28.10.52.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Jul 2014 10:52:54 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: riel@redhat.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 v4 10/12] sched: get CPU's utilization statistic Date: Mon, 28 Jul 2014 19:51:44 +0200 Message-Id: <1406569906-9763-11-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406569906-9763-1-git-send-email-vincent.guittot@linaro.org> References: <1406569906-9763-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.220.178 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_capacity that is currently used on a CPU or group of CPUs. We use the usage_load_avg 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_capacity in order to reflect the overload of the CPU Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8bd57df..8524760 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4129,6 +4129,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); @@ -4517,6 +4522,17 @@ static int select_idle_sibling(struct task_struct *p, int target) return target; } +static int get_cpu_utilization(int cpu) +{ + unsigned long usage = cpu_rq(cpu)->cfs.usage_load_avg; + unsigned long capacity = capacity_of(cpu); + + if (usage >= SCHED_LOAD_SCALE) + return capacity + 1; + + return (usage * capacity) >> SCHED_LOAD_SHIFT; +} + /* * 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, @@ -5596,6 +5612,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; @@ -5935,6 +5952,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; if (rq->nr_running > 1) @@ -6108,7 +6126,6 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd /* 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);