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 2/8] taskstats: split the basic accounting fields
Date: Wed, 26 Sep 2007 18:28:05 +0200 [thread overview]
Message-ID: <20070926162805.29434.9637.stgit@cheypa.inria.fr> (raw)
In-Reply-To: <20070926162800.29434.67786.stgit@cheypa.inria.fr>
Split the basic accounting taskstats fields into the threadgroup specific ones
and the thread specific ones. This should have no effect on the execution.
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/tsacct.c | 53 +++++++++++++++++++++++++++++++++++++----------------
1 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 4ab1b58..d32378f 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -25,13 +25,11 @@
/*
* fill in basic accounting fields
*/
-void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
+static void fill_wall_times(struct taskstats *stats, struct task_struct *tsk)
{
struct timespec uptime, ts;
s64 ac_etime;
- BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
-
/* calculate task elapsed time in timespec */
do_posix_clock_monotonic_gettime(&uptime);
ts = timespec_sub(uptime, tsk->start_time);
@@ -40,17 +38,47 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
do_div(ac_etime, NSEC_PER_USEC);
stats->ac_etime = ac_etime;
stats->ac_btime = get_seconds() - ts.tv_sec;
- if (thread_group_leader(tsk)) {
- stats->ac_exitcode = tsk->exit_code;
- if (tsk->flags & PF_FORKNOEXEC)
- stats->ac_flag |= AFORK;
- }
+}
+
+/*
+ * Later on, XXX_add_tsk() will need to be called after XXX_fill_threadgroup(),
+ * so put the functions in this order
+ */
+static void bacct_fill_threadgroup(struct taskstats *stats,
+ struct task_struct *tsk);
+
+void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
+{
if (tsk->flags & PF_SUPERPRIV)
stats->ac_flag |= ASU;
if (tsk->flags & PF_DUMPCORE)
stats->ac_flag |= ACORE;
if (tsk->flags & PF_SIGNALED)
stats->ac_flag |= AXSIG;
+
+ stats->ac_utime += cputime_to_msecs(tsk->utime) * USEC_PER_MSEC;
+ stats->ac_stime += cputime_to_msecs(tsk->stime) * USEC_PER_MSEC;
+ stats->ac_utimescaled +=
+ cputime_to_msecs(tsk->utimescaled) * USEC_PER_MSEC;
+ stats->ac_stimescaled +=
+ cputime_to_msecs(tsk->stimescaled) * USEC_PER_MSEC;
+ stats->ac_minflt += tsk->min_flt;
+ stats->ac_majflt += tsk->maj_flt;
+
+ bacct_fill_threadgroup(stats, tsk);
+}
+
+static void bacct_fill_threadgroup(struct taskstats *stats,
+ struct task_struct *tsk)
+{
+ 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;
+ }
+
stats->ac_nice = task_nice(tsk);
stats->ac_sched = tsk->policy;
stats->ac_uid = tsk->uid;
@@ -60,15 +88,8 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
stats->ac_ppid = pid_alive(tsk) ?
rcu_dereference(tsk->real_parent)->tgid : 0;
rcu_read_unlock();
- stats->ac_utime = cputime_to_msecs(tsk->utime) * USEC_PER_MSEC;
- stats->ac_stime = cputime_to_msecs(tsk->stime) * USEC_PER_MSEC;
- stats->ac_utimescaled =
- cputime_to_msecs(tsk->utimescaled) * USEC_PER_MSEC;
- stats->ac_stimescaled =
- cputime_to_msecs(tsk->stimescaled) * USEC_PER_MSEC;
- stats->ac_minflt = tsk->min_flt;
- stats->ac_majflt = tsk->maj_flt;
+ BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm));
}
next prev parent reply other threads:[~2007-09-26 16:37 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 ` Guillaume Chazarain [this message]
2007-09-26 16:28 ` [PATCH 3/8] taskstats: split the extended accounting fields 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 ` [PATCH 7/8] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code Guillaume Chazarain
2007-09-26 20:47 ` 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 2/8] taskstats: split the basic accounting fields 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=20070926162805.29434.9637.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
Powered by JetHome