aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morton <[email protected]>2006-12-10 02:19:48 -0800
committerLinus Torvalds <[email protected]>2006-12-10 09:55:41 -0800
commitaba76fdb8a5fefba73d3490563bf7c4da37b1a34 (patch)
treeeefa514957d847d1fea1b8a76755907758867aca
parent98c4d57decf97bf8ddfe948a3266aa56b38b1a51 (diff)
[PATCH] io-accounting: report in procfs
Add a simple /proc/pid/io to show the IO accounting fields. Maybe this shouldn't be merged in mainline - the preferred reporting channel is taskstats. But given the poor state of our userspace support for taskstats, this is useful for developer-testing, at least. And it improves the changes that the procps developers will wire it up into top(1). Opinions are sought. The patch also wires up the existing IO-accounting fields. It's a bit racy on 32-bit machines: if process A reads process B's /proc/pid/io while process B is updating one of those 64-bit counters, process A could see an intermediate result. Cc: Jay Lan <[email protected]> Cc: Shailabh Nagar <[email protected]> Cc: Balbir Singh <[email protected]> Cc: Chris Sturtivant <[email protected]> Cc: Tony Ernst <[email protected]> Cc: Guillaume Thouvenin <[email protected]> Cc: David Wright <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--fs/proc/base.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index fd959d5b5a80..77a57b5799c4 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1804,6 +1804,27 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, filldir_t filld
proc_base_instantiate, task, p);
}
+#ifdef CONFIG_TASK_IO_ACCOUNTING
+static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
+{
+ return sprintf(buffer,
+ "rchar: %llu\n"
+ "wchar: %llu\n"
+ "syscr: %llu\n"
+ "syscw: %llu\n"
+ "read_bytes: %llu\n"
+ "write_bytes: %llu\n"
+ "cancelled_write_bytes: %llu\n",
+ (unsigned long long)task->rchar,
+ (unsigned long long)task->wchar,
+ (unsigned long long)task->syscr,
+ (unsigned long long)task->syscw,
+ (unsigned long long)task->ioac.read_bytes,
+ (unsigned long long)task->ioac.write_bytes,
+ (unsigned long long)task->ioac.cancelled_write_bytes);
+}
+#endif
+
/*
* Thread groups
*/
@@ -1855,6 +1876,9 @@ static struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject),
#endif
+#ifdef CONFIG_TASK_IO_ACCOUNTING
+ INF("io", S_IRUGO, pid_io_accounting),
+#endif
};
static int proc_tgid_base_readdir(struct file * filp,