aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/task_io_accounting_ops.h
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-05-11 01:22:37 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 11:29:34 -0400
commit6eaeeaba39e5fa3d52a0bb8de15e995516ae251a (patch)
tree5b4052fabfe107ad5332cb758ad8d86ea5a87848 /include/linux/task_io_accounting_ops.h
parent02239c29967418284c05d58971894d658575e78c (diff)
getrusage(): fill ru_inblock and ru_oublock fields if possible
If CONFIG_TASK_IO_ACCOUNTING is defined, we update io accounting counters for each task. This patch permits reporting of values using the well known getrusage() syscall, filling ru_inblock and ru_oublock instead of null values. As TASK_IO_ACCOUNTING currently counts bytes counts, we approximate blocks count doing : nr_blocks = nr_bytes / 512 Example of use : ---------------------- After patch is applied, /usr/bin/time command can now give a good approximation of IO that the process had to do. $ /usr/bin/time grep tototo /usr/include/* Command exited with non-zero status 1 0.00user 0.02system 0:02.11elapsed 1%CPU (0avgtext+0avgdata 0maxresident)k 24288inputs+0outputs (0major+259minor)pagefaults 0swaps $ /usr/bin/time dd if=/dev/zero of=/tmp/testfile count=1000 1000+0 enregistrements lus 1000+0 enregistrements écrits 512000 octets (512 kB) copiés, 0,00326601 seconde, 157 MB/s 0.00user 0.00system 0:00.00elapsed 80%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+3000outputs (0major+299minor)pagefaults 0swaps Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/task_io_accounting_ops.h')
-rw-r--r--include/linux/task_io_accounting_ops.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
index df2a319106b..1218733ec6b 100644
--- a/include/linux/task_io_accounting_ops.h
+++ b/include/linux/task_io_accounting_ops.h
@@ -10,11 +10,29 @@ static inline void task_io_account_read(size_t bytes)
10 current->ioac.read_bytes += bytes; 10 current->ioac.read_bytes += bytes;
11} 11}
12 12
13/*
14 * We approximate number of blocks, because we account bytes only.
15 * A 'block' is 512 bytes
16 */
17static inline unsigned long task_io_get_inblock(const struct task_struct *p)
18{
19 return p->ioac.read_bytes >> 9;
20}
21
13static inline void task_io_account_write(size_t bytes) 22static inline void task_io_account_write(size_t bytes)
14{ 23{
15 current->ioac.write_bytes += bytes; 24 current->ioac.write_bytes += bytes;
16} 25}
17 26
27/*
28 * We approximate number of blocks, because we account bytes only.
29 * A 'block' is 512 bytes
30 */
31static inline unsigned long task_io_get_oublock(const struct task_struct *p)
32{
33 return p->ioac.write_bytes >> 9;
34}
35
18static inline void task_io_account_cancelled_write(size_t bytes) 36static inline void task_io_account_cancelled_write(size_t bytes)
19{ 37{
20 current->ioac.cancelled_write_bytes += bytes; 38 current->ioac.cancelled_write_bytes += bytes;
@@ -31,10 +49,20 @@ static inline void task_io_account_read(size_t bytes)
31{ 49{
32} 50}
33 51
52static inline unsigned long task_io_get_inblock(const struct task_struct *p)
53{
54 return 0;
55}
56
34static inline void task_io_account_write(size_t bytes) 57static inline void task_io_account_write(size_t bytes)
35{ 58{
36} 59}
37 60
61static inline unsigned long task_io_get_oublock(const struct task_struct *p)
62{
63 return 0;
64}
65
38static inline void task_io_account_cancelled_write(size_t bytes) 66static inline void task_io_account_cancelled_write(size_t bytes)
39{ 67{
40} 68}