All of lore.kernel.org
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Frans Pop <elendil@planet.nl>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Chuck Ebbert <cebbert@redhat.com>, Greg KH <greg@kroah.com>,
	stable@kernel.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [stable] 2.6.23 regression: top displaying 9999% CPU usage
Date: Tue, 30 Oct 2007 03:13:22 +0530	[thread overview]
Message-ID: <20071029214321.GA25669@linux.vnet.ibm.com> (raw)
In-Reply-To: <20071029200425.GA830@elte.hu>

On Mon, Oct 29, 2007 at 09:04:25PM +0100, Ingo Molnar wrote:
> 
> * Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> 
> > We'll I initially thought of it and then I remembered that the 
> > regression occurs only when the accounting itself is inaccurate. I am 
> > tempted to ack the removal, but I would like to get input from others. 
> > Meanwhile, I'll try and see if I can fix the problem
> 
> i've got a patch from Peter queued up. (see below) This should fix the 
> main issue.
> 
> 	Ingo
>

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

  parent reply	other threads:[~2007-10-29 22:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 20:31 2.6.23 regression: top displaying 9999% CPU usage Frans Pop
2007-10-12 21:22 ` [stable] " Greg KH
2007-10-13  7:53   ` Frans Pop
2007-10-14 20:36     ` Christian Borntraeger
2007-10-16  8:29       ` Christian Borntraeger
2007-10-16  9:30         ` Balbir Singh
2007-10-16 10:11           ` Frans Pop
2007-10-16 10:38             ` Balbir Singh
2007-10-16 10:34           ` Christian Borntraeger
2007-10-16 12:59             ` Balbir Singh
2007-10-29 12:05               ` Frans Pop
2007-10-29 12:31                 ` Balbir Singh
2007-10-29 20:04                   ` Ingo Molnar
2007-10-29 20:33                     ` Christian Borntraeger
2007-10-29 20:41                       ` Ingo Molnar
2007-10-29 21:11                         ` Peter Zijlstra
2007-10-29 21:22                         ` Frans Pop
2007-10-29 21:43                     ` Balbir Singh [this message]
2007-10-29 23:19                       ` Frans Pop
2007-10-29 23:22                         ` Ingo Molnar
2007-10-30 20:22                           ` Otavio Salvador
2007-10-29 23:24                         ` Balbir Singh
2007-10-30  5:56                       ` Christian Borntraeger
2007-10-30  6:00                         ` Balbir Singh

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=20071029214321.GA25669@linux.vnet.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=borntraeger@de.ibm.com \
    --cc=cebbert@redhat.com \
    --cc=elendil@planet.nl \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=stable@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.