aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-12-10 05:19:48 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-10 12:55:41 -0500
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 <jlan@sgi.com> Cc: Shailabh Nagar <nagar@watson.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Chris Sturtivant <csturtiv@sgi.com> Cc: Tony Ernst <tee@sgi.com> Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net> Cc: David Wright <daw@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-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
1804 proc_base_instantiate, task, p); 1804 proc_base_instantiate, task, p);
1805} 1805}
1806 1806
1807#ifdef CONFIG_TASK_IO_ACCOUNTING
1808static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
1809{
1810 return sprintf(buffer,
1811 "rchar: %llu\n"
1812 "wchar: %llu\n"
1813 "syscr: %llu\n"
1814 "syscw: %llu\n"
1815 "read_bytes: %llu\n"
1816 "write_bytes: %llu\n"
1817 "cancelled_write_bytes: %llu\n",
1818 (unsigned long long)task->rchar,
1819 (unsigned long long)task->wchar,
1820 (unsigned long long)task->syscr,
1821 (unsigned long long)task->syscw,
1822 (unsigned long long)task->ioac.read_bytes,
1823 (unsigned long long)task->ioac.write_bytes,
1824 (unsigned long long)task->ioac.cancelled_write_bytes);
1825}
1826#endif
1827
1807/* 1828/*
1808 * Thread groups 1829 * Thread groups
1809 */ 1830 */
@@ -1855,6 +1876,9 @@ static struct pid_entry tgid_base_stuff[] = {
1855#ifdef CONFIG_FAULT_INJECTION 1876#ifdef CONFIG_FAULT_INJECTION
1856 REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), 1877 REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject),
1857#endif 1878#endif
1879#ifdef CONFIG_TASK_IO_ACCOUNTING
1880 INF("io", S_IRUGO, pid_io_accounting),
1881#endif
1858}; 1882};
1859 1883
1860static int proc_tgid_base_readdir(struct file * filp, 1884static int proc_tgid_base_readdir(struct file * filp,