aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
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 /kernel/sys.c
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 'kernel/sys.c')
-rw-r--r--kernel/sys.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index cdb7e9457ba6..ec319bbb0bd4 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -29,6 +29,7 @@
29#include <linux/signal.h> 29#include <linux/signal.h>
30#include <linux/cn_proc.h> 30#include <linux/cn_proc.h>
31#include <linux/getcpu.h> 31#include <linux/getcpu.h>
32#include <linux/task_io_accounting_ops.h>
32 33
33#include <linux/compat.h> 34#include <linux/compat.h>
34#include <linux/syscalls.h> 35#include <linux/syscalls.h>
@@ -2082,6 +2083,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2082 r->ru_nivcsw = p->signal->cnivcsw; 2083 r->ru_nivcsw = p->signal->cnivcsw;
2083 r->ru_minflt = p->signal->cmin_flt; 2084 r->ru_minflt = p->signal->cmin_flt;
2084 r->ru_majflt = p->signal->cmaj_flt; 2085 r->ru_majflt = p->signal->cmaj_flt;
2086 r->ru_inblock = p->signal->cinblock;
2087 r->ru_oublock = p->signal->coublock;
2085 2088
2086 if (who == RUSAGE_CHILDREN) 2089 if (who == RUSAGE_CHILDREN)
2087 break; 2090 break;
@@ -2093,6 +2096,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2093 r->ru_nivcsw += p->signal->nivcsw; 2096 r->ru_nivcsw += p->signal->nivcsw;
2094 r->ru_minflt += p->signal->min_flt; 2097 r->ru_minflt += p->signal->min_flt;
2095 r->ru_majflt += p->signal->maj_flt; 2098 r->ru_majflt += p->signal->maj_flt;
2099 r->ru_inblock += p->signal->inblock;
2100 r->ru_oublock += p->signal->oublock;
2096 t = p; 2101 t = p;
2097 do { 2102 do {
2098 utime = cputime_add(utime, t->utime); 2103 utime = cputime_add(utime, t->utime);
@@ -2101,6 +2106,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2101 r->ru_nivcsw += t->nivcsw; 2106 r->ru_nivcsw += t->nivcsw;
2102 r->ru_minflt += t->min_flt; 2107 r->ru_minflt += t->min_flt;
2103 r->ru_majflt += t->maj_flt; 2108 r->ru_majflt += t->maj_flt;
2109 r->ru_inblock += task_io_get_inblock(t);
2110 r->ru_oublock += task_io_get_oublock(t);
2104 t = next_thread(t); 2111 t = next_thread(t);
2105 } while (t != p); 2112 } while (t != p);
2106 break; 2113 break;