From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412Ab2LJI17 (ORCPT ); Mon, 10 Dec 2012 03:27:59 -0500 Received: from mga14.intel.com ([143.182.124.37]:14834 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753037Ab2LJI0c (ORCPT ); Mon, 10 Dec 2012 03:26:32 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,250,1355126400"; d="scan'208";a="178808757" From: Alex Shi To: rob@landley.net, mingo@redhat.com, peterz@infradead.org Cc: gregkh@linuxfoundation.org, andre.przywara@amd.com, rjw@sisk.pl, paul.gortmaker@windriver.com, akpm@linux-foundation.org, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, pjt@google.com, vincent.guittot@linaro.org Subject: [PATCH 12/18] sched: log the cpu utilization at rq Date: Mon, 10 Dec 2012 16:22:28 +0800 Message-Id: <1355127754-8444-13-git-send-email-alex.shi@intel.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1355127754-8444-1-git-send-email-alex.shi@intel.com> References: <1355127754-8444-1-git-send-email-alex.shi@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpu's utilization is to measure how busy is the cpu. util = cpu_rq(cpu)->avg.runnable_avg_sum / cpu_rq(cpu)->avg.runnable_avg_period; Since the util is no more than 1, we use its percentage value in later caculations. Considering there are interval between balancing, if the cpu util is up to 97%, we can think it is full of load in a health kernel. In later power aware scheduling, we are sensitive for how busy of the cpu, not how weight of its load. As to power comsuming, it is more related with busy time, not the load weight. Signed-off-by: Alex Shi --- kernel/sched/fair.c | 4 ++++ kernel/sched/sched.h | 3 +++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1b1deb8..4cc1764 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1269,8 +1269,12 @@ static void update_cfs_rq_blocked_load(struct cfs_rq *cfs_rq, int force_update) static inline void update_rq_runnable_avg(struct rq *rq, int runnable) { + int period; __update_entity_runnable_avg(rq->clock_task, &rq->avg, runnable); __update_tg_runnable_avg(&rq->avg, &rq->cfs); + + period = rq->avg.runnable_avg_period ? rq->avg.runnable_avg_period : 1; + rq->util = rq->avg.runnable_avg_sum * 100 / period; } /* Add the load generated by se into cfs_rq's child load-average */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 7a5eae4..5247560 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -350,6 +350,8 @@ extern struct root_domain def_root_domain; #endif /* CONFIG_SMP */ +/* Take as full load, if the cpu util is up to 97% */ +#define FULL_UTIL 97 /* * This is the main, per-CPU runqueue data structure. * @@ -481,6 +483,7 @@ struct rq { #endif struct sched_avg avg; + unsigned int util; }; static inline int cpu_of(struct rq *rq) -- 1.7.5.1