Skip to contentSkip to conversation

sched: Make find_busiest_queue() a method

tip:sched/numa tip-bot for Peter Zijlstra 1 participant 1 message Sep 28, 2012 Scheduler

lore
Share & tools
lore
#0 lore raw
Commit-ID:  6aee56c2e1f3e90f5867cf3fd995b0e3f368d229
Gitweb:     http://git.kernel.org/tip/6aee56c2e1f3e90f5867cf3fd995b0e3f368d229
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Sat, 3 Mar 2012 16:56:25 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 27 Sep 2012 14:46:04 +0200

sched: Make find_busiest_queue() a method

Its a bit awkward but it was the least painful means of modifying the queue selection. Used in a later patch to conditionally use a random queue.

Cc Paul Turner <[email protected]>
Cc Lee Schermerhorn <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 kernel/sched/fair.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
kernel/sched/fair.c +12 -8
index de596a2..ffa10d6 100644
@@ -3049,6 +3049,9 @@ struct lb_env {
 	unsigned int		loop;
 	unsigned int		loop_break;
 	unsigned int		loop_max;
+
+	struct rq *		(*find_busiest_queue)(struct lb_env *,
+						      struct sched_group *);
 };
 
 /*
@@ -4222,13 +4225,14 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 	struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
 
 	struct lb_env env = {
-		.sd		= sd,
-		.dst_cpu	= this_cpu,
-		.dst_rq		= this_rq,
-		.dst_grpmask    = sched_group_cpus(sd->groups),
-		.idle		= idle,
-		.loop_break	= sched_nr_migrate_break,
-		.cpus		= cpus,
+		.sd		    = sd,
+		.dst_cpu	    = this_cpu,
+		.dst_rq		    = this_rq,
+		.dst_grpmask        = sched_group_cpus(sd->groups),
+		.idle		    = idle,
+		.loop_break	    = sched_nr_migrate_break,
+		.cpus		    = cpus,
+		.find_busiest_queue = find_busiest_queue,
 	};
 
 	cpumask_copy(cpus, cpu_active_mask);
@@ -4247,7 +4251,7 @@ redo:
 		goto out_balanced;
 	}
 
-	busiest = find_busiest_queue(&env, group);
+	busiest = env.find_busiest_queue(&env, group);
 	if (!busiest) {
 		schedstat_inc(sd, lb_nobusyq[idle]);
 		goto out_balanced;