mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guillaume Chazarain <guichaz@yahoo.fr>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Guillaume Chazarain <guichaz@yahoo.fr>
Subject: [PATCH 7/8] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code
Date: Wed, 26 Sep 2007 18:28:31 +0200	[thread overview]
Message-ID: <20070926162831.29434.29622.stgit@cheypa.inria.fr> (raw)
In-Reply-To: <20070926162800.29434.67786.stgit@cheypa.inria.fr>

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_stats() must be called
after add_tsk_stats() 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 |    2 ++
 kernel/tsacct.c    |   12 +++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 59fe1d8..938c0b0 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -208,6 +208,8 @@ static void add_tsk_stats(struct taskstats *stats, struct task_struct *task)
  *
  * Will be called on the thread group leader if requesting stats for the whole
  * thread group.
+ * fill_threadgroup_stats() may overwrite stats from add_tsk_stats(), so it
+ * must be called after add_tsk_stats().
  */
 static void fill_threadgroup_stats(struct taskstats *stats,
 				   struct task_struct *task, bool tg_stats)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 8c2f470..e83f53b 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -65,13 +65,15 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
 void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *tsk,
 			    bool tg_stats)
 {
+	int group_exit_code;
+
 	fill_wall_times(stats, tsk);
 
-	if (thread_group_leader(tsk)) {
-		stats->ac_exitcode = tsk->exit_code;
-		if (tsk->flags & PF_FORKNOEXEC)
-			stats->ac_flag |= AFORK;
-	}
+	if (thread_group_leader(tsk) && ((tsk->flags & PF_FORKNOEXEC)))
+		stats->ac_flag |= AFORK;
+
+	group_exit_code = tg_stats ? tsk->signal->group_exit_code : 0;
+	stats->ac_exitcode = group_exit_code ? : tsk->exit_code;
 
 	stats->ac_nice	 = task_nice(tsk);
 	stats->ac_sched	 = tsk->policy;

  parent reply	other threads:[~2007-09-26 16:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 16:28 [PATCH 1/8] taskstats: fix indentation of long argument lists Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 2/8] taskstats: split the basic accounting fields Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 3/8] taskstats: split the extended " Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 4/8] taskstats: separate PID/TGID stats producers to complete the TGID ones Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 5/8] taskstats: factor out version and context switch accounting Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 6/8] taskstats: tell fill_threadgroup_stats() if it replies with PID or TGID stats Guillaume Chazarain
2007-09-26 16:28 ` Guillaume Chazarain [this message]
2007-09-26 20:47   ` [PATCH 7/8] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code roel
2007-09-26 20:55     ` Guillaume Chazarain
2007-09-26 16:28 ` [PATCH 8/8] taskstats: avoid breaking binary compatibility between taskstats v6 and before Guillaume Chazarain
2007-09-26 17:08 [PATCH 1/8] taskstats: fix indentation of long argument lists Guillaume Chazarain
2007-09-26 17:08 ` [PATCH 7/8] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code 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=20070926162831.29434.29622.stgit@cheypa.inria.fr \
    --to=guichaz@yahoo.fr \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®