[PATCH for testing] Re: Decreasing stime running confuses top

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Chuck Ebbert <cebbert@...>
Cc: Luca Tettamanti <kronos.it@...>, Frans Pop <elendil@...>, Willy Tarreau <w@...>, LKML <linux-kernel@...>, Ilpo <ilpo.jarvinen@...>, Alexander E. Patrakov <patrakov@...>, Ingo Molnar <mingo@...>
Date: Thursday, October 4, 2007 - 5:10 pm

Am Donnerstag, 4. Oktober 2007 schrieb Chuck Ebbert:

Short history what I know about this file:
after 2.6.22 the accounting was changes to use sched_clock and to use stime 
and utime only for the split. This is where task_utime and task_stime were 
introduced. See the code in 2.6.23-rc1.
Unfortunately this broke the accouting on s390 which already has precise 
numbers in utime and stime. So the code was partially reverted to use stime 
and utime again where appropriate, which are of type  cputime_t. 


correct.


These conversions can reduce the accuracy to jiffie resolution, but should not
make the value non-monotonic. I dont think that here is the problem. 

But: it seems that p->se.sum_exec_runtime can change indeed. That would 
explain stime going backward, if sum_exec_runtime was increases in the middle 
of the calculation. 
The logic of task_stime and task_utime was introduced by 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b27f03d4bd...


Frans can you test this patch if this makes stime and utime monotic again?

It basically reverts the rest of  b27f03d4bdc145a09fb7b0c0e004b29f1ee555fa and 
should restore the 2.6.22 behavior. The process time is used from tasks utime 
and stime instead of the scheduler clock. That means, in general after a long 
period of time, it is less accurate than the current time and behaves like 
2.6.22.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 array.c |   37 -------------------------------------
 1 file changed, 37 deletions(-)


diff --git a/fs/proc/array.c b/fs/proc/array.c
index ee4814d..e42c76e 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -323,7 +323,6 @@ int proc_pid_status(struct task_struct *task, char 
*buffer)
 /*
  * Use precise platform statistics if available:
  */
-#ifdef CONFIG_VIRT_CPU_ACCOUNTING
 static cputime_t task_utime(struct task_struct *p)
 {
 	return p->utime;
@@ -333,42 +332,6 @@ static cputime_t task_stime(struct task_struct *p)
 {
 	return p->stime;
 }
-#else
-static cputime_t task_utime(struct task_struct *p)
-{
-	clock_t utime = cputime_to_clock_t(p->utime),
-		total = utime + cputime_to_clock_t(p->stime);
-	u64 temp;
-
-	/*
-	 * Use CFS's precise accounting:
-	 */
-	temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime);
-
-	if (total) {
-		temp *= utime;
-		do_div(temp, total);
-	}
-	utime = (clock_t)temp;
-
-	return clock_t_to_cputime(utime);
-}
-
-static cputime_t task_stime(struct task_struct *p)
-{
-	clock_t stime;
-
-	/*
-	 * Use CFS's precise accounting. (we subtract utime from
-	 * the total, to make sure the total observed by userspace
-	 * grows monotonically - apps rely on that):
-	 */
-	stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
-			cputime_to_clock_t(task_utime(p));
-
-	return clock_t_to_cputime(stime);
-}
-#endif
 
 static int do_task_stat(struct task_struct *task, char *buffer, int whole)
 {
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
top displaying 9999% CPU usage, Frans Pop, (Wed Oct 3, 8:33 am)
Re: top displaying 9999% CPU usage, Alexander E. Patrakov, (Wed Oct 3, 9:03 am)
Re: top displaying 9999% CPU usage, Frans Pop, (Wed Oct 3, 10:04 am)
Re: top displaying 9999% CPU usage, Ilpo Järvinen, (Wed Oct 3, 10:43 am)
Re: top displaying 9999% CPU usage, Ilpo Järvinen, (Wed Oct 3, 10:51 am)
Re: Decreasing stime running confuses top, Chuck Ebbert, (Thu Oct 4, 3:32 pm)
Re: Decreasing stime running confuses top, Christian Borntraeger, (Thu Oct 4, 4:00 pm)
Re: Decreasing stime running confuses top, Chuck Ebbert, (Thu Oct 4, 4:21 pm)
[PATCH for testing] Re: Decreasing stime running confuses top, Christian Borntraeger, (Thu Oct 4, 5:10 pm)
Re: [PATCH for testing] Re: Decreasing stime running confuse..., Christian Borntraeger, (Mon Oct 8, 12:49 pm)
Re: [PATCH for testing] Re: Decreasing stime running confuse..., Christian Borntraeger, (Thu Oct 4, 6:31 pm)
Re: top displaying 9999% CPU usage, Jan Engelhardt, (Wed Oct 3, 8:52 am)