Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: Frans Pop <elendil@...>, Christian Borntraeger <borntraeger@...>, Chuck Ebbert <cebbert@...>, Greg KH <greg@...>, <stable@...>, <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Monday, October 29, 2007 - 5:43 pm

On Mon, Oct 29, 2007 at 09:04:25PM +0100, Ingo Molnar wrote:

We'll also need this additional patch (untested), but in the long run
I think the approach needs to be

1. Update stime and utime at the time of context switching -- keep it
   in sync with p->sum_exec_runtime
2. Keep track of system/user context at system call entry points

 
Extend Peter's patch to fix accounting issues.

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
---

 fs/proc/array.c       |    3 ++-
 include/linux/sched.h |    2 +-
 kernel/fork.c         |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff -puN fs/proc/array.c~fix-accounting-issue-extended fs/proc/array.c
--- 2.6.24-rc1/fs/proc/array.c~fix-accounting-issue-extended	2007-10-30 03:08:18.000000000 +0530
+++ 2.6.24-rc1-balbir/fs/proc/array.c	2007-10-30 03:09:46.000000000 +0530
@@ -374,7 +374,8 @@ static cputime_t task_stime(struct task_
 	stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
 			cputime_to_clock_t(task_utime(p));
 
-	return clock_t_to_cputime(stime);
+	p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime));
+	return p->prev_stime;
 }
 #endif
 
diff -puN include/linux/sched.h~fix-accounting-issue-extended include/linux/sched.h
--- 2.6.24-rc1/include/linux/sched.h~fix-accounting-issue-extended	2007-10-30 03:08:18.000000000 +0530
+++ 2.6.24-rc1-balbir/include/linux/sched.h	2007-10-30 03:08:32.000000000 +0530
@@ -1004,7 +1004,7 @@ struct task_struct {
 	unsigned int rt_priority;
 	cputime_t utime, stime, utimescaled, stimescaled;
 	cputime_t gtime;
-	cputime_t prev_utime;
+	cputime_t prev_utime, prev_stime;
 	unsigned long nvcsw, nivcsw; /* context switch counts */
 	struct timespec start_time; 		/* monotonic time */
 	struct timespec real_start_time;	/* boot based time */
diff -puN kernel/fork.c~fix-accounting-issue-extended kernel/fork.c
--- 2.6.24-rc1/kernel/fork.c~fix-accounting-issue-extended	2007-10-30 03:08:18.000000000 +0530
+++ 2.6.24-rc1-balbir/kernel/fork.c	2007-10-30 03:08:42.000000000 +0530
@@ -1057,6 +1057,7 @@ static struct task_struct *copy_process(
 	p->utimescaled = cputime_zero;
 	p->stimescaled = cputime_zero;
 	p->prev_utime = cputime_zero;
+	p->prev_stime = cputime_zero;
 
 #ifdef CONFIG_TASK_XACCT
 	p->rchar = 0;		/* I/O counter: bytes read */
_

-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.23 regression: top displaying 9999% CPU usage, Frans Pop, (Fri Oct 12, 4:31 pm)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Christian Borntraeger, (Sun Oct 14, 4:36 pm)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Christian Borntraeger, (Tue Oct 16, 4:29 am)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Christian Borntraeger, (Tue Oct 16, 6:34 am)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Balbir Singh, (Mon Oct 29, 5:43 pm)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Christian Borntraeger, (Tue Oct 30, 1:56 am)
Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage, Christian Borntraeger, (Mon Oct 29, 4:33 pm)