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

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

 



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 <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Jay Lan <[email protected]>
Cc: Jonathan Lim <[email protected]>
Cc: Oleg Nesterov <[email protected]>
---

 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);
 
-
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