public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch 2/4] Delay accounting: Block I/O delays
@ 2005-11-15  4:35 Shailabh Nagar
  0 siblings, 0 replies; only message in thread
From: Shailabh Nagar @ 2005-11-15  4:35 UTC (permalink / raw)
  To: linux-kernel

delayacct-blkio.patch

Record time spent by a task waiting to queue and complete block I/O.

Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com>

 include/linux/delayacct.h |   16 +++++++++++++++-
 include/linux/sched.h     |    2 ++
 kernel/sched.c            |    7 +++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

Index: linux-2.6.14/include/linux/delayacct.h
===================================================================
--- linux-2.6.14.orig/include/linux/delayacct.h
+++ linux-2.6.14/include/linux/delayacct.h
@@ -43,6 +43,19 @@ static inline void delayacct_timestamp(u
 #define test_ts_integrity(start_ts, end_ts)  (1)
 #endif

+static inline void delayacct_blkio(unsigned long long ts)
+{
+	unsigned long long now = sched_clock();
+
+	if (!test_ts_integrity(ts, now))
+		return;
+
+	spin_lock(&current->delays.lock);
+	current->delays.blkio_delay += now - ts;
+	current->delays.blkio_count++;
+	spin_unlock(&current->delays.lock);
+}
+
 #else

 static inline void delayacct_init(struct task_struct *tsk)
@@ -50,7 +63,8 @@ static inline void delayacct_init(struct
 #define delayacct_def_var(ts)
 static inline void delayacct_timestamp(unsigned long long *ts)
 {}
-
+static inline void delayacct_blkio(unsigned long long ts)
+{}
 #endif /* CONFIG_DELAY_ACCT */


Index: linux-2.6.14/include/linux/sched.h
===================================================================
--- linux-2.6.14.orig/include/linux/sched.h
+++ linux-2.6.14/include/linux/sched.h
@@ -502,6 +502,8 @@ struct task_delay_info {
 	spinlock_t	lock;

 	/* Add stats in pairs: uint64_t delay, uint32_t count */
+	uint64_t blkio_delay;	/* wait for block io completion */
+	uint32_t blkio_count;
 };
 #endif

Index: linux-2.6.14/kernel/sched.c
===================================================================
--- linux-2.6.14.orig/kernel/sched.c
+++ linux-2.6.14/kernel/sched.c
@@ -47,6 +47,7 @@
 #include <linux/syscalls.h>
 #include <linux/times.h>
 #include <linux/acct.h>
+#include <linux/delayacct.h>
 #include <asm/tlb.h>

 #include <asm/unistd.h>
@@ -4083,10 +4084,13 @@ EXPORT_SYMBOL(yield);
 void __sched io_schedule(void)
 {
 	struct runqueue *rq = &per_cpu(runqueues, raw_smp_processor_id());
+	delayacct_def_var(ts);

+	delayacct_timestamp(&ts);
 	atomic_inc(&rq->nr_iowait);
 	schedule();
 	atomic_dec(&rq->nr_iowait);
+	delayacct_blkio(ts);
 }

 EXPORT_SYMBOL(io_schedule);
@@ -4095,10 +4099,13 @@ long __sched io_schedule_timeout(long ti
 {
 	struct runqueue *rq = &per_cpu(runqueues, raw_smp_processor_id());
 	long ret;
+	delayacct_def_var(ts);

+	delayacct_timestamp(&ts);
 	atomic_inc(&rq->nr_iowait);
 	ret = schedule_timeout(timeout);
 	atomic_dec(&rq->nr_iowait);
+	delayacct_blkio(ts);
 	return ret;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-15  3:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-15  4:35 [Patch 2/4] Delay accounting: Block I/O delays Shailabh Nagar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox