From c14481f58660f2010b8de923aa7fbddb653e48d6 Mon Sep 17 00:00:00 2001 From: Konrad Kuchciak Date: Tue, 25 Jun 2019 08:28:26 +0200 Subject: [PATCH] Fix io accounting in kernel module Change-Id: Id3722fbc99a77062a5168f8d51f0b655eb6fc141 --- kernel/proc-tsm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/kernel/proc-tsm.c b/kernel/proc-tsm.c index 5dad1aa..8f61d51 100644 --- a/kernel/proc-tsm.c +++ b/kernel/proc-tsm.c @@ -32,6 +32,7 @@ #include #include #include +#include #define DEBUG 0 #define PAGE_TO_KB(x) ((x) << (PAGE_SHIFT - 10)) @@ -47,13 +48,14 @@ static u64 time_now(void) static int stability_monitor_show(struct seq_file *m, void *v) { struct sysinfo info; - struct task_struct *task; + struct task_struct *task, *t; struct pid *pid = NULL; pid_t ppid = 0; + u64 uptime; cputime_t utime, stime; - unsigned long long vm_rss, total_ram, task_io; + unsigned long long vm_rss, total_ram; + struct task_io_accounting task_ioac; unsigned int open_fds; - u64 uptime; rcu_read_lock(); @@ -98,7 +100,11 @@ static int stability_monitor_show(struct seq_file *m, void *v) thread_group_cputime_adjusted(task, &utime, &stime); /* IO */ - task_io = (unsigned long long)task->ioac.read_bytes + (unsigned long long)task->ioac.write_bytes; + task_ioac = task->ioac; + t = task; + while_each_thread(task, t) + task_io_accounting_add(&task_ioac, &t->ioac); + task_unlock(task); @@ -107,7 +113,7 @@ static int stability_monitor_show(struct seq_file *m, void *v) seq_put_decimal_ull(m, ' ', cputime_to_usecs(utime + stime)); seq_put_decimal_ull(m, ' ', PAGE_TO_KB(vm_rss)); // kB seq_put_decimal_ll(m, ' ', open_fds); - seq_put_decimal_ull(m, ' ', task_io); + seq_put_decimal_ull(m, ' ', task_ioac.read_bytes + task_ioac.write_bytes); seq_printf(m, "\n"); } -- 2.34.1