All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Al Boldi <a1426z@gawab.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: CFS review
Date: Mon, 27 Aug 2007 22:41:16 +0200	[thread overview]
Message-ID: <20070827204116.GA12495@elte.hu> (raw)
In-Reply-To: <200708271746.47685.a1426z@gawab.com>


* Al Boldi <a1426z@gawab.com> wrote:

> > Could you try the patch below instead, does this make 3x glxgears 
> > smooth again? (if yes, could you send me your Signed-off-by line as 
> > well.)
> 
> The task-startup stalling is still there for ~10sec.
> 
> Can you see the problem on your machine?

nope (i have no framebuffer setup) - but i can see some chew-max 
latencies that occur when new tasks are started up. I _think_ it's 
probably the same problem as yours.

could you try the patch below (which is the combo patch of my current 
queue), ontop of head 50c46637aa? This makes chew-max behave better 
during task mass-startup here.

	Ingo

----------------->
Index: linux/include/linux/sched.h
===================================================================
--- linux.orig/include/linux/sched.h
+++ linux/include/linux/sched.h
@@ -904,6 +904,7 @@ struct sched_entity {
 
 	u64			exec_start;
 	u64			sum_exec_runtime;
+	u64			prev_sum_exec_runtime;
 	u64			wait_start_fair;
 	u64			sleep_start_fair;
 
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -1587,6 +1587,7 @@ static void __sched_fork(struct task_str
 	p->se.wait_start_fair		= 0;
 	p->se.exec_start		= 0;
 	p->se.sum_exec_runtime		= 0;
+	p->se.prev_sum_exec_runtime	= 0;
 	p->se.delta_exec		= 0;
 	p->se.delta_fair_run		= 0;
 	p->se.delta_fair_sleep		= 0;
Index: linux/kernel/sched_fair.c
===================================================================
--- linux.orig/kernel/sched_fair.c
+++ linux/kernel/sched_fair.c
@@ -82,12 +82,12 @@ enum {
 };
 
 unsigned int sysctl_sched_features __read_mostly =
-		SCHED_FEAT_FAIR_SLEEPERS	*1 |
+		SCHED_FEAT_FAIR_SLEEPERS	*0 |
 		SCHED_FEAT_SLEEPER_AVG		*0 |
 		SCHED_FEAT_SLEEPER_LOAD_AVG	*1 |
 		SCHED_FEAT_PRECISE_CPU_LOAD	*1 |
-		SCHED_FEAT_START_DEBIT		*1 |
-		SCHED_FEAT_SKIP_INITIAL		*0;
+		SCHED_FEAT_START_DEBIT		*0 |
+		SCHED_FEAT_SKIP_INITIAL		*1;
 
 extern struct sched_class fair_sched_class;
 
@@ -225,39 +225,15 @@ static struct sched_entity *__pick_next_
  * Calculate the preemption granularity needed to schedule every
  * runnable task once per sysctl_sched_latency amount of time.
  * (down to a sensible low limit on granularity)
- *
- * For example, if there are 2 tasks running and latency is 10 msecs,
- * we switch tasks every 5 msecs. If we have 3 tasks running, we have
- * to switch tasks every 3.33 msecs to get a 10 msecs observed latency
- * for each task. We do finer and finer scheduling up to until we
- * reach the minimum granularity value.
- *
- * To achieve this we use the following dynamic-granularity rule:
- *
- *    gran = lat/nr - lat/nr/nr
- *
- * This comes out of the following equations:
- *
- *    kA1 + gran = kB1
- *    kB2 + gran = kA2
- *    kA2 = kA1
- *    kB2 = kB1 - d + d/nr
- *    lat = d * nr
- *
- * Where 'k' is key, 'A' is task A (waiting), 'B' is task B (running),
- * '1' is start of time, '2' is end of time, 'd' is delay between
- * 1 and 2 (during which task B was running), 'nr' is number of tasks
- * running, 'lat' is the the period of each task. ('lat' is the
- * sched_latency that we aim for.)
  */
-static long
+static unsigned long
 sched_granularity(struct cfs_rq *cfs_rq)
 {
 	unsigned int gran = sysctl_sched_latency;
 	unsigned int nr = cfs_rq->nr_running;
 
 	if (nr > 1) {
-		gran = gran/nr - gran/nr/nr;
+		gran = gran/nr;
 		gran = max(gran, sysctl_sched_min_granularity);
 	}
 
@@ -489,6 +465,9 @@ update_stats_wait_end(struct cfs_rq *cfs
 {
 	unsigned long delta_fair;
 
+	if (unlikely(!se->wait_start_fair))
+		return;
+
 	delta_fair = (unsigned long)min((u64)(2*sysctl_sched_runtime_limit),
 			(u64)(cfs_rq->fair_clock - se->wait_start_fair));
 
@@ -668,7 +647,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
 /*
  * Preempt the current task with a newly woken task if needed:
  */
-static void
+static int
 __check_preempt_curr_fair(struct cfs_rq *cfs_rq, struct sched_entity *se,
 			  struct sched_entity *curr, unsigned long granularity)
 {
@@ -679,8 +658,11 @@ __check_preempt_curr_fair(struct cfs_rq 
 	 * preempt the current task unless the best task has
 	 * a larger than sched_granularity fairness advantage:
 	 */
-	if (__delta > niced_granularity(curr, granularity))
+	if (__delta > niced_granularity(curr, granularity)) {
 		resched_task(rq_of(cfs_rq)->curr);
+		return 1;
+	}
+	return 0;
 }
 
 static inline void
@@ -725,6 +707,7 @@ static void put_prev_entity(struct cfs_r
 
 static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 {
+	unsigned long gran, delta_exec;
 	struct sched_entity *next;
 
 	/*
@@ -741,8 +724,13 @@ static void entity_tick(struct cfs_rq *c
 	if (next == curr)
 		return;
 
-	__check_preempt_curr_fair(cfs_rq, next, curr,
-			sched_granularity(cfs_rq));
+	gran = sched_granularity(cfs_rq);
+	delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
+	if (delta_exec > gran)
+		gran = 0;
+
+	if (__check_preempt_curr_fair(cfs_rq, next, curr, gran))
+		curr->prev_sum_exec_runtime = curr->sum_exec_runtime;
 }
 
 /**************************************************
@@ -1080,29 +1068,27 @@ static void task_new_fair(struct rq *rq,
 
 	sched_info_queued(p);
 
+	update_curr(cfs_rq);
 	update_stats_enqueue(cfs_rq, se);
-	/*
-	 * Child runs first: we let it run before the parent
-	 * until it reschedules once. We set up the key so that
-	 * it will preempt the parent:
-	 */
-	p->se.fair_key = current->se.fair_key -
-		niced_granularity(&rq->curr->se, sched_granularity(cfs_rq)) - 1;
+
 	/*
 	 * The first wait is dominated by the child-runs-first logic,
 	 * so do not credit it with that waiting time yet:
 	 */
 	if (sysctl_sched_features & SCHED_FEAT_SKIP_INITIAL)
-		p->se.wait_start_fair = 0;
+		se->wait_start_fair = 0;
 
 	/*
 	 * The statistical average of wait_runtime is about
 	 * -granularity/2, so initialize the task with that:
 	 */
-	if (sysctl_sched_features & SCHED_FEAT_START_DEBIT)
-		p->se.wait_runtime = -(sched_granularity(cfs_rq) / 2);
+	if (sysctl_sched_features & SCHED_FEAT_START_DEBIT) {
+		se->wait_runtime = -(sched_granularity(cfs_rq)/2);
+		schedstat_add(cfs_rq, wait_runtime, se->wait_runtime);
+	}
 
 	__enqueue_entity(cfs_rq, se);
+	resched_task(current);
 }
 
 #ifdef CONFIG_FAIR_GROUP_SCHED

  reply	other threads:[~2007-08-27 20:41 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-11 10:44 CFS review Al Boldi
2007-08-12  4:17 ` Ingo Molnar
2007-08-12 15:27   ` Al Boldi
2007-08-12 15:52     ` Ingo Molnar
2007-08-12 19:43       ` Al Boldi
2007-08-21 10:58         ` Ingo Molnar
2007-08-21 22:27           ` Al Boldi
2007-08-24 13:45             ` Ingo Molnar
2007-08-25 22:27               ` Al Boldi
2007-08-25 23:15                 ` Ingo Molnar
2007-08-26 16:27                   ` Al Boldi
2007-08-26 16:39                     ` Ingo Molnar
2007-08-27  4:06                       ` Al Boldi
2007-08-27 10:53                         ` Ingo Molnar
2007-08-27 14:46                           ` Al Boldi
2007-08-27 20:41                             ` Ingo Molnar [this message]
2007-08-28  4:37                               ` Al Boldi
2007-08-28  5:05                                 ` Linus Torvalds
2007-08-28  5:23                                   ` Al Boldi
2007-08-28  7:28                                     ` Mike Galbraith
2007-08-28  7:36                                       ` Ingo Molnar
2007-08-28 16:34                                     ` Linus Torvalds
2007-08-28 16:44                                       ` Arjan van de Ven
2007-08-28 16:45                                       ` Ingo Molnar
2007-08-29  4:19                                         ` Al Boldi
2007-08-29  4:53                                           ` Ingo Molnar
2007-08-29  5:58                                             ` Al Boldi
2007-08-29  6:43                                               ` Ingo Molnar
2007-08-28 20:46                                   ` Valdis.Kletnieks
2007-08-28  7:43                                 ` Xavier Bestel
2007-08-28  8:02                                   ` Ingo Molnar
2007-08-28 19:19                                     ` Willy Tarreau
2007-08-28 19:55                                       ` Ingo Molnar
2007-08-29  4:18                                 ` Ingo Molnar
2007-08-29  4:29                                   ` Keith Packard
2007-08-29  4:46                                     ` Ingo Molnar
2007-08-29  7:57                                       ` Keith Packard
2007-08-29  8:04                                         ` Ingo Molnar
2007-08-29  8:53                                           ` Al Boldi
2007-08-29 15:57                                           ` Keith Packard
2007-08-29 19:56                                             ` Rene Herman
2007-08-30  7:05                                               ` Rene Herman
2007-08-30  7:20                                                 ` Ingo Molnar
2007-08-31  6:46                                                 ` Tilman Sauerbeck
2007-08-31 10:44                                                   ` DRM and/or X trouble (was Re: CFS review) Rene Herman
2007-08-31 14:55                                                     ` DRM and/or X trouble Satyam Sharma
2007-08-30 16:06                                               ` CFS review Chuck Ebbert
2007-08-30 16:48                                                 ` Rene Herman
2007-08-29  4:40                                   ` Mike Galbraith
2007-08-29  3:42                   ` Bill Davidsen
2007-08-29  3:37                 ` Bill Davidsen
2007-08-29  3:45                   ` Ingo Molnar
2007-08-29 13:11                     ` Bill Davidsen
  -- strict thread matches above, loose matches on Subject: below --
2007-07-10  8:31 -mm merge plans for 2.6.23 Andrew Morton
2007-07-11 12:43 ` x86 status was " Andi Kleen
2007-07-11 17:42   ` Ingo Molnar
2007-07-11 21:16     ` Andi Kleen
2007-07-11 21:46       ` Andrea Arcangeli
2007-07-11 22:09         ` Linus Torvalds
2007-07-13  2:23           ` Roman Zippel
2007-07-13  4:47             ` Mike Galbraith
2007-07-13 17:23               ` Roman Zippel
2007-07-14  5:04                 ` Mike Galbraith
2007-08-01  3:41                   ` CFS review Roman Zippel
2007-08-01  7:12                     ` Ingo Molnar
2007-08-01  7:26                       ` Mike Galbraith
2007-08-01  7:30                         ` Ingo Molnar
2007-08-01  7:36                           ` Mike Galbraith
2007-08-01  8:49                             ` Mike Galbraith
2007-08-01 13:19                       ` Roman Zippel
2007-08-01 15:07                         ` Ingo Molnar
2007-08-01 17:10                           ` Andi Kleen
2007-08-01 16:27                             ` Linus Torvalds
2007-08-01 17:48                               ` Andi Kleen
2007-08-01 17:50                               ` Ingo Molnar
2007-08-01 18:01                                 ` Roman Zippel
2007-08-01 19:05                                   ` Ingo Molnar
2007-08-09 23:14                                     ` Roman Zippel
2007-08-10  5:49                                       ` Ingo Molnar
2007-08-10 13:52                                         ` Roman Zippel
2007-08-10 14:18                                           ` Ingo Molnar
2007-08-10 16:47                                           ` Mike Galbraith
2007-08-10 17:19                                             ` Roman Zippel
2007-08-10 16:54                                           ` Michael Chang
2007-08-10 17:25                                             ` Roman Zippel
2007-08-10 19:44                                               ` Ingo Molnar
2007-08-10 19:47                                               ` Willy Tarreau
2007-08-10 21:15                                                 ` Roman Zippel
2007-08-10 21:36                                                   ` Ingo Molnar
2007-08-10 22:50                                                     ` Roman Zippel
2007-08-11  5:28                                                       ` Willy Tarreau
2007-08-12  5:17                                                         ` Ingo Molnar
2007-08-11  0:30                                                     ` Ingo Molnar
2007-08-20 22:19                                                       ` Roman Zippel
2007-08-21  7:33                                                         ` Mike Galbraith
2007-08-21  8:35                                                           ` Ingo Molnar
2007-08-21 11:54                                                           ` Roman Zippel
2007-08-11  5:15                                                   ` Willy Tarreau
2007-08-10  7:23                                       ` Mike Galbraith
2007-08-01 11:22                     ` Ingo Molnar
2007-08-01 12:21                       ` Roman Zippel
2007-08-01 12:23                         ` Ingo Molnar
2007-08-01 13:59                         ` Ingo Molnar
2007-08-01 14:04                           ` Arjan van de Ven
2007-08-01 15:44                           ` Roman Zippel
2007-08-01 17:41                             ` Ingo Molnar
2007-08-01 18:14                               ` Roman Zippel
2007-08-03  3:04                       ` Matt Mackall
2007-08-03  3:57                         ` Arjan van de Ven
2007-08-03  4:18                           ` Willy Tarreau
2007-08-03  4:31                             ` Arjan van de Ven
2007-08-03  4:53                               ` Willy Tarreau
2007-08-03  4:38                           ` Matt Mackall
2007-08-03  8:44                             ` Ingo Molnar
2007-08-03  9:29                             ` Andi Kleen
2007-08-01 11:37                     ` Ingo Molnar
2007-08-01 12:27                       ` Roman Zippel
2007-08-01 13:20                     ` Andi Kleen
2007-08-01 13:33                       ` Roman Zippel
2007-08-01 14:36                         ` Ingo Molnar
2007-08-01 16:11                           ` Andi Kleen
2007-08-02  2:17                         ` Linus Torvalds
2007-08-02  4:57                           ` Willy Tarreau
2007-08-02 10:43                             ` Andi Kleen
2007-08-02 10:07                               ` Willy Tarreau
2007-08-02 16:09                           ` Ingo Molnar
2007-08-02 22:38                             ` Roman Zippel
2007-08-02 19:16                           ` Daniel Phillips
2007-08-02 23:23                           ` Roman Zippel
2007-08-01 14:40                     ` Ingo Molnar
2007-08-01 14:49                     ` Peter Zijlstra
2007-08-02 17:36                       ` Roman Zippel
2007-08-02 15:46                     ` Ingo Molnar

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=20070827204116.GA12495@elte.hu \
    --to=mingo@elte.hu \
    --cc=a1426z@gawab.com \
    --cc=akpm@linux-foundation.org \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --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.