linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shailabh Nagar <nagar@watson.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [Patch 7/8] proc interface for block I/O delays
Date: Wed, 29 Mar 2006 19:56:44 -0500	[thread overview]
Message-ID: <442B2CCC.2080604@watson.ibm.com> (raw)
In-Reply-To: <442B271D.10208@watson.ibm.com>

delayacct-procfs.patch

Export I/O delays seen by a task through /proc/<tgid>/stats
for use in top etc.

Note that delays for I/O done for swapping in pages (swapin I/O) is
clubbed together with all other I/O here (this is not the
case in the netlink interface where the swapin I/O is kept distinct)

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


 fs/proc/array.c           |    6 ++++--
 include/linux/delayacct.h |   11 +++++++++++
 kernel/delayacct.c        |   15 +++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)

Index: linux-2.6.16/fs/proc/array.c
===================================================================
--- linux-2.6.16.orig/fs/proc/array.c	2006-03-29 18:12:54.000000000 -0500
+++ linux-2.6.16/fs/proc/array.c	2006-03-29 18:13:21.000000000 -0500
@@ -75,6 +75,7 @@
 #include <linux/times.h>
 #include <linux/cpuset.h>
 #include <linux/rcupdate.h>
+#include <linux/delayacct.h>

 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -414,7 +415,7 @@ static int do_task_stat(struct task_stru

 	res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu \
-%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n",
+%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n",
 		task->pid,
 		tcomm,
 		state,
@@ -459,7 +460,8 @@ static int do_task_stat(struct task_stru
 		task->exit_signal,
 		task_cpu(task),
 		task->rt_priority,
-		task->policy);
+		task->policy,
+		delayacct_blkio_ticks(task));
 	if(mm)
 		mmput(mm);
 	return res;
Index: linux-2.6.16/include/linux/delayacct.h
===================================================================
--- linux-2.6.16.orig/include/linux/delayacct.h	2006-03-29 18:13:18.000000000 -0500
+++ linux-2.6.16/include/linux/delayacct.h	2006-03-29 18:13:21.000000000 -0500
@@ -29,6 +29,7 @@ extern void __delayacct_tsk_exit(struct
 extern void __delayacct_blkio_start(void);
 extern void __delayacct_blkio_end(void);
 extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
+extern unsigned long long __delayacct_blkio_ticks(struct task_struct *);

 static inline void delayacct_tsk_init(struct task_struct *tsk)
 {
@@ -54,6 +55,12 @@ static inline void delayacct_blkio_end(v
 	if (current->delays)
 		__delayacct_blkio_end();
 }
+static inline unsigned long long delayacct_blkio_ticks(struct task_struct *tsk)
+{
+	if (unlikely(delayacct_on))
+		return __delayacct_blkio_ticks(tsk);
+	return 0;
+}
 #else
 static inline void delayacct_init(void)
 {}
@@ -65,6 +72,10 @@ static inline void delayacct_blkio_start
 {}
 static inline void delayacct_blkio_end(void)
 {}
+static inline unsigned long long delayacct_blkio_ticks(struct task_struct *tsk)
+{
+	return 0;
+}
 #endif /* CONFIG_TASK_DELAY_ACCT */
 #ifdef CONFIG_TASKSTATS
 static inline int delayacct_add_tsk(struct taskstats *d,
Index: linux-2.6.16/kernel/delayacct.c
===================================================================
--- linux-2.6.16.orig/kernel/delayacct.c	2006-03-29 18:13:20.000000000 -0500
+++ linux-2.6.16/kernel/delayacct.c	2006-03-29 18:13:21.000000000 -0500
@@ -118,6 +118,21 @@ void __delayacct_blkio_end(void)
 			      &current->delays->blkio_delay,
 			      &current->delays->blkio_count);
 }
+
+unsigned long long __delayacct_blkio_ticks(struct task_struct *tsk)
+{
+	unsigned long long ret;
+
+	if (!tsk->delays)
+		return 0;
+
+	spin_lock(&tsk->delays->lock);
+	ret = nsec_to_clock_t(tsk->delays->blkio_delay +
+				tsk->delays->swapin_delay);
+	spin_unlock(&tsk->delays->lock);
+	return ret;
+}
+
 #ifdef CONFIG_TASKSTATS
 int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
 {


  parent reply	other threads:[~2006-03-30  0:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30  0:32 [Patch 0/8] per-task delay accounting Shailabh Nagar
2006-03-30  0:35 ` [Patch 1/8] Setup Shailabh Nagar
2006-03-30  5:03   ` Andrew Morton
2006-03-30 15:07     ` Shailabh Nagar
2006-03-30  0:37 ` [Patch 2/8] Block I/O, swapin delays Shailabh Nagar
2006-03-30  5:03   ` Andrew Morton
2006-03-30 15:21     ` Shailabh Nagar
2006-03-30  0:42 ` [Patch 3/8] cpu delays Shailabh Nagar
2006-03-30  5:03   ` Andrew Morton
2006-03-30 16:01     ` Shailabh Nagar
2006-03-30 16:00   ` Dave Hansen
2006-03-30 16:03     ` Shailabh Nagar
2006-03-30  0:48 ` [Patch 4/8] generic netlink utility functions Shailabh Nagar
2006-03-30  0:52 ` [Patch 5/8] generic netlink interface for delay accounting Shailabh Nagar
2006-03-30  5:04   ` Andrew Morton
2006-03-30  6:10     ` Balbir Singh
2006-03-30  6:26       ` Andrew Morton
2006-03-30  6:29         ` Balbir Singh
2006-03-30 16:24       ` Shailabh Nagar
2006-03-30  0:54 ` [Patch 6/8] virtual cpu run time Shailabh Nagar
2006-03-30  5:04   ` Andrew Morton
2006-03-30 16:10     ` Shailabh Nagar
2006-03-30  0:56 ` Shailabh Nagar [this message]
2006-03-30  5:04   ` [Patch 7/8] proc interface for block I/O delays Andrew Morton
2006-03-30  0:59 ` [Patch 8/8] documentation, userspace utility Shailabh Nagar
2006-03-30  5:03 ` [Patch 0/8] per-task delay accounting Andrew Morton
2006-03-30  6:23   ` Balbir Singh
2006-03-30  6:47     ` Andrew Morton
2006-03-30  9:55       ` Paul Jackson
2006-03-30 13:23       ` [Lse-tech] " Dipankar Sarma
2006-03-30 17:23       ` Shailabh Nagar
2006-03-31  2:54         ` Peter Chubb
2006-03-31  5:27           ` Shailabh Nagar
2006-03-31  8:17             ` Peter Chubb
2006-03-31 16:03               ` Shailabh Nagar
     [not found]       ` <442CCF54.3000501@watson.ibm.com>
2006-03-31  7:31         ` Guillaume Thouvenin
2006-03-31 17:01           ` Shailabh Nagar
     [not found]         ` <442D8E39.8080606@engr.sgi.com>
     [not found]           ` <442DED81.5060009@engr.sgi.com>
2006-04-10 17:15             ` Jay Lan
2006-04-10 21:44               ` Shailabh Nagar
2006-04-10 22:33                 ` [Lse-tech] " Jay Lan

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=442B2CCC.2080604@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;
as well as URLs for NNTP newsgroup(s).