mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: mingo@elte.hu, linux-kernel@vger.kernel.org, peterz@infradead.org
Subject: [PATCH] [1/4] SCHED: cache task_hot result
Date: Wed, 12 Nov 2008 13:45:09 +0100 (CET)	[thread overview]
Message-ID: <20081112124509.616B03E6610@basil.firstfloor.org> (raw)
In-Reply-To: <20081112145.328971960@firstfloor.org>


Minor scheduler optimization: cache the result of task_hot() in 
can migrate task instead of computing it three times.

Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 kernel/sched.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Index: linux-2.6.28-rc4-test/kernel/sched.c
===================================================================
--- linux-2.6.28-rc4-test.orig/kernel/sched.c	2008-11-10 08:50:24.000000000 +0100
+++ linux-2.6.28-rc4-test/kernel/sched.c	2008-11-12 12:32:52.000000000 +0100
@@ -2907,6 +2907,8 @@
 		     struct sched_domain *sd, enum cpu_idle_type idle,
 		     int *all_pinned)
 {
+	int hot;
+
 	/*
 	 * We do not migrate tasks that are:
 	 * 1) running (obviously), or
@@ -2930,10 +2932,11 @@
 	 * 2) too many balance attempts have failed.
 	 */
 
-	if (!task_hot(p, rq->clock, sd) ||
-			sd->nr_balance_failed > sd->cache_nice_tries) {
+	hot = task_hot(p, rq->clock, sd);
+
+	if (!hot || sd->nr_balance_failed > sd->cache_nice_tries) {
 #ifdef CONFIG_SCHEDSTATS
-		if (task_hot(p, rq->clock, sd)) {
+		if (hot) {
 			schedstat_inc(sd, lb_hot_gained[idle]);
 			schedstat_inc(p, se.nr_forced_migrations);
 		}
@@ -2941,7 +2944,7 @@
 		return 1;
 	}
 
-	if (task_hot(p, rq->clock, sd)) {
+	if (hot) {
 		schedstat_inc(p, se.nr_failed_migrations_hot);
 		return 0;
 	}

  reply	other threads:[~2008-11-12 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12 12:45 [PATCH] [0/4] SCHED: Trivial scheduler fixes Andi Kleen
2008-11-12 12:45 ` Andi Kleen [this message]
2008-11-12 12:45 ` [PATCH] [2/4] SCHED: Mark all frequently used sysctls __read_mostly Andi Kleen
2008-11-12 12:45 ` [PATCH] [3/4] SCHED: don't inline idle_balance into schedule() Andi Kleen
2008-11-12 12:45 ` [PATCH] [4/4] SCHED: Use a lookup array in sd_level_to_string Andi Kleen
2008-11-12 14:47   ` Johannes Weiner
2008-11-12 15:28     ` Andi Kleen
2008-11-12 18:43     ` 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=20081112124509.616B03E6610@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.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 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®