mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kevin O'Connor" <kevin@koconnor.net>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Subject: O(1) batch scheduler
Date: Tue, 9 Jul 2002 22:30:21 -0400	[thread overview]
Message-ID: <20020709223021.A4567@arizona.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0207011137330.4167-100000@e2>; from mingo@elte.hu on Mon, Jul 01, 2002 at 11:45:32AM +0200

Hi Ingo,

I looked through your sched-2.5.25-A5 patch, and I'm confused by the
idle_count array.  It calculates the idle average of the last 9 seconds -
but why not just use a weighted average.  A weighted average is going to be
very close to the true average, and where it differs the weighted average
should be preferable.

Incremental patch (untested):

--- kernel/sched.c	Tue Jul  9 22:06:38 2002
+++ ../linux-2.5.25-a/kernel/sched.c	Tue Jul  9 22:23:41 2002
@@ -171,7 +171,7 @@
 	#define IDLE_TICKS (HZ)
 
 	int idle_ticks_left;
-	int idle_count[IDLE_SLOTS];
+	int idle_count;
 	int idle_avg;
 
 } ____cacheline_aligned;
@@ -886,17 +886,6 @@
 #define BUSY_REBALANCE_TICK (HZ/4 ?: 1)
 #define IDLE_REBALANCE_TICK (HZ/1000 ?: 1)
 
-static inline int recalc_idle_avg(runqueue_t *rq)
-{
-	int i, count = 0, avg;
-
-	for (i = 1; i < IDLE_SLOTS; i++)
-		count += rq->idle_count[i];
-
-	avg = count / (IDLE_SLOTS - 1);
-	return avg;
-}
-
 static inline void idle_tick(runqueue_t *rq)
 {
 	if (jiffies % IDLE_REBALANCE_TICK)
@@ -938,17 +927,13 @@
 		 * This code is rare, triggered only once per second:
 		 */
 		if (--rq->idle_ticks_left <= 0) {
-			int i;
-
-			rq->idle_ticks_left = IDLE_TICKS;
-			for (i = IDLE_SLOTS-1; i > 0; i--)
-				rq->idle_count[i] = rq->idle_count[i-1];
-			rq->idle_count[0] = 0;
-			rq->idle_avg = recalc_idle_avg(rq);
+			rq->idle_avg = (rq->idle_avg * (IDLE_SLOTS - 1)
+					+ rq->idle_count) / IDLE_SLOTS;
+			rq->idle_count = 0;
 		}
 	}
 	if (p == rq->idle || p->policy == SCHED_BATCH)
-		rq->idle_count[0]++;
+		rq->idle_count++;
 #endif
 	if (p == rq->idle) {
 		if (local_bh_count(cpu) || local_irq_count(cpu) > 1)

-- 
 ------------------------------------------------------------------------
 | Kevin O'Connor                     "BTW, IMHO we need a FAQ for      |
 | kevin@koconnor.net                  'IMHO', 'FAQ', 'BTW', etc. !"    |
 ------------------------------------------------------------------------

  reply	other threads:[~2002-07-10  2:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-01  9:45 [patch] sched-2.5.24-D3, batch/idle priority scheduling, SCHED_BATCH Ingo Molnar
2002-07-10  2:30 ` Kevin O'Connor [this message]
2002-07-11  6:27   ` O(1) batch scheduler Ingo Molnar
2002-07-11  6:32   ` Ingo Molnar
2002-07-11  7:05   ` [patch] " Ingo Molnar
2002-07-11  4:41     ` Kevin O'Connor

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=20020709223021.A4567@arizona.localdomain \
    --to=kevin@koconnor.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®