From patchwork Fri May 23 15:53:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 30828 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6330120369 for ; Fri, 23 May 2014 15:55:54 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf18903448pab.3 for ; Fri, 23 May 2014 08:55:52 -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=Mry/DdIhT5BSi5SmoxaFktN9mZnbLi5t8UwvMIW5Rlk=; b=jhaHZ60JasF3HD8rXQ6p1K5XrZbZymWWBloMVWaViQN0Ag3NeshI0ipPelE9pon16Z dnO2iBO60SbN1N+WS7PPIE1wE3s1hEiYUWy1iaBZkIj8w3q6OXpZuVTrfYBwjq//jCPQ pegIE3CmVLa0vT4OQL5GmhDjeFX/6HdAfhGW+Th7zrkmixMB9YGQA1lKgIaTyiJBxw/G xyspadCJhSbFx8Javlpqx/hwZvgDahyh2ZQXqxdBYEl2RZTegi8INHG3NdIjLK+huTSO oQMzBLAw8o7g122+aQvoA38hcj4KHq0V5ApNXqpX+V2abh62cvLIIYOx8vAemE9sinfs 7hrQ== X-Gm-Message-State: ALoCoQk06dt3YaMRHFHM9MeLR+0BN8QSIucBS977KV4frGolVCjQF4SZsTa22Ueb0PkoazrCWGl/ X-Received: by 10.66.121.226 with SMTP id ln2mr2592845pab.24.1400860552791; Fri, 23 May 2014 08:55:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.234 with SMTP id a97ls1761454qgf.51.gmail; Fri, 23 May 2014 08:55:52 -0700 (PDT) X-Received: by 10.220.163.201 with SMTP id b9mr711589vcy.79.1400860552670; Fri, 23 May 2014 08:55:52 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id bw9si1866729vdd.78.2014.05.23.08.55.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 08:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so6412048vcb.4 for ; Fri, 23 May 2014 08:55:52 -0700 (PDT) X-Received: by 10.58.185.165 with SMTP id fd5mr1968487vec.41.1400860552590; Fri, 23 May 2014 08:55:52 -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.220.221.72 with SMTP id ib8csp42827vcb; Fri, 23 May 2014 08:55:52 -0700 (PDT) X-Received: by 10.68.237.67 with SMTP id va3mr7163640pbc.19.1400860551840; Fri, 23 May 2014 08:55:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tx10si4509186pac.112.2014.05.23.08.55.51 for ; Fri, 23 May 2014 08:55:51 -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 S1753140AbaEWPzo (ORCPT + 27 others); Fri, 23 May 2014 11:55:44 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:43385 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753142AbaEWPyU (ORCPT ); Fri, 23 May 2014 11:54:20 -0400 Received: by mail-wg0-f42.google.com with SMTP id y10so4914663wgg.1 for ; Fri, 23 May 2014 08:54:19 -0700 (PDT) X-Received: by 10.194.250.68 with SMTP id za4mr2806711wjc.89.1400860459591; Fri, 23 May 2014 08:54:19 -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 m1sm3558594wib.20.2014.05.23.08.54.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 08:54:18 -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, Vincent Guittot Subject: [PATCH v2 08/11] sched: get CPU's activity statistic Date: Fri, 23 May 2014 17:53:02 +0200 Message-Id: <1400860385-14555-9-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400860385-14555-1-git-send-email-vincent.guittot@linaro.org> References: <1400860385-14555-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.173 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 activity level of each group of each sched_domain level. The activity 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 activity 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b7c51be..c01d8b6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4044,6 +4044,11 @@ static unsigned long power_of(int cpu) return cpu_rq(cpu)->cpu_power; } +static unsigned long power_orig_of(int cpu) +{ + return cpu_rq(cpu)->cpu_power_orig; +} + static unsigned long cpu_avg_load_per_task(int cpu) { struct rq *rq = cpu_rq(cpu); @@ -4438,6 +4443,18 @@ done: return target; } +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; + + if (sum >= period) + return power_orig_of(cpu) + rq->nr_running - 1; + + return (sum * power_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, @@ -5518,6 +5535,7 @@ struct sg_lb_stats { unsigned long sum_weighted_load; /* Weighted load of group's tasks */ unsigned long load_per_task; unsigned long group_power; + unsigned long group_activity; /* Total activity of the group */ unsigned int sum_nr_running; /* Nr tasks running in the group */ unsigned int group_capacity; unsigned int idle_cpus; @@ -5538,6 +5556,7 @@ struct sd_lb_stats { struct sched_group *busiest; /* Busiest group in this sd */ struct sched_group *local; /* 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 */ @@ -5557,6 +5576,7 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds) .busiest = NULL, .local = NULL, .total_load = 0UL, + .total_activity = 0UL, .total_pwr = 0UL, .busiest_stat = { .avg_load = 0UL, @@ -5876,6 +5896,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, load = source_load(i, load_idx); sgs->group_load += load; + sgs->group_activity += get_cpu_activity(i); sgs->sum_nr_running += rq->cfs.h_nr_running; #ifdef CONFIG_NUMA_BALANCING sgs->nr_numa_running += rq->nr_numa_running; @@ -6034,6 +6055,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd next_group: /* Now, start updating sd_lb_stats */ sds->total_load += sgs->group_load; + sds->total_activity += sgs->group_activity; sds->total_pwr += sgs->group_power; sg = sg->next;