linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add all thread stats for TASKSTATS_CMD_ATTR_TGID
@ 2007-08-02 13:53 Guillaume Chazarain
  2007-08-02 19:04 ` Andrew Morton
  2007-08-15  7:15 ` Balbir Singh
  0 siblings, 2 replies; 21+ messages in thread
From: Guillaume Chazarain @ 2007-08-02 13:53 UTC (permalink / raw)
  To: Andrew Morton, Balbir Singh, Linux Kernel Mailing List

[Resent with different recipients as nagar@watson.ibm.com bounced with
a User unknown]

Hi,

This patch adds all thread accounting stats for the global tgid stats.
As a shameless plug, this fixes iotop -P (http://guichaz.free.fr/misc/iotop.py).

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
---

diff -r 22708012ca6e kernel/taskstats.c
--- a/kernel/taskstats.c	Tue Jul 31 21:12:07 2007 -0700
+++ b/kernel/taskstats.c	Wed Aug 01 17:43:54 2007 +0200
@@ -233,6 +233,7 @@ static int fill_tgid(pid_t tgid, struct
 		memset(stats, 0, sizeof(*stats));

 	tsk = first;
+	bacct_add_tsk(stats, first);
 	do {
 		if (tsk->exit_state)
 			continue;
@@ -246,6 +247,7 @@ static int fill_tgid(pid_t tgid, struct

 		stats->nvcsw += tsk->nvcsw;
 		stats->nivcsw += tsk->nivcsw;
+		xacct_add_tsk(stats, tsk);
 	} while_each_thread(first, tsk);

 	unlock_task_sighand(first, &flags);
diff -r 22708012ca6e kernel/tsacct.c
--- a/kernel/tsacct.c	Tue Jul 31 21:12:07 2007 -0700
+++ b/kernel/tsacct.c	Wed Aug 01 17:41:40 2007 +0200
@@ -81,8 +81,8 @@ void xacct_add_tsk(struct taskstats *sta
 	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;
+	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);
 	if (mm) {
 		/* adjust to KB unit */
@@ -90,18 +90,14 @@ void xacct_add_tsk(struct taskstats *sta
 		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;
+	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;
+	stats->read_bytes	+= p->ioac.read_bytes;
+	stats->write_bytes	+= p->ioac.write_bytes;
+	stats->cancelled_write_bytes += p->ioac.cancelled_write_bytes;
 #endif
 }
 #undef KB

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2007-09-20 12:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-02 13:53 [PATCH] Add all thread stats for TASKSTATS_CMD_ATTR_TGID Guillaume Chazarain
2007-08-02 19:04 ` Andrew Morton
2007-08-19 19:34   ` Guillaume Chazarain
2007-08-20 17:01     ` Balbir Singh
2007-08-25 15:10       ` Guillaume Chazarain
2007-08-26  4:58         ` Balbir Singh
2007-08-26  9:44           ` Guillaume Chazarain
2007-08-31  3:02           ` Jonathan Lim
2007-08-31  7:24             ` Balbir Singh
2007-08-31 12:35               ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v3) Guillaume Chazarain
2007-09-13  0:18                 ` Andrew Morton
2007-09-15 18:42                   ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v4) Guillaume Chazarain
2007-09-17 22:23                     ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v5) Guillaume Chazarain
2007-09-18 15:29                       ` Oleg Nesterov
2007-09-20  6:20                       ` Andrew Morton
2007-09-20  8:54                         ` Balbir Singh
2007-09-20 12:16                           ` Oleg Nesterov
2007-09-20 12:17                             ` Balbir Singh
2007-09-07 23:37               ` [PATCH] Add all thread stats for TASKSTATS_CMD_ATTR_TGID Jonathan Lim
2007-09-10 13:03                 ` Guillaume Chazarain
2007-08-15  7:15 ` Balbir Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).