Commit 5f24fe82 authored by Martin J. Bligh's avatar Martin J. Bligh Committed by Justin T. Gibbs

[PATCH] (1/3) Minimal NUMA scheduler

Patch from Martin J. Bligh

This adds a small hook to the find_busiest_queue routine to allow us to
specify a mask of which CPUs to search over. In the NUMA case, it will
only balance inside the node (much cheaper to search, and stops tasks
from bouncing across nodes, which is very costly). The cpus_to_balance
routine is conditionally defined to ensure no impact to non-NUMA machines.

This is a tiny NUMA scheduler, but it needs the assistance of the second
and third patches in order to spread tasks across nodes.
parent ca58c4b6
...@@ -624,6 +624,22 @@ static inline void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2) ...@@ -624,6 +624,22 @@ static inline void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2)
spin_unlock(&rq2->lock); spin_unlock(&rq2->lock);
} }
#ifdef CONFIG_NUMA
static inline unsigned long cpus_to_balance(int this_cpu)
{
return __node_to_cpu_mask(__cpu_to_node(this_cpu));
}
#else /* !CONFIG_NUMA */
static inline unsigned long cpus_to_balance(int this_cpu)
{
return cpu_online_map;
}
#endif /* CONFIG_NUMA */
#if CONFIG_SMP #if CONFIG_SMP
/* /*
...@@ -652,9 +668,9 @@ static inline unsigned int double_lock_balance(runqueue_t *this_rq, ...@@ -652,9 +668,9 @@ static inline unsigned int double_lock_balance(runqueue_t *this_rq,
} }
/* /*
* find_busiest_queue - find the busiest runqueue. * find_busiest_queue - find the busiest runqueue among the cpus in cpumask.
*/ */
static inline runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu, int idle, int *imbalance) static inline runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu, int idle, int *imbalance, unsigned long cpumask)
{ {
int nr_running, load, max_load, i; int nr_running, load, max_load, i;
runqueue_t *busiest, *rq_src; runqueue_t *busiest, *rq_src;
...@@ -689,7 +705,7 @@ static inline runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu, ...@@ -689,7 +705,7 @@ static inline runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu,
busiest = NULL; busiest = NULL;
max_load = 1; max_load = 1;
for (i = 0; i < NR_CPUS; i++) { for (i = 0; i < NR_CPUS; i++) {
if (!cpu_online(i)) if (!((1UL << i) & cpumask))
continue; continue;
rq_src = cpu_rq(i); rq_src = cpu_rq(i);
...@@ -764,7 +780,8 @@ static void load_balance(runqueue_t *this_rq, int idle) ...@@ -764,7 +780,8 @@ static void load_balance(runqueue_t *this_rq, int idle)
struct list_head *head, *curr; struct list_head *head, *curr;
task_t *tmp; task_t *tmp;
busiest = find_busiest_queue(this_rq, this_cpu, idle, &imbalance); busiest = find_busiest_queue(this_rq, this_cpu, idle, &imbalance,
cpus_to_balance(this_cpu));
if (!busiest) if (!busiest)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment