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: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Galbraith <efault@gmx.de>,
	Arjan van de Ven <arjan@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	pranith-kumar_d@mentorg.com, Andi Kleen <andi@firstfloor.org>
Subject: Re: [patch] CFS scheduler, -v14
Date: Tue, 29 May 2007 15:53:56 +0530	[thread overview]
Message-ID: <20070529102356.GB12620@linux.vnet.ibm.com> (raw)
In-Reply-To: <20070528110748.GG25331@elte.hu>

On Mon, May 28, 2007 at 01:07:48PM +0200, Ingo Molnar wrote:
> 
> * Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> 
> > Ingo Molnar wrote:
> > > i found an accounting bug in this: it didnt sum up threads correctly. 
> > > The patch below fixes this. The stime == 0 problem is still there 
> > > though.
> > > 
> > > 	Ingo
> > > 
> > 
> > Thanks! I'll test the code on Monday. I do not understand the 
> > sysctl_sched_smoothing functionality, so I do not understand its 
> > impact on accounting. I'll take a look more closely
> 
> basically sysctl_sched_smoothing is more of a 'experimental features 
> flag' kind of thing. I'll remove it soon, you should only need to 
> concentrate on the functionality that it enables by default.
> 
> 	Ingo

Hi, Ingo,

I hope this patch addresses the stime == 0 problem.

This patch improves accounting of the CFS scheduler. We have the executed
run time in sum_exec_runtime field of the task. This patch splits the
sum_exec_runtime in the ratio of task->utime and task->stime to obtain
the user and system time of the task. 

TODO's:

1. Migrate getrusage() to use sum_exec_runtime so that the output in /proc
   is consistent with the data by running time(1).


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

 fs/proc/array.c |   27 ++++++++++++++++++++++++---
 linux/sched.h   |    0 
 2 files changed, 24 insertions(+), 3 deletions(-)

diff -puN fs/proc/array.c~cfs-distribute-accounting fs/proc/array.c
--- linux-2.6.22-rc2/fs/proc/array.c~cfs-distribute-accounting	2007-05-29 13:47:47.000000000 +0530
+++ linux-2.6.22-rc2-balbir/fs/proc/array.c	2007-05-29 15:35:22.000000000 +0530
@@ -332,7 +332,6 @@ static clock_t task_stime(struct task_st
 	return cputime_to_clock_t(p->stime);
 }
 
-
 static int do_task_stat(struct task_struct *task, char * buffer, int whole)
 {
 	unsigned long vsize, eip, esp, wchan = ~0UL;
@@ -400,8 +399,13 @@ static int do_task_stat(struct task_stru
 
 			min_flt += sig->min_flt;
 			maj_flt += sig->maj_flt;
-			utime += cputime_to_clock_t(sig->utime);
-			stime += cputime_to_clock_t(sig->stime);
+			if (!has_rt_policy(t))
+				utime += nsec_to_clock_t(
+						sig->sum_sched_runtime);
+			else {
+				utime += cputime_to_clock_t(sig->utime);
+				stime += cputime_to_clock_t(sig->stime);
+			}
 		}
 
 		sid = signal_session(sig);
@@ -421,6 +425,23 @@ static int do_task_stat(struct task_stru
 		stime = task_stime(task);
 	}
 
+	if (!has_rt_policy(task)) {
+		clock_t sum_us_time = utime + stime;
+		clock_t tu_time = cputime_to_clock_t(task->utime);
+		clock_t ts_time = cputime_to_clock_t(task->stime);
+		clock_t total_time = utime;
+
+		/*
+		 * Split up sched_exec_time according to the utime and
+		 * stime ratio. At this point utime contains the summed
+		 * sched_exec_runtime and stime is zero
+		 */
+		if (sum_us_time) {
+			utime = ((tu_time * total_time) / sum_us_time);
+			stime = ((ts_time * total_time) / sum_us_time);
+		}
+	}
+
 	/* scale priority and nice values from timeslices to -20..20 */
 	/* to make it look like a "normal" Unix priority/nice value  */
 	priority = task_prio(task);
diff -puN kernel/sys.c~cfs-distribute-accounting kernel/sys.c
diff -puN include/linux/sched.h~cfs-distribute-accounting include/linux/sched.h
_

-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

  reply	other threads:[~2007-05-29 10:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23 12:06 [patch] CFS scheduler, -v14 Ingo Molnar
2007-05-23 19:39 ` Nicolas Mailhot
2007-05-23 19:57   ` Ingo Molnar
2007-05-23 20:02     ` Nicolas Mailhot
2007-05-24  6:42 ` Balbir Singh
2007-05-24  8:09   ` Ingo Molnar
2007-05-24  9:19     ` Balbir Singh
2007-05-24 17:25     ` Jeremy Fitzhardinge
2007-05-24 20:59       ` Ingo Molnar
2007-05-24 22:43         ` Jeremy Fitzhardinge
2007-05-25 12:46     ` Ingo Molnar
2007-05-25 16:45       ` Balbir Singh
2007-05-28 11:07         ` Ingo Molnar
2007-05-29 10:23           ` Balbir Singh [this message]
2007-06-05  7:57             ` Ingo Molnar
2007-05-29 10:19       ` Balbir Singh
2007-05-26 14:58 ` S.Çağlar Onur
2007-05-26 15:08   ` S.Çağlar Onur
2007-06-01 13:35   ` S.Çağlar Onur
2007-06-01 15:31     ` Linus Torvalds
2007-06-07 22:29       ` S.Çağlar Onur
2007-06-01 15:37     ` [OT] " Andreas Mohr
2007-05-27  2:49 ` Li Yu
2007-05-29  6:15   ` Ingo Molnar
2007-05-29  8:07     ` Ingo Molnar
2007-05-31  9:45       ` Li Yu
2007-05-31  9:53         ` Ingo Molnar
2007-06-01  7:16           ` Li Yu
2007-06-01 19:21             ` Ingo Molnar
2007-06-05  2:33               ` Li Yu
2007-06-05  8:01                 ` Ingo Molnar
2007-06-05  8:54                   ` Li Yu
2007-06-06  7:41                   ` Li Yu
2007-06-05  3:35               ` Li Yu
2007-05-28  1:17 ` Li Yu
2007-05-29  0:49   ` Li Yu

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=20070529102356.GB12620@linux.vnet.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pranith-kumar_d@mentorg.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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.