| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * kernel/sched/cpudl.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Global CPU deadline management |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * 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. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | #include "sched.h" |
|---|
| 14 | 10 | |
|---|
| .. | .. |
|---|
| 124 | 120 | const struct sched_dl_entity *dl_se = &p->dl; |
|---|
| 125 | 121 | |
|---|
| 126 | 122 | 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 | + |
|---|
| 128 | 148 | return 1; |
|---|
| 129 | 149 | } else { |
|---|
| 130 | 150 | int best_cpu = cpudl_maximum(cp); |
|---|
| 131 | 151 | |
|---|
| 132 | 152 | WARN_ON(best_cpu != -1 && !cpu_present(best_cpu)); |
|---|
| 133 | 153 | |
|---|
| 134 | | - if (cpumask_test_cpu(best_cpu, &p->cpus_allowed) && |
|---|
| 154 | + if (cpumask_test_cpu(best_cpu, p->cpus_ptr) && |
|---|
| 135 | 155 | dl_time_before(dl_se->deadline, cp->elements[0].dl)) { |
|---|
| 136 | 156 | if (later_mask) |
|---|
| 137 | 157 | cpumask_set_cpu(best_cpu, later_mask); |
|---|