From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>,
Shailabh Nagar <nagar1234@in.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
John stultz <johnstul@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Roland McGrath <roland@redhat.com>,
Valdis.Kletnieks@vt.edu
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [patch v2 4/4] taskstats: Export "cdata_wait" CPU times with taskstats
Date: Mon, 29 Nov 2010 17:42:41 +0100 [thread overview]
Message-ID: <20101129164435.903722027@linux.vnet.ibm.com> (raw)
In-Reply-To: 20101129164237.522034198@linux.vnet.ibm.com
[-- Attachment #1: 04-taskstats-top-improve-ctime-taskstats.patch --]
[-- Type: text/plain, Size: 2177 bytes --]
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Version 2
---------
* Use thread_group_leader() instead of (tsk->pid == tsk->tgid)
* Use cdata_wait instead of cdata_acct
* I left the struct signal locking in the patch, because I think
that in order to get consistent data this is necessary. See also
do_task_stat() in fs/proc/array.c. One problem is that we
report wrong values (zero) for cdata, if lock_task_sighand()
fails. This will be the same behavior as for /proc/<pid>/stat.
But maybe we should somehow return to userspace that the
information is not correct. Any ideas?
Description
-----------
With this patch the cumulative CPU time is added to "struct taskstats".
The CPU time is only returned for the thread group leader.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
include/linux/taskstats.h | 7 ++++++-
kernel/tsacct.c | 7 +++++++
2 files changed, 13 insertions(+), 1 deletion(-)
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -33,7 +33,7 @@
*/
-#define TASKSTATS_VERSION 7
+#define TASKSTATS_VERSION 8
#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
* in linux/sched.h */
@@ -163,6 +163,11 @@ struct taskstats {
/* Delay waiting for memory reclaim */
__u64 freepages_count;
__u64 freepages_delay_total;
+ /* version 7 ends here */
+
+ /* Cumulative CPU time of dead children */
+ __u64 ac_cutime; /* User CPU time [usec] */
+ __u64 ac_cstime; /* System CPU time [usec] */
};
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -30,6 +30,7 @@ void bacct_add_tsk(struct taskstats *sta
{
const struct cred *tcred;
struct timespec uptime, ts;
+ unsigned long flags;
u64 ac_etime;
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
@@ -71,6 +72,12 @@ void bacct_add_tsk(struct taskstats *sta
stats->ac_majflt = tsk->maj_flt;
strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm));
+ if (thread_group_leader(tsk) && lock_task_sighand(tsk, &flags)) {
+ struct cdata *cd = &tsk->signal->cdata_wait;
+ stats->ac_cutime = cputime_to_usecs(cd->utime);
+ stats->ac_cstime = cputime_to_usecs(cd->stime);
+ unlock_task_sighand(tsk, &flags);
+ }
}
next prev parent reply other threads:[~2010-11-29 16:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-29 16:42 [patch v2 0/4] taskstats: Improve cumulative time accounting Michael Holzheu
2010-11-29 16:42 ` [patch v2 1/4] taskstats: Introduce "struct cdata" Michael Holzheu
2010-11-29 16:42 ` [patch v2 2/4] taskstats: Introduce __account_cdata() function Michael Holzheu
2010-11-29 16:42 ` [patch v2 3/4] taskstats: Introduce kernel.full_cdata sysctl Michael Holzheu
2010-11-29 16:42 ` Michael Holzheu [this message]
2010-12-01 18:51 ` [patch v2 4/4] taskstats: Export "cdata_wait" CPU times with taskstats Oleg Nesterov
2010-12-02 16:34 ` Michael Holzheu
2010-12-06 9:06 ` Balbir Singh
2010-12-08 20:23 ` Oleg Nesterov
2010-12-10 13:26 ` Michael Holzheu
[not found] ` <20101211173931.GA8084@redhat.com>
2010-12-13 13:05 ` Michael Holzheu
2010-12-13 13:20 ` Michael Holzheu
2010-12-13 14:33 ` Oleg Nesterov
2010-12-13 16:42 ` Michael Holzheu
2010-12-03 7:33 ` Balbir Singh
2010-12-06 12:37 ` Michael Holzheu
2010-12-06 15:15 ` Balbir Singh
2010-12-07 10:45 ` Michael Holzheu
2010-12-08 20:39 ` Oleg Nesterov
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=20101129164435.903722027@linux.vnet.ibm.com \
--to=holzheu@linux.vnet.ibm.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nagar1234@in.ibm.com \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).