hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/kernel/sched/cpudeadline.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * kernel/sched/cpudl.c
34 *
45 * Global CPU deadline management
56 *
67 * Author: Juri Lelli <j.lelli@sssup.it>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; version 2
11
- * of the License.
128 */
139 #include "sched.h"
1410
....@@ -124,14 +120,38 @@
124120 const struct sched_dl_entity *dl_se = &p->dl;
125121
126122 if (later_mask &&
127
- cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) {
123
+ cpumask_and(later_mask, cp->free_cpus, p->cpus_ptr)) {
124
+ unsigned long cap, max_cap = 0;
125
+ int cpu, max_cpu = -1;
126
+
127
+ if (!static_branch_unlikely(&sched_asym_cpucapacity))
128
+ return 1;
129
+
130
+ /* Ensure the capacity of the CPUs fits the task. */
131
+ for_each_cpu(cpu, later_mask) {
132
+ if (!dl_task_fits_capacity(p, cpu)) {
133
+ cpumask_clear_cpu(cpu, later_mask);
134
+
135
+ cap = capacity_orig_of(cpu);
136
+
137
+ if (cap > max_cap ||
138
+ (cpu == task_cpu(p) && cap == max_cap)) {
139
+ max_cap = cap;
140
+ max_cpu = cpu;
141
+ }
142
+ }
143
+ }
144
+
145
+ if (cpumask_empty(later_mask))
146
+ cpumask_set_cpu(max_cpu, later_mask);
147
+
128148 return 1;
129149 } else {
130150 int best_cpu = cpudl_maximum(cp);
131151
132152 WARN_ON(best_cpu != -1 && !cpu_present(best_cpu));
133153
134
- if (cpumask_test_cpu(best_cpu, &p->cpus_allowed) &&
154
+ if (cpumask_test_cpu(best_cpu, p->cpus_ptr) &&
135155 dl_time_before(dl_se->deadline, cp->elements[0].dl)) {
136156 if (later_mask)
137157 cpumask_set_cpu(best_cpu, later_mask);