From patchwork Fri Oct 18 11:52:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 21120 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03518246F1 for ; Fri, 18 Oct 2013 11:53:54 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kq14sf6208803pab.4 for ; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=PC6S5e/5Dj7eKQ30wvCeDdF/QYVKJXNE4NwwQz+BX6c=; b=JPrWLxMJigsion++o6OPdcbgj40KV+1GPseqdA1UJln6Q5sEHm5KoTlWL9nd94fVWQ HMH44NUEDBtwbpdQMmjXtiHCdnnI0znZ3Psne+uw8v7mbY9dB8E6Nxiz6ZXFkNMshWDT rX957pzUJiTBRSldR3V83M4T6HbjPFc0j+dWMLPgt5LzYINO/FzauXfY6wlAPceQnW10 ZxL9p/WefirvA3FaL7jbvBWcd35F+O1V7HMG57r3CwNJElO9w2VXQAtI6GiaQ6LNIhYG eECTDiS4N5AY9PdntRJLZtDLIoOkQ+CLJnaO8SfBywFTBdW49kQ2aH4yTTpmu1GHSZKK HX2g== X-Received: by 10.66.188.37 with SMTP id fx5mr1211121pac.45.1382097234264; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.40 with SMTP id z8ls1221149qef.81.gmail; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) X-Received: by 10.52.227.6 with SMTP id rw6mr1456250vdc.19.1382097234099; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id sv5si238450veb.13.2013.10.18.04.53.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id w8so1140736vbj.0 for ; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) X-Gm-Message-State: ALoCoQlLJ+v9GRiRfcBEl2Ompe3upIPMl5F+tsBHeMeOp6emSxfl3M8fECDtCX7amWsLHfc6pAIw X-Received: by 10.52.227.6 with SMTP id rw6mr1456246vdc.19.1382097234013; Fri, 18 Oct 2013 04:53:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp29485vcz; Fri, 18 Oct 2013 04:53:53 -0700 (PDT) X-Received: by 10.180.160.178 with SMTP id xl18mr2541625wib.61.1382097232915; Fri, 18 Oct 2013 04:53:52 -0700 (PDT) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by mx.google.com with ESMTPS id vs1si428448wjc.33.2013.10.18.04.53.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.173 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=209.85.212.173; Received: by mail-wi0-f173.google.com with SMTP id ey11so841076wid.6 for ; Fri, 18 Oct 2013 04:53:52 -0700 (PDT) X-Received: by 10.180.95.102 with SMTP id dj6mr2111553wib.31.1382097232374; Fri, 18 Oct 2013 04:53:52 -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 lr3sm25000673wic.5.2013.10.18.04.53.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:51 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, pjt@google.com, Morten.Rasmussen@arm.com, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com, linaro-kernel@lists.linaro.org Cc: rjw@sisk.pl, paulmck@linux.vnet.ibm.com, corbet@lwn.net, tglx@linutronix.de, len.brown@intel.com, arjan@linux.intel.com, amit.kucheria@linaro.org, l.majewski@samsung.com, Vincent Guittot Subject: [RFC][PATCH v5 07/14] sched: get CPU's activity statistic Date: Fri, 18 Oct 2013 13:52:20 +0200 Message-Id: <1382097147-30088-7-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> References: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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. 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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index db9b871..7e26f65 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -179,6 +179,11 @@ void sched_init_granularity(void) } #ifdef CONFIG_SMP +static unsigned long available_of(int cpu) +{ + return cpu_rq(cpu)->cpu_available; +} + #ifdef CONFIG_SCHED_PACKING_TASKS /* * Save the id of the optimal CPU that should be used to pack small tasks @@ -3549,6 +3554,22 @@ 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; + + sum = min(sum, period); + + if (sum == period) { + u32 overload = rq->nr_running > 1 ? 1 : 0; + return available_of(cpu) + overload; + } + + return (sum * available_of(cpu)) / period; +} + /* * sched_balance_self: balance the current task (running on cpu) in domains * that have the 'flag' flag set. In practice, this is SD_BALANCE_FORK and @@ -4430,6 +4451,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; @@ -4446,6 +4468,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 */ @@ -4465,6 +4488,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, @@ -4771,6 +4795,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)) @@ -4894,6 +4919,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, /* Now, start updating sd_lb_stats */ sds->total_load += sgs->group_load; + sds->total_activity += sgs->group_activity; sds->total_pwr += sgs->group_power; if (!local_group && update_sd_pick_busiest(env, sds, sg, sgs)) {