All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2 -tip] sched: small optimisation on can_migrate_task
@ 2009-03-16 19:59 Luis Henriques
  2009-03-17 11:06 ` [tip:sched/cleanups] sched: small optimisation of can_migrate_task() Luis Henriques
  0 siblings, 1 reply; 2+ messages in thread
From: Luis Henriques @ 2009-03-16 19:59 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

There were 3 invocation to task_hot() in function can_migrate_task().  These 3
invocations have been replaced by only one invocation, cached in a local
variable.

Signed-off-by: Luis Henriques <henrix@sapo.pt>
---
 kernel/sched.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 0a5d929..4000304 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3072,6 +3072,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 		     struct sched_domain *sd, enum cpu_idle_type idle,
 		     int *all_pinned)
 {
+	int tsk_cache_hot = 0;
 	/*
 	 * We do not migrate tasks that are:
 	 * 1) running (obviously), or
@@ -3095,10 +3096,11 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 	 * 2) too many balance attempts have failed.
 	 */
 
-	if (!task_hot(p, rq->clock, sd) ||
-			sd->nr_balance_failed > sd->cache_nice_tries) {
+	tsk_cache_hot = task_hot(p, rq->clock, sd);
+	if (!tsk_cache_hot ||
+		sd->nr_balance_failed > sd->cache_nice_tries) {
 #ifdef CONFIG_SCHEDSTATS
-		if (task_hot(p, rq->clock, sd)) {
+		if (tsk_cache_hot) {
 			schedstat_inc(sd, lb_hot_gained[idle]);
 			schedstat_inc(p, se.nr_forced_migrations);
 		}
@@ -3106,7 +3108,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 		return 1;
 	}
 
-	if (task_hot(p, rq->clock, sd)) {
+	if (tsk_cache_hot) {
 		schedstat_inc(p, se.nr_failed_migrations_hot);
 		return 0;
 	}
-- 
1.6.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:sched/cleanups] sched: small optimisation of can_migrate_task()
  2009-03-16 19:59 [PATCH 2/2 -tip] sched: small optimisation on can_migrate_task Luis Henriques
@ 2009-03-17 11:06 ` Luis Henriques
  0 siblings, 0 replies; 2+ messages in thread
From: Luis Henriques @ 2009-03-17 11:06 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, henrix, tglx, mingo

Commit-ID:  708dc5125309cd33c5daaad3026cc4ae6ef39c8b
Gitweb:     http://git.kernel.org/tip/708dc5125309cd33c5daaad3026cc4ae6ef39c8b
Author:     Luis Henriques <henrix@sapo.pt>
AuthorDate: Mon, 16 Mar 2009 19:59:02 +0000
Commit:     Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 17 Mar 2009 12:04:41 +0100

sched: small optimisation of can_migrate_task()

There were 3 invocations of task_hot() in can_migrate_task().

Replace these 3 invocations by only one invocation, cached in
a local variable.

Signed-off-by: Luis Henriques <henrix@sapo.pt>
LKML-Reference: <20090316195902.GA6197@hades.domain.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/sched.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 489e7d9..d2dfe4c 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3002,6 +3002,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 		     struct sched_domain *sd, enum cpu_idle_type idle,
 		     int *all_pinned)
 {
+	int tsk_cache_hot = 0;
 	/*
 	 * We do not migrate tasks that are:
 	 * 1) running (obviously), or
@@ -3025,10 +3026,11 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 	 * 2) too many balance attempts have failed.
 	 */
 
-	if (!task_hot(p, rq->clock, sd) ||
-			sd->nr_balance_failed > sd->cache_nice_tries) {
+	tsk_cache_hot = task_hot(p, rq->clock, sd);
+	if (!tsk_cache_hot ||
+		sd->nr_balance_failed > sd->cache_nice_tries) {
 #ifdef CONFIG_SCHEDSTATS
-		if (task_hot(p, rq->clock, sd)) {
+		if (tsk_cache_hot) {
 			schedstat_inc(sd, lb_hot_gained[idle]);
 			schedstat_inc(p, se.nr_forced_migrations);
 		}
@@ -3036,7 +3038,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
 		return 1;
 	}
 
-	if (task_hot(p, rq->clock, sd)) {
+	if (tsk_cache_hot) {
 		schedstat_inc(p, se.nr_failed_migrations_hot);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-17 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-16 19:59 [PATCH 2/2 -tip] sched: small optimisation on can_migrate_task Luis Henriques
2009-03-17 11:06 ` [tip:sched/cleanups] sched: small optimisation of can_migrate_task() Luis Henriques

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.