[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080121110809.1b584998@laptopd505.fenrus.org>
Date:	Mon, 21 Jan 2008 11:08:09 -0800
From:	Arjan van de Ven <arjan@...radead.org>
To:	linux-kernel@...r.kernel.org
Cc:	mingo@...e.hu
Subject: [patch] sched: Keep total / count stats in addition to the max for
 wait time
From: Arjan van de Ven <arjan@...ux.intel.com>
Subject: sched: Keep total / count stats in addition to the max for wait time
Right now, the linux kernel (with scheduler statistics enabled) keeps track
of the maximum time a process is waiting to be scheduled. While the maximum
is a very useful metric, tracking average and total is equally useful
(at least for latencytop) to figure out the accumulated effect of scheduler
delays. The accumulated effect is important to judge the performance impact
of scheduler tuning/behavior.
Signed-off-by: Arjan van de Ven <arjan@...ux.intel.com>
---
 include/linux/sched.h |    2 ++
 kernel/sched_debug.c  |    4 ++++
 kernel/sched_fair.c   |    3 +++
 3 files changed, 9 insertions(+)
Index: linux-2.6.24-rc8/include/linux/sched.h
===================================================================
--- linux-2.6.24-rc8.orig/include/linux/sched.h
+++ linux-2.6.24-rc8/include/linux/sched.h
@@ -877,6 +877,8 @@ struct sched_entity {
 #ifdef CONFIG_SCHEDSTATS
 	u64			wait_start;
 	u64			wait_max;
+	u64			wait_count;
+	u64			wait_sum;
 
 	u64			sleep_start;
 	u64			sleep_max;
Index: linux-2.6.24-rc8/kernel/sched_debug.c
===================================================================
--- linux-2.6.24-rc8.orig/kernel/sched_debug.c
+++ linux-2.6.24-rc8/kernel/sched_debug.c
@@ -299,6 +299,8 @@ void proc_sched_show_task(struct task_st
 	PN(se.exec_max);
 	PN(se.slice_max);
 	PN(se.wait_max);
+	PN(se.wait_sum);
+	P(se.wait_count);
 	P(sched_info.bkl_count);
 	P(se.nr_migrations);
 	P(se.nr_migrations_cold);
@@ -366,6 +368,8 @@ void proc_sched_set_task(struct task_str
 {
 #ifdef CONFIG_SCHEDSTATS
 	p->se.wait_max				= 0;
+	p->se.wait_sum				= 0;
+	p->se.wait_count			= 0;
 	p->se.sleep_max				= 0;
 	p->se.sum_sleep_runtime			= 0;
 	p->se.block_max				= 0;
Index: linux-2.6.24-rc8/kernel/sched_fair.c
===================================================================
--- linux-2.6.24-rc8.orig/kernel/sched_fair.c
+++ linux-2.6.24-rc8/kernel/sched_fair.c
@@ -385,6 +385,9 @@ update_stats_wait_end(struct cfs_rq *cfs
 {
 	schedstat_set(se->wait_max, max(se->wait_max,
 			rq_of(cfs_rq)->clock - se->wait_start));
+	schedstat_set(se->wait_count, se->wait_count + 1);
+	schedstat_set(se->wait_sum, se->wait_sum +
+			rq_of(cfs_rq)->clock - se->wait_start);
 	schedstat_set(se->wait_start, 0);
 }
 
-- 
If you want to reach me at my work email, use arjan@...ux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
