Commit d38b223c authored by Mike Travis's avatar Mike Travis Committed by Ingo Molnar

cpumask: reduce stack usage in find_lowest_rq

Impact: reduce stack usage, cleanup

Use a cpumask_var_t in find_lowest_rq() and clean up other old
cpumask_t calls.
Signed-off-by: default avatarMike Travis <travis@sgi.com>
parent c90e785b
...@@ -960,16 +960,17 @@ static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu) ...@@ -960,16 +960,17 @@ static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu)
static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask); static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask);
static inline int pick_optimal_cpu(int this_cpu, cpumask_t *mask) static inline int pick_optimal_cpu(int this_cpu,
const struct cpumask *mask)
{ {
int first; int first;
/* "this_cpu" is cheaper to preempt than a remote processor */ /* "this_cpu" is cheaper to preempt than a remote processor */
if ((this_cpu != -1) && cpu_isset(this_cpu, *mask)) if ((this_cpu != -1) && cpumask_test_cpu(this_cpu, mask))
return this_cpu; return this_cpu;
first = first_cpu(*mask); first = cpumask_first(mask);
if (first != NR_CPUS) if (first < nr_cpu_ids)
return first; return first;
return -1; return -1;
...@@ -981,6 +982,7 @@ static int find_lowest_rq(struct task_struct *task) ...@@ -981,6 +982,7 @@ static int find_lowest_rq(struct task_struct *task)
struct cpumask *lowest_mask = __get_cpu_var(local_cpu_mask); struct cpumask *lowest_mask = __get_cpu_var(local_cpu_mask);
int this_cpu = smp_processor_id(); int this_cpu = smp_processor_id();
int cpu = task_cpu(task); int cpu = task_cpu(task);
cpumask_var_t domain_mask;
if (task->rt.nr_cpus_allowed == 1) if (task->rt.nr_cpus_allowed == 1)
return -1; /* No other targets possible */ return -1; /* No other targets possible */
...@@ -1013,19 +1015,25 @@ static int find_lowest_rq(struct task_struct *task) ...@@ -1013,19 +1015,25 @@ static int find_lowest_rq(struct task_struct *task)
if (this_cpu == cpu) if (this_cpu == cpu)
this_cpu = -1; /* Skip this_cpu opt if the same */ this_cpu = -1; /* Skip this_cpu opt if the same */
for_each_domain(cpu, sd) { if (alloc_cpumask_var(&domain_mask, GFP_ATOMIC)) {
if (sd->flags & SD_WAKE_AFFINE) { for_each_domain(cpu, sd) {
cpumask_t domain_mask; if (sd->flags & SD_WAKE_AFFINE) {
int best_cpu; int best_cpu;
cpumask_and(&domain_mask, sched_domain_span(sd), cpumask_and(domain_mask,
lowest_mask); sched_domain_span(sd),
lowest_mask);
best_cpu = pick_optimal_cpu(this_cpu, best_cpu = pick_optimal_cpu(this_cpu,
&domain_mask); domain_mask);
if (best_cpu != -1)
return best_cpu; if (best_cpu != -1) {
free_cpumask_var(domain_mask);
return best_cpu;
}
}
} }
free_cpumask_var(domain_mask);
} }
/* /*
......
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