Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169890
b: refs/heads/master
c: e2c8806
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell authored and Ingo Molnar committed Nov 4, 2009
1 parent a56e708 commit fc995bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 45a5c8bad827ebb9c9798becc15bce2e804d49e0
refs/heads/master: e2c880630438f80b474378d5487b511b07665051
61 changes: 24 additions & 37 deletions trunk/kernel/sched_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,29 +1153,12 @@ 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 inline int pick_optimal_cpu(int this_cpu,
const struct cpumask *mask)
{
int first;

/* "this_cpu" is cheaper to preempt than a remote processor */
if ((this_cpu != -1) && cpumask_test_cpu(this_cpu, mask))
return this_cpu;

first = cpumask_first(mask);
if (first < nr_cpu_ids)
return first;

return -1;
}

static int find_lowest_rq(struct task_struct *task)
{
struct sched_domain *sd;
struct cpumask *lowest_mask = __get_cpu_var(local_cpu_mask);
int this_cpu = smp_processor_id();
int cpu = task_cpu(task);
cpumask_var_t domain_mask;

if (task->rt.nr_cpus_allowed == 1)
return -1; /* No other targets possible */
Expand All @@ -1198,36 +1181,40 @@ static int find_lowest_rq(struct task_struct *task)
* Otherwise, we consult the sched_domains span maps to figure
* out which cpu is logically closest to our hot cache data.
*/
if (this_cpu == cpu)
this_cpu = -1; /* Skip this_cpu opt if the same */

if (alloc_cpumask_var(&domain_mask, GFP_ATOMIC)) {
for_each_domain(cpu, sd) {
if (sd->flags & SD_WAKE_AFFINE) {
int best_cpu;
if (!cpumask_test_cpu(this_cpu, lowest_mask))
this_cpu = -1; /* Skip this_cpu opt if not among lowest */

cpumask_and(domain_mask,
sched_domain_span(sd),
lowest_mask);
for_each_domain(cpu, sd) {
if (sd->flags & SD_WAKE_AFFINE) {
int best_cpu;

best_cpu = pick_optimal_cpu(this_cpu,
domain_mask);

if (best_cpu != -1) {
free_cpumask_var(domain_mask);
return best_cpu;
}
}
/*
* "this_cpu" is cheaper to preempt than a
* remote processor.
*/
if (this_cpu != -1 &&
cpumask_test_cpu(this_cpu, sched_domain_span(sd)))
return this_cpu;

best_cpu = cpumask_first_and(lowest_mask,
sched_domain_span(sd));
if (best_cpu < nr_cpu_ids)
return best_cpu;
}
free_cpumask_var(domain_mask);
}

/*
* And finally, if there were no matches within the domains
* just give the caller *something* to work with from the compatible
* locations.
*/
return pick_optimal_cpu(this_cpu, lowest_mask);
if (this_cpu != -1)
return this_cpu;

cpu = cpumask_any(lowest_mask);
if (cpu < nr_cpu_ids)
return cpu;
return -1;
}

/* Will lock the rq it finds */
Expand Down

0 comments on commit fc995bb

Please sign in to comment.