Fix io accounting in kernel module
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Tue, 25 Jun 2019 06:28:26 +0000 (08:28 +0200)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Thu, 27 Jun 2019 11:38:14 +0000 (13:38 +0200)
Change-Id: Id3722fbc99a77062a5168f8d51f0b655eb6fc141

kernel/proc-tsm.c

index 5dad1aa..8f61d51 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/fdtable.h>
 #include <linux/math64.h>
+#include <linux/task_io_accounting_ops.h>
 
 #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");
     }