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 3/3] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code
Date: Sat, 22 Sep 2007 01:30:55 +0200 [thread overview]
Message-ID: <20070921233055.21607.12387.stgit@localhost.localdomain> (raw)
In-Reply-To: <20070921233038.21607.51089.stgit@localhost.localdomain>
Threads also have an exit code on their own, so report it in
TASKSTATS_CMD_ATTR_PID.
For TASKSTATS_CMD_ATTR_TGID, instead of relying only on the exit code of the
leader, we use task->signal->group_exit_code if not null as suggested by
Oleg Nesterov.
Also, document that as of this patch, fill_threadgroup() must be called after
add_tsk() as it may overwrite some stats.
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>
---
kernel/taskstats.c | 3 +++
kernel/tsacct.c | 12 +++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 42d3110..24d7f62 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -181,6 +181,9 @@ static void send_cpu_listeners(struct sk_buff *skb,
* memory usage), so are taken from the group leader.
* XXX_threadgroup() methods deal with the first type while XXX_add_tsk() with
* the second.
+ *
+ * fill_threadgroup() may overwrite stats from add_tsk(), so it must be called
+ * after add_tsk().
*/
static void fill_threadgroup(struct taskstats *stats, struct task_struct *task,
bool tg_stats)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 24056aa..526b134 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -44,6 +44,8 @@ static void fill_wall_times(struct taskstats *stats, struct task_struct *tsk)
void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task,
bool tg_stats)
{
+ int group_exit_code;
+
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
rcu_read_lock();
@@ -53,11 +55,11 @@ void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task,
fill_wall_times(stats, task);
- if (thread_group_leader(task)) {
- stats->ac_exitcode = task->exit_code;
- if (task->flags & PF_FORKNOEXEC)
- stats->ac_flag |= AFORK;
- }
+ if (thread_group_leader(task) && (task->flags & PF_FORKNOEXEC))
+ stats->ac_flag |= AFORK;
+
+ group_exit_code = tg_stats ? task->signal->group_exit_code : 0;
+ stats->ac_exitcode = group_exit_code ? : task->exit_code;
stats->ac_nice = task_nice(task);
stats->ac_sched = task->policy;
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 ` [PATCH 2/3] taskstats: tell fill_thread_group() whether it replies with PID or TGID stats Guillaume Chazarain
2007-09-21 23:30 ` Guillaume Chazarain [this message]
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=20070921233055.21607.12387.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox