[PATCH 3/8] taskstats: split the extended accounting fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Split the extended accounting taskstats fields into the threadgroup specific
ones and the thread specific ones. This should have no effect on the execution.

Signed-off-by: Guillaume Chazarain <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Jay Lan <[email protected]>
Cc: Jonathan Lim <[email protected]>
Cc: Oleg Nesterov <[email protected]>
---

 kernel/tsacct.c |   48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)


diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index d32378f..e8c25d2 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -101,33 +101,41 @@ static void bacct_fill_threadgroup(struct taskstats *stats,
 /*
  * fill in extended accounting fields
  */
-void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
+
+static void xacct_fill_threadgroup(struct taskstats *stats,
+				   struct task_struct *tsk);
+
+void xacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
+{
+	/* convert pages-jiffies to Mbyte-usec */
+	stats->coremem += jiffies_to_usecs(tsk->acct_rss_mem1) * PAGE_SIZE / MB;
+	stats->virtmem += jiffies_to_usecs(tsk->acct_vm_mem1)  * PAGE_SIZE / MB;
+
+	stats->read_char	+= tsk->rchar;
+	stats->write_char	+= tsk->wchar;
+	stats->read_syscalls	+= tsk->syscr;
+	stats->write_syscalls	+= tsk->syscw;
+#ifdef CONFIG_TASK_IO_ACCOUNTING
+	stats->read_bytes	+= tsk->ioac.read_bytes;
+	stats->write_bytes	+= tsk->ioac.write_bytes;
+	stats->cancelled_write_bytes += tsk->ioac.cancelled_write_bytes;
+#endif
+
+	xacct_fill_threadgroup(stats, tsk);
+}
+
+static void xacct_fill_threadgroup(struct taskstats *stats,
+				   struct task_struct *tsk)
 {
 	struct mm_struct *mm;
 
-	/* convert pages-jiffies to Mbyte-usec */
-	stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB;
-	stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB;
-	mm = get_task_mm(p);
+	mm = get_task_mm(tsk);
 	if (mm) {
 		/* adjust to KB unit */
-		stats->hiwater_rss   = mm->hiwater_rss * PAGE_SIZE / KB;
-		stats->hiwater_vm    = mm->hiwater_vm * PAGE_SIZE / KB;
+		stats->hiwater_rss = mm->hiwater_rss * PAGE_SIZE / KB;
+		stats->hiwater_vm  = mm->hiwater_vm  * PAGE_SIZE / KB;
 		mmput(mm);
 	}
-	stats->read_char	= p->rchar;
-	stats->write_char	= p->wchar;
-	stats->read_syscalls	= p->syscr;
-	stats->write_syscalls	= p->syscw;
-#ifdef CONFIG_TASK_IO_ACCOUNTING
-	stats->read_bytes	= p->ioac.read_bytes;
-	stats->write_bytes	= p->ioac.write_bytes;
-	stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes;
-#else
-	stats->read_bytes	= 0;
-	stats->write_bytes	= 0;
-	stats->cancelled_write_bytes = 0;
-#endif
 }
 #undef KB
 #undef MB
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux