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 2/4] taskstats: Introduce __account_cdata() function
Date: Mon, 29 Nov 2010 17:42:39 +0100 [thread overview]
Message-ID: <20101129164435.239943381@linux.vnet.ibm.com> (raw)
In-Reply-To: <20101129164237.522034198@linux.vnet.ibm.com>
[-- Attachment #1: 02-taskstats-top-improve-ctime-add_cdata-func.patch --]
[-- Type: text/plain, Size: 5535 bytes --]
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Version 2
---------
* Move lock of siglock down in __account_cdata()
Description
-----------
This patch introduces the function __account_cdata() that does the
cummulative resource accounting for dead processes in sys_wait().
No functional changes are done. This patch is a preparation for
the full cdata accounting (full_cdata sysctl).
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
kernel/exit.c | 133 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 68 insertions(+), 65 deletions(-)
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -74,6 +74,72 @@ static void __unhash_process(struct task
list_del_rcu(&p->thread_group);
}
+static void __account_cdata(struct task_struct *p)
+{
+ struct cdata *cd, *pcd, *tcd;
+ unsigned long maxrss;
+ cputime_t tgutime, tgstime;
+
+ /*
+ * The resource counters for the group leader are in its
+ * own task_struct. Those for dead threads in the group
+ * are in its signal_struct, as are those for the child
+ * processes it has previously reaped. All these
+ * accumulate in the parent's signal_struct c* fields.
+ *
+ * We don't bother to take a lock here to protect these
+ * p->signal fields, because they are only touched by
+ * __exit_signal, which runs with tasklist_lock
+ * write-locked anyway, and so is excluded here. We do
+ * need to protect the access to parent->signal fields,
+ * as other threads in the parent group can be right
+ * here reaping other children at the same time.
+ *
+ * We use thread_group_times() to get times for the thread
+ * group, which consolidates times for all threads in the
+ * group including the group leader.
+ */
+ thread_group_times(p, &tgutime, &tgstime);
+ pcd = &p->real_parent->signal->cdata_wait;
+ tcd = &p->signal->cdata_threads;
+ cd = &p->signal->cdata_wait;
+
+ spin_lock_irq(&p->real_parent->sighand->siglock);
+ pcd->utime =
+ cputime_add(pcd->utime,
+ cputime_add(tgutime,
+ cd->utime));
+ pcd->stime =
+ cputime_add(pcd->stime,
+ cputime_add(tgstime,
+ cd->stime));
+ pcd->gtime =
+ cputime_add(pcd->gtime,
+ cputime_add(p->gtime,
+ cputime_add(tcd->gtime,
+ cd->gtime)));
+ pcd->min_flt +=
+ p->min_flt + tcd->min_flt + cd->min_flt;
+ pcd->maj_flt +=
+ p->maj_flt + tcd->maj_flt + cd->maj_flt;
+ pcd->nvcsw +=
+ p->nvcsw + tcd->nvcsw + cd->nvcsw;
+ pcd->nivcsw +=
+ p->nivcsw + tcd->nivcsw + cd->nivcsw;
+ pcd->inblock +=
+ task_io_get_inblock(p) +
+ tcd->inblock + cd->inblock;
+ pcd->oublock +=
+ task_io_get_oublock(p) +
+ tcd->oublock + cd->oublock;
+ maxrss = max(tcd->maxrss, cd->maxrss);
+ if (pcd->maxrss < maxrss)
+ pcd->maxrss = maxrss;
+ task_io_accounting_add(&p->real_parent->signal->ioac, &p->ioac);
+ task_io_accounting_add(&p->real_parent->signal->ioac, &p->signal->ioac);
+ spin_unlock_irq(&p->real_parent->sighand->siglock);
+}
+
/*
* This function expects the tasklist_lock write-locked.
*/
@@ -1226,71 +1292,8 @@ static int wait_task_zombie(struct wait_
* It can be ptraced but not reparented, check
* !task_detached() to filter out sub-threads.
*/
- if (likely(!traced) && likely(!task_detached(p))) {
- struct cdata *cd, *pcd, *tcd;
- unsigned long maxrss;
- cputime_t tgutime, tgstime;
-
- /*
- * The resource counters for the group leader are in its
- * own task_struct. Those for dead threads in the group
- * are in its signal_struct, as are those for the child
- * processes it has previously reaped. All these
- * accumulate in the parent's signal_struct c* fields.
- *
- * We don't bother to take a lock here to protect these
- * p->signal fields, because they are only touched by
- * __exit_signal, which runs with tasklist_lock
- * write-locked anyway, and so is excluded here. We do
- * need to protect the access to parent->signal fields,
- * as other threads in the parent group can be right
- * here reaping other children at the same time.
- *
- * We use thread_group_times() to get times for the thread
- * group, which consolidates times for all threads in the
- * group including the group leader.
- */
- thread_group_times(p, &tgutime, &tgstime);
- spin_lock_irq(&p->real_parent->sighand->siglock);
- pcd = &p->real_parent->signal->cdata_wait;
- tcd = &p->signal->cdata_threads;
- cd = &p->signal->cdata_wait;
-
- pcd->utime =
- cputime_add(pcd->utime,
- cputime_add(tgutime,
- cd->utime));
- pcd->stime =
- cputime_add(pcd->stime,
- cputime_add(tgstime,
- cd->stime));
- pcd->gtime =
- cputime_add(pcd->gtime,
- cputime_add(p->gtime,
- cputime_add(tcd->gtime,
- cd->gtime)));
- pcd->min_flt +=
- p->min_flt + tcd->min_flt + cd->min_flt;
- pcd->maj_flt +=
- p->maj_flt + tcd->maj_flt + cd->maj_flt;
- pcd->nvcsw +=
- p->nvcsw + tcd->nvcsw + cd->nvcsw;
- pcd->nivcsw +=
- p->nivcsw + tcd->nivcsw + cd->nivcsw;
- pcd->inblock +=
- task_io_get_inblock(p) +
- tcd->inblock + cd->inblock;
- pcd->oublock +=
- task_io_get_oublock(p) +
- tcd->oublock + cd->oublock;
- maxrss = max(tcd->maxrss, cd->maxrss);
- if (pcd->maxrss < maxrss)
- pcd->maxrss = maxrss;
- task_io_accounting_add(&p->real_parent->signal->ioac, &p->ioac);
- task_io_accounting_add(&p->real_parent->signal->ioac,
- &p->signal->ioac);
- spin_unlock_irq(&p->real_parent->sighand->siglock);
- }
+ if (likely(!traced) && likely(!task_detached(p)))
+ __account_cdata(p);
/*
* Now we are sure this task is interesting, and no other
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 ` Michael Holzheu [this message]
2010-11-29 16:42 ` [patch v2 3/4] taskstats: Introduce kernel.full_cdata sysctl Michael Holzheu
2010-11-29 16:42 ` [patch v2 4/4] taskstats: Export "cdata_wait" CPU times with taskstats Michael Holzheu
2010-12-01 18:51 ` 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.239943381@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
Powered by JetHome