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;
-
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| James Bottomley | Re: Announce: Linux-next (Or Andrew's dream :-)) |
| David Woodhouse | Re: [PATCH 2/3] firmware: convert korg1212 driver to use firmware loader exclusively |
| Kamalesh Babulal | Re: 2.6.24-rc8-mm1 Build Failure on S390x |
git: | |
| David Miller | [GIT]: Networking |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
