From: Guillaume Chazarain <guichaz@yahoo.fr>
To: Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@tv-sign.ru>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Jonathan Lim <jlim@sgi.com>, Jay Lan <jlan@cthulhu.engr.sgi.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] taskstats: tell fill_thread_group() whether it replies with PID or TGID stats
Date: Sat, 22 Sep 2007 01:30:49 +0200 [thread overview]
Message-ID: <20070921233049.21607.39807.stgit@localhost.localdomain> (raw)
In-Reply-To: <20070921233038.21607.51089.stgit@localhost.localdomain>
fill_thread_group() 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 | 12 +++++++-----
kernel/tsacct.c | 3 ++-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/include/linux/tsacct_kern.h b/include/linux/tsacct_kern.h
index 93dffc2..5652ae0 100644
--- a/include/linux/tsacct_kern.h
+++ b/include/linux/tsacct_kern.h
@@ -10,10 +10,10 @@
#include <linux/taskstats.h>
#ifdef CONFIG_TASKSTATS
-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);
void bacct_add_tsk(struct taskstats *stats, struct task_struct *task);
#else
-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)
{}
static inline void bacct_add_tsk(struct taskstats *stats, struct task_struct *task)
{}
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index ce43fae..42d3110 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -172,6 +172,7 @@ static void send_cpu_listeners(struct sk_buff *skb,
* fill_threadgroup - 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
*
* There are two types of taskstats fields when considering a thread group:
* - those that can be aggregated from each thread in the group (like CPU
@@ -181,7 +182,8 @@ static void send_cpu_listeners(struct sk_buff *skb,
* XXX_threadgroup() methods deal with the first type while XXX_add_tsk() with
* the second.
*/
-static void fill_threadgroup(struct taskstats *stats, struct task_struct *task)
+static void fill_threadgroup(struct taskstats *stats, struct task_struct *task,
+ bool tg_stats)
{
/*
* Each accounting subsystem adds calls to its functions to initialize
@@ -193,7 +195,7 @@ static void fill_threadgroup(struct taskstats *stats, struct task_struct *task)
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);
@@ -248,7 +250,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
memset(stats, 0, sizeof(*stats));
add_tsk(stats, tsk);
- fill_threadgroup(stats, tsk);
+ fill_threadgroup(stats, tsk, false);
/* Define err: label here if needed */
put_task_struct(tsk);
@@ -289,7 +291,7 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
add_tsk(stats, tsk);
while_each_thread(first, tsk);
- fill_threadgroup(stats, first->group_leader);
+ fill_threadgroup(stats, first->group_leader, true);
unlock_task_sighand(first, &flags);
rc = 0;
out:
@@ -545,7 +547,7 @@ void taskstats_exit(struct task_struct *tsk, int group_dead)
*/
memcpy(stats, tsk->signal->stats, sizeof(*stats));
- fill_threadgroup(stats, tsk->group_leader);
+ fill_threadgroup(stats, tsk->group_leader, true);
send:
send_cpu_listeners(rep_skb, listeners);
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 9541a1a..24056aa 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -41,7 +41,8 @@ static void fill_wall_times(struct taskstats *stats, struct task_struct *tsk)
* fill in basic accounting fields
*/
-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)
{
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
next prev parent reply other threads:[~2007-09-21 23:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 23:30 [PATCH 1/3] taskstats: separate PID/TGID stats producers to complete the TGID ones Guillaume Chazarain
2007-09-21 23:30 ` Guillaume Chazarain [this message]
2007-09-21 23:30 ` [PATCH 3/3] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code Guillaume Chazarain
2007-09-22 18:06 ` [PATCH 1/3] taskstats: separate PID/TGID stats producers to complete the TGID ones Balbir Singh
2007-09-26 17:32 ` Guillaume Chazarain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070921233049.21607.39807.stgit@localhost.localdomain \
--to=guichaz@yahoo.fr \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=jlan@cthulhu.engr.sgi.com \
--cc=jlim@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.