diff options
author | Xunlei Pang <pang.xunlei@linaro.org> | 2015-01-18 23:49:36 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-01-30 13:39:16 -0500 |
commit | 16b269436b7213ebc01dcfcc9dafa8535b676ccb (patch) | |
tree | 430aa2ee5f76f7de1bfa393cd8ad36e4a09e5f45 /kernel | |
parent | ff6f2d29bd31cdfa1ac494a8b26d2af8ba887d59 (diff) |
sched/deadline: Modify cpudl::free_cpus to reflect rd->online
Currently, cpudl::free_cpus contains all CPUs during init, see
cpudl_init(). When calling cpudl_find(), we have to add rd->span
to avoid selecting the cpu outside the current root domain, because
cpus_allowed cannot be depended on when performing clustered
scheduling using the cpuset, see find_later_rq().
This patch adds cpudl_set_freecpu() and cpudl_clear_freecpu() for
changing cpudl::free_cpus when doing rq_online_dl()/rq_offline_dl(),
so we can avoid the rd->span operation when calling cpudl_find()
in find_later_rq().
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1421642980-10045-1-git-send-email-pang.xunlei@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched/cpudeadline.c | 28 | ||||
-rw-r--r-- | kernel/sched/cpudeadline.h | 2 | ||||
-rw-r--r-- | kernel/sched/deadline.c | 5 |
3 files changed, 28 insertions, 7 deletions
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 539ca3ce071b..fd9d3fb49d0d 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c | |||
@@ -107,7 +107,9 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, | |||
107 | int best_cpu = -1; | 107 | int best_cpu = -1; |
108 | const struct sched_dl_entity *dl_se = &p->dl; | 108 | const struct sched_dl_entity *dl_se = &p->dl; |
109 | 109 | ||
110 | if (later_mask && cpumask_and(later_mask, later_mask, cp->free_cpus)) { | 110 | if (later_mask && |
111 | cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed) && | ||
112 | cpumask_and(later_mask, later_mask, cpu_active_mask)) { | ||
111 | best_cpu = cpumask_any(later_mask); | 113 | best_cpu = cpumask_any(later_mask); |
112 | goto out; | 114 | goto out; |
113 | } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && | 115 | } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && |
@@ -186,6 +188,26 @@ out: | |||
186 | } | 188 | } |
187 | 189 | ||
188 | /* | 190 | /* |
191 | * cpudl_set_freecpu - Set the cpudl.free_cpus | ||
192 | * @cp: the cpudl max-heap context | ||
193 | * @cpu: rd attached cpu | ||
194 | */ | ||
195 | void cpudl_set_freecpu(struct cpudl *cp, int cpu) | ||
196 | { | ||
197 | cpumask_set_cpu(cpu, cp->free_cpus); | ||
198 | } | ||
199 | |||
200 | /* | ||
201 | * cpudl_clear_freecpu - Clear the cpudl.free_cpus | ||
202 | * @cp: the cpudl max-heap context | ||
203 | * @cpu: rd attached cpu | ||
204 | */ | ||
205 | void cpudl_clear_freecpu(struct cpudl *cp, int cpu) | ||
206 | { | ||
207 | cpumask_clear_cpu(cpu, cp->free_cpus); | ||
208 | } | ||
209 | |||
210 | /* | ||
189 | * cpudl_init - initialize the cpudl structure | 211 | * cpudl_init - initialize the cpudl structure |
190 | * @cp: the cpudl max-heap context | 212 | * @cp: the cpudl max-heap context |
191 | */ | 213 | */ |
@@ -203,7 +225,7 @@ int cpudl_init(struct cpudl *cp) | |||
203 | if (!cp->elements) | 225 | if (!cp->elements) |
204 | return -ENOMEM; | 226 | return -ENOMEM; |
205 | 227 | ||
206 | if (!alloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { | 228 | if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { |
207 | kfree(cp->elements); | 229 | kfree(cp->elements); |
208 | return -ENOMEM; | 230 | return -ENOMEM; |
209 | } | 231 | } |
@@ -211,8 +233,6 @@ int cpudl_init(struct cpudl *cp) | |||
211 | for_each_possible_cpu(i) | 233 | for_each_possible_cpu(i) |
212 | cp->elements[i].idx = IDX_INVALID; | 234 | cp->elements[i].idx = IDX_INVALID; |
213 | 235 | ||
214 | cpumask_setall(cp->free_cpus); | ||
215 | |||
216 | return 0; | 236 | return 0; |
217 | } | 237 | } |
218 | 238 | ||
diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h index 020039bd1326..1a0a6ef2fbe1 100644 --- a/kernel/sched/cpudeadline.h +++ b/kernel/sched/cpudeadline.h | |||
@@ -24,6 +24,8 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, | |||
24 | struct cpumask *later_mask); | 24 | struct cpumask *later_mask); |
25 | void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid); | 25 | void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid); |
26 | int cpudl_init(struct cpudl *cp); | 26 | int cpudl_init(struct cpudl *cp); |
27 | void cpudl_set_freecpu(struct cpudl *cp, int cpu); | ||
28 | void cpudl_clear_freecpu(struct cpudl *cp, int cpu); | ||
27 | void cpudl_cleanup(struct cpudl *cp); | 29 | void cpudl_cleanup(struct cpudl *cp); |
28 | #endif /* CONFIG_SMP */ | 30 | #endif /* CONFIG_SMP */ |
29 | 31 | ||
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index b52092f2636d..e7b272233c5c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
@@ -1165,9 +1165,6 @@ static int find_later_rq(struct task_struct *task) | |||
1165 | * We have to consider system topology and task affinity | 1165 | * We have to consider system topology and task affinity |
1166 | * first, then we can look for a suitable cpu. | 1166 | * first, then we can look for a suitable cpu. |
1167 | */ | 1167 | */ |
1168 | cpumask_copy(later_mask, task_rq(task)->rd->span); | ||
1169 | cpumask_and(later_mask, later_mask, cpu_active_mask); | ||
1170 | cpumask_and(later_mask, later_mask, &task->cpus_allowed); | ||
1171 | best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, | 1168 | best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, |
1172 | task, later_mask); | 1169 | task, later_mask); |
1173 | if (best_cpu == -1) | 1170 | if (best_cpu == -1) |
@@ -1562,6 +1559,7 @@ static void rq_online_dl(struct rq *rq) | |||
1562 | if (rq->dl.overloaded) | 1559 | if (rq->dl.overloaded) |
1563 | dl_set_overload(rq); | 1560 | dl_set_overload(rq); |
1564 | 1561 | ||
1562 | cpudl_set_freecpu(&rq->rd->cpudl, rq->cpu); | ||
1565 | if (rq->dl.dl_nr_running > 0) | 1563 | if (rq->dl.dl_nr_running > 0) |
1566 | cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr, 1); | 1564 | cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr, 1); |
1567 | } | 1565 | } |
@@ -1573,6 +1571,7 @@ static void rq_offline_dl(struct rq *rq) | |||
1573 | dl_clear_overload(rq); | 1571 | dl_clear_overload(rq); |
1574 | 1572 | ||
1575 | cpudl_set(&rq->rd->cpudl, rq->cpu, 0, 0); | 1573 | cpudl_set(&rq->rd->cpudl, rq->cpu, 0, 0); |
1574 | cpudl_clear_freecpu(&rq->rd->cpudl, rq->cpu); | ||
1576 | } | 1575 | } |
1577 | 1576 | ||
1578 | void init_sched_dl_class(void) | 1577 | void init_sched_dl_class(void) |