public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] dubious process system time.
@ 2006-08-24 12:18 Martin Schwidefsky
  2006-08-24 12:32 ` Andi Kleen
  2006-08-24 23:40 ` Paul Mackerras
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Schwidefsky @ 2006-08-24 12:18 UTC (permalink / raw)
  To: linux-kernel

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

[patch] dubious process system time.

The system time that is accounted to a process includes the time spent
in three different contexts: normal system time, hardirq time and
softirq time. To account hardirq time and sortirq time to a process
seems wrong, because the process could just happen to run when the
interrupt arrives that was caused by an i/o for a completly different
process. And the sum over stime and cstime of all processes won't
match cputstat->system either. 
The following patch changes the accounting of system time so that
hardirq and softirq time are not accounted to a process anymore.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 kernel/sched.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff -urpN linux-2.6/kernel/sched.c linux-2.6-patched/kernel/sched.c
--- linux-2.6/kernel/sched.c	2006-08-01 10:09:55.000000000 +0200
+++ linux-2.6-patched/kernel/sched.c	2006-08-24 13:42:40.000000000 +0200
@@ -2939,17 +2939,16 @@ void account_system_time(struct task_str
 	struct rq *rq = this_rq();
 	cputime64_t tmp;
 
-	p->stime = cputime_add(p->stime, cputime);
-
 	/* Add system time to cpustat. */
 	tmp = cputime_to_cputime64(cputime);
 	if (hardirq_count() - hardirq_offset)
 		cpustat->irq = cputime64_add(cpustat->irq, tmp);
 	else if (softirq_count())
 		cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
-	else if (p != rq->idle)
+	else if (p != rq->idle) {
+		p->stime = cputime_add(p->stime, cputime);
 		cpustat->system = cputime64_add(cpustat->system, tmp);
-	else if (atomic_read(&rq->nr_iowait) > 0)
+	} else if (atomic_read(&rq->nr_iowait) > 0)
 		cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
 	else
 		cpustat->idle = cputime64_add(cpustat->idle, tmp);

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-08-25 12:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-24 12:18 [patch] dubious process system time Martin Schwidefsky
2006-08-24 12:32 ` Andi Kleen
2006-08-24 13:28   ` Martin Schwidefsky
2006-08-24 15:18     ` Andi Kleen
2006-08-24 16:02       ` Martin Schwidefsky
2006-08-25 10:12         ` Helge Hafting
2006-08-25 10:29           ` Martin Schwidefsky
2006-08-25 12:58             ` Paul Mackerras
2006-08-24 23:40 ` Paul Mackerras
2006-08-25  8:18   ` Martin Schwidefsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox