From: Alex Shi <alex.shi@intel.com>
To: Lei Wen <leiwen@marvell.com>
Cc: Paul Turner <pjt@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] sched: add trace event for per-entity tracking
Date: Mon, 01 Jul 2013 16:06:31 +0800 [thread overview]
Message-ID: <51D13887.7000606@intel.com> (raw)
In-Reply-To: <1372662634-12833-1-git-send-email-leiwen@marvell.com>
On 07/01/2013 03:10 PM, Lei Wen wrote:
> Thanks for the per-entity tracking feature, we could know the details of
> each task by its help.
> This patch add its trace support, so that we could quickly know the system
> status in a large time scale, like now we may get each runqueue's usage ratio by:
>
> cfs_rq's usage ratio = cfs_rq->runnable_load_avg/cfs_rq->load.weight
>
the direct usage ratio is rq.avg.runnable_avg_sum / rq.avg.runnable_avg_period.
one patch from obsolete power-scheduling could be reference for this:
git@github.com:alexshi/power-scheduling.git power-scheduling
>From 081cd4bcbccfaa1930b031e4dfbf9d23b8c0d5ab Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi@intel.com>
Date: Fri, 7 Dec 2012 21:37:58 +0800
Subject: [PATCH 02/23] sched: log the cpu utilization at rq
The cpu's utilization is to measure how busy is the cpu.
util = cpu_rq(cpu)->avg.runnable_avg_sum * SCHED_POEWR_SCALE
/ cpu_rq(cpu)->avg.runnable_avg_period;
Since the util is no more than 1, we scale its value with 1024, same as
SCHED_POWER_SCALE and set the FULL_UTIL as 1024.
In later power aware scheduling, we are sensitive for how busy of the
cpu. Since as to power consuming, it is tight related with cpu busy
time.
BTW, rq->util can be used for any purposes if needed, not only power
scheduling.
Signed-off-by: Alex Shi <alex.shi@intel.com>
---
include/linux/sched.h | 2 +-
kernel/sched/debug.c | 1 +
kernel/sched/fair.c | 5 +++++
kernel/sched/sched.h | 4 ++++
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 9539597..4e4d9ee 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -794,7 +794,7 @@ enum cpu_idle_type {
#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT)
/*
- * Increase resolution of cpu_power calculations
+ * Increase resolution of cpu_power and rq->util calculations
*/
#define SCHED_POWER_SHIFT 10
#define SCHED_POWER_SCALE (1L << SCHED_POWER_SHIFT)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 75024a6..f5db759 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -311,6 +311,7 @@ do { \
P(ttwu_count);
P(ttwu_local);
+ P(util);
#undef P
#undef P64
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2e49c3f..7124244 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1495,8 +1495,13 @@ 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)
{
+ u32 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 = (u64)(rq->avg.runnable_avg_sum << SCHED_POWER_SHIFT)
+ / 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 804ee41..8682110 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -351,6 +351,9 @@ extern struct root_domain def_root_domain;
#endif /* CONFIG_SMP */
+/* full cpu utilization */
+#define FULL_UTIL SCHED_POWER_SCALE
+
/*
* This is the main, per-CPU runqueue data structure.
*
@@ -482,6 +485,7 @@ struct rq {
#endif
struct sched_avg avg;
+ unsigned int util;
};
static inline int cpu_of(struct rq *rq)
--
1.7.12
--
Thanks
Alex
next prev parent reply other threads:[~2013-07-01 8:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 7:10 [PATCH 0/2] sched: add trace event for per-entity tracking Lei Wen
2013-07-01 7:10 ` [PATCH 1/2] sched: add trace events for task and rq usage tracking Lei Wen
2013-07-01 9:43 ` Kamalesh Babulal
2013-07-01 12:18 ` Lei Wen
2013-07-01 7:10 ` [PATCH 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
2013-07-01 8:06 ` Alex Shi [this message]
2013-07-01 8:49 ` [PATCH 0/2] sched: add trace event for per-entity tracking Lei Wen
2013-07-01 12:33 ` [PATCH V2 " Lei Wen
2013-07-01 12:33 ` [V2 1/2] sched: add trace events for task and rq usage tracking Lei Wen
2013-07-01 12:44 ` Peter Zijlstra
2013-07-01 13:25 ` Lei Wen
2013-07-01 12:33 ` [V2 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
2013-07-01 14:07 ` Paul Turner
2013-07-02 2:52 ` Lei Wen
2013-07-02 12:15 ` [PATCH V3 0/2] sched: add trace event for per-entity tracking Lei Wen
2013-07-02 12:15 ` [V3 1/2] sched: add trace events for task and rq usage tracking Lei Wen
2013-07-03 12:46 ` Lei Wen
2013-07-02 12:15 ` [V3 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51D13887.7000606@intel.com \
--to=alex.shi@intel.com \
--cc=leiwen@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox