[PATCH 6/8] taskstats: tell fill_threadgroup_stats() if it replies with PID or TGID stats

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Guillaume Chazarain
Date: Wednesday, September 26, 2007 - 10:08 am

fill_threadgroup_stats() may want to know if it is filling
TASKSTATS_CMD_ATTR_TGID or TASKSTATS_CMD_ATTR_PID stats, so give it this
information in the tg_stats boolean.

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Cc: Jonathan Lim <jlim@sgi.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
---

 include/linux/tsacct_kern.h |    4 ++--
 kernel/taskstats.c          |   11 ++++++-----
 kernel/tsacct.c             |    3 ++-
 3 files changed, 10 insertions(+), 8 deletions(-)


diff --git a/include/linux/tsacct_kern.h b/include/linux/tsacct_kern.h
index 1568a3d..e8d1ad6 100644
--- a/include/linux/tsacct_kern.h
+++ b/include/linux/tsacct_kern.h
@@ -11,11 +11,11 @@
 
 #ifdef CONFIG_TASKSTATS
 void bacct_add_tsk(struct taskstats *stats, struct task_struct *task);
-void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task);
+void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task, bool tg_stats);
 #else
 static inline void bacct_add_tsk(struct taskstats *stats, struct task_struct *task)
 {}
-static inline void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task)
+static inline void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task, bool tg_stats)
 {}
 #endif /* CONFIG_TASKSTATS */
 
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index f25bf03..59fe1d8 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -204,12 +204,13 @@ static void add_tsk_stats(struct taskstats *stats, struct task_struct *task)
  * fill_threadgroup_stats - initialize some common stats for the thread group
  * @stats: the taskstats to write into
  * @task: the thread representing the whole group
+ * @tg_stats: whether in the end thread group stats are requested
  *
  * Will be called on the thread group leader if requesting stats for the whole
  * thread group.
  */
 static void fill_threadgroup_stats(struct taskstats *stats,
-				   struct task_struct *task)
+				   struct task_struct *task, bool tg_stats)
 {
 	/*
 	 * Each accounting subsystem adds calls to its functions to initialize
@@ -221,7 +222,7 @@ static void fill_threadgroup_stats(struct taskstats *stats,
 	stats->version = TASKSTATS_VERSION;
 
 	/* fill in basic acct fields */
-	bacct_fill_threadgroup(stats, task);
+	bacct_fill_threadgroup(stats, task, tg_stats);
 
 	/* fill in extended acct fields */
 	xacct_fill_threadgroup(stats, task);
@@ -244,7 +245,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk, struct taskstats *stats)
 
 	memset(stats, 0, sizeof(*stats));
 	add_tsk_stats(stats, tsk);
-	fill_threadgroup_stats(stats, tsk);
+	fill_threadgroup_stats(stats, tsk, false);
 
 	/* Define err: label here if needed */
 	put_task_struct(tsk);
@@ -285,7 +286,7 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
 			add_tsk_stats(stats, tsk);
 	} while_each_thread(first, tsk);
 
-	fill_threadgroup_stats(stats, first->group_leader);
+	fill_threadgroup_stats(stats, first->group_leader, true);
 	unlock_task_sighand(first, &flags);
 	rc = 0;
 out:
@@ -541,7 +542,7 @@ void taskstats_exit(struct task_struct *tsk, int group_dead)
 	 */
 
 	memcpy(stats, tsk->signal->stats, sizeof(*stats));
-	fill_threadgroup_stats(stats, tsk->group_leader);
+	fill_threadgroup_stats(stats, tsk->group_leader, true);
 
 send:
 	send_cpu_listeners(rep_skb, listeners);
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 73b4c69..8c2f470 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -62,7 +62,8 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
 	stats->nivcsw		+= tsk->nivcsw;
 }
 
-void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *tsk)
+void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *tsk,
+			    bool tg_stats)
 {
 	fill_wall_times(stats, tsk);
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/8] taskstats: fix indentation of long argument lists, Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 2/8] taskstats: split the basic accounting fields, Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 3/8] taskstats: split the extended accounting fields, Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 4/8] taskstats: separate PID/TGID stats producers t ..., Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 5/8] taskstats: factor out version and context swit ..., Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 6/8] taskstats: tell fill_threadgroup_stats() if it ..., Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 7/8] taskstats: fix stats-&gt;ac_exitcode to work on t ..., Guillaume Chazarain, (Wed Sep 26, 10:08 am)
[PATCH 8/8] taskstats: avoid breaking binary compatibility ..., Guillaume Chazarain, (Wed Sep 26, 10:08 am)
Re: [PATCH 1/8] taskstats: fix indentation of long argumen ..., Guillaume Chazarain, (Wed Sep 26, 10:12 am)
Re: [PATCH 1/8] taskstats: fix indentation of long argumen ..., Guillaume Chazarain, (Thu Sep 27, 1:39 am)