* [PATCH] cputime: fix account_steal_time.
@ 2005-01-14 14:41 Martin Schwidefsky
0 siblings, 0 replies; only message in thread
From: Martin Schwidefsky @ 2005-01-14 14:41 UTC (permalink / raw)
To: akpm, linux-kernel
Hi Andrew,
after the cputime patches have hit BitKeeper, Uli had a look at them and
being Uli he found a bug. Actually three bugs but they are all in the
same function. The bugs are only relevant for an architecture that uses
account_steal_time which is currently s390 only.
blue skies,
Martin.
---
[PATCH] cputime: fix account_steal_time.
From: Ulrich Weigand <uweigand@de.ibm.com>
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
account_steal_time called for idle doesn't work correctly:
1) steal time while idle needs to be added to the system time of idle
to get correct uptime numbers
3) if there is an i/o request outstanding the steal time should be
added to iowait, even if the hypervisor scheduled another virtual
cpu since we are still waiting for i/o.
2) steal time while idle without an i/o request outstanding has to
be added to cpustat->idle and not to cpustat->system.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
diffstat:
kernel/sched.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff -urN linux-2.6/kernel/sched.c linux-2.6-patched/kernel/sched.c
--- linux-2.6/kernel/sched.c 2005-01-14 15:02:43.000000000 +0100
+++ linux-2.6-patched/kernel/sched.c 2005-01-14 15:02:52.000000000 +0100
@@ -2383,13 +2383,17 @@
void account_steal_time(struct task_struct *p, cputime_t steal)
{
struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
- cputime64_t steal64 = cputime_to_cputime64(steal);
+ cputime64_t tmp = cputime_to_cputime64(steal);
runqueue_t *rq = this_rq();
- if (p == rq->idle)
- cpustat->system = cputime64_add(cpustat->system, steal64);
- else
- cpustat->steal = cputime64_add(cpustat->steal, steal64);
+ if (p == rq->idle) {
+ p->stime = cputime_add(p->stime, steal);
+ if (atomic_read(&rq->nr_iowait) > 0)
+ cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
+ else
+ cpustat->idle = cputime64_add(cpustat->idle, tmp);
+ } else
+ cpustat->steal = cputime64_add(cpustat->steal, tmp);
}
/*
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-01-14 14:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-14 14:41 [PATCH] cputime: fix account_steal_time Martin Schwidefsky
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®