From patchwork Tue Sep 23 16:08:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 37744 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E35B120792 for ; Tue, 23 Sep 2014 16:10:59 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf2201605eek.0 for ; Tue, 23 Sep 2014 09:10:59 -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=0KdTUys3Xt4Jqu/B98J17Zx5tbwsg3xVJ50ZexMkQtU=; b=FmlZcLgs07N+2Ox/8ECgWbGlNtWDX8ycVm/OWmI+ZEA0G2MtcZ0RH9sU+whTuTT3s/ yAnXnehzhSRZIwNSjZtzbE82DZ566IxYPdlEz2/TzhBl/yOxBcWFAwB2SZIwLIPkhaS/ dBD61VB3kC5URfOreHpcA5IaPSLmTEPIQrLWe8S3aRkwo9l3H6ZzAnDwgU0me+wrrOID pG/9kuG1QDEY5VHZAq1LOXqMwmgNtIYfoh+ibxhywkRpx6DuQi7+C7W56E6DP48XiZd1 eold2aZ59cDjGhyiosHDQG2lghpfkSjuLCgG7WKc26ZzVkF7JTT65q8rly5CkSWVwHe+ YqXw== X-Gm-Message-State: ALoCoQl37XnX7UDiodWN5ElSgPkifqxE0tCGh55i5npqpLFg7TWwwU9hZuyDOrWl0aY9AbvSsncm X-Received: by 10.194.205.34 with SMTP id ld2mr115238wjc.5.1411488659108; Tue, 23 Sep 2014 09:10:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.171 with SMTP id p11ls57138lal.68.gmail; Tue, 23 Sep 2014 09:10:58 -0700 (PDT) X-Received: by 10.112.135.230 with SMTP id pv6mr366079lbb.105.1411488658838; Tue, 23 Sep 2014 09:10:58 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by mx.google.com with ESMTPS id o17si19361817laa.10.2014.09.23.09.10.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 09:10:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id b12so9079244lbj.14 for ; Tue, 23 Sep 2014 09:10:51 -0700 (PDT) X-Received: by 10.152.179.226 with SMTP id dj2mr699560lac.40.1411488651900; Tue, 23 Sep 2014 09:10:51 -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.112.130.169 with SMTP id of9csp442234lbb; Tue, 23 Sep 2014 09:10:51 -0700 (PDT) X-Received: by 10.70.35.15 with SMTP id d15mr1301397pdj.48.1411488650443; Tue, 23 Sep 2014 09:10:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si21661858pdb.94.2014.09.23.09.10.49 for ; Tue, 23 Sep 2014 09:10:50 -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 S1756359AbaIWQKr (ORCPT + 27 others); Tue, 23 Sep 2014 12:10:47 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:57300 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756482AbaIWQJh (ORCPT ); Tue, 23 Sep 2014 12:09:37 -0400 Received: by mail-we0-f180.google.com with SMTP id u56so4847043wes.25 for ; Tue, 23 Sep 2014 09:09:35 -0700 (PDT) X-Received: by 10.180.108.143 with SMTP id hk15mr23682854wib.27.1411488575778; Tue, 23 Sep 2014 09:09:35 -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 hm5sm16427901wjb.2.2014.09.23.09.09.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 09:09:34 -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, pjt@google.com, bsegall@google.com, Vincent Guittot Subject: [PATCH v6 4/6] sched: get CPU's usage statistic Date: Tue, 23 Sep 2014 18:08:03 +0200 Message-Id: <1411488485-10025-5-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411488485-10025-1-git-send-email-vincent.guittot@linaro.org> References: <1411488485-10025-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.217.169 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 usage level of each group of each sched_domain level. The usage is the amount of cpu_capacity that is currently used on a CPU or group of CPUs. We use the utilization_load_avg to evaluate the usage level of each group. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2cf153d..4097e3f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4523,6 +4523,17 @@ static int select_idle_sibling(struct task_struct *p, int target) return target; } +static int get_cpu_usage(int cpu) +{ + unsigned long usage = cpu_rq(cpu)->cfs.utilization_load_avg; + unsigned long capacity = capacity_orig_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, @@ -5663,6 +5674,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_usage; /* Total usage of the group */ unsigned int sum_nr_running; /* Nr tasks running in the group */ unsigned int group_capacity_factor; unsigned int idle_cpus; @@ -6037,6 +6049,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, load = source_load(i, load_idx); sgs->group_load += load; + sgs->group_usage += get_cpu_usage(i); sgs->sum_nr_running += rq->cfs.h_nr_running; if (rq->nr_running > 1)