From: Shailabh Nagar <nagar@watson.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [Patch 2/4] Delay accounting: Block I/O delays
Date: Mon, 14 Nov 2005 23:35:42 -0500 [thread overview]
Message-ID: <4379659E.90905@watson.ibm.com> (raw)
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(¤t->delays.lock);
+ current->delays.blkio_delay += now - ts;
+ current->delays.blkio_count++;
+ spin_unlock(¤t->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;
}
reply other threads:[~2005-11-15 3:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4379659E.90905@watson.ibm.com \
--to=nagar@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/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