diff options
| -rw-r--r-- | kernel/sched/core.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f895fdd32c5b..8322d73b4392 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -6190,10 +6190,65 @@ static void sched_init_numa(void) | |||
| 6190 | 6190 | ||
| 6191 | sched_domains_numa_levels = level; | 6191 | sched_domains_numa_levels = level; |
| 6192 | } | 6192 | } |
| 6193 | |||
| 6194 | static void sched_domains_numa_masks_set(int cpu) | ||
| 6195 | { | ||
| 6196 | int i, j; | ||
| 6197 | int node = cpu_to_node(cpu); | ||
| 6198 | |||
| 6199 | for (i = 0; i < sched_domains_numa_levels; i++) { | ||
| 6200 | for (j = 0; j < nr_node_ids; j++) { | ||
| 6201 | if (node_distance(j, node) <= sched_domains_numa_distance[i]) | ||
| 6202 | cpumask_set_cpu(cpu, sched_domains_numa_masks[i][j]); | ||
| 6203 | } | ||
| 6204 | } | ||
| 6205 | } | ||
| 6206 | |||
| 6207 | static void sched_domains_numa_masks_clear(int cpu) | ||
| 6208 | { | ||
| 6209 | int i, j; | ||
| 6210 | for (i = 0; i < sched_domains_numa_levels; i++) { | ||
| 6211 | for (j = 0; j < nr_node_ids; j++) | ||
| 6212 | cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]); | ||
| 6213 | } | ||
| 6214 | } | ||
| 6215 | |||
| 6216 | /* | ||
| 6217 | * Update sched_domains_numa_masks[level][node] array when new cpus | ||
| 6218 | * are onlined. | ||
| 6219 | */ | ||
| 6220 | static int sched_domains_numa_masks_update(struct notifier_block *nfb, | ||
| 6221 | unsigned long action, | ||
| 6222 | void *hcpu) | ||
| 6223 | { | ||
| 6224 | int cpu = (long)hcpu; | ||
| 6225 | |||
| 6226 | switch (action & ~CPU_TASKS_FROZEN) { | ||
| 6227 | case CPU_ONLINE: | ||
| 6228 | sched_domains_numa_masks_set(cpu); | ||
| 6229 | break; | ||
| 6230 | |||
| 6231 | case CPU_DEAD: | ||
| 6232 | sched_domains_numa_masks_clear(cpu); | ||
| 6233 | break; | ||
| 6234 | |||
| 6235 | default: | ||
| 6236 | return NOTIFY_DONE; | ||
| 6237 | } | ||
| 6238 | |||
| 6239 | return NOTIFY_OK; | ||
| 6240 | } | ||
| 6193 | #else | 6241 | #else |
| 6194 | static inline void sched_init_numa(void) | 6242 | static inline void sched_init_numa(void) |
| 6195 | { | 6243 | { |
| 6196 | } | 6244 | } |
| 6245 | |||
| 6246 | static int sched_domains_numa_masks_update(struct notifier_block *nfb, | ||
| 6247 | unsigned long action, | ||
| 6248 | void *hcpu) | ||
| 6249 | { | ||
| 6250 | return 0; | ||
| 6251 | } | ||
| 6197 | #endif /* CONFIG_NUMA */ | 6252 | #endif /* CONFIG_NUMA */ |
| 6198 | 6253 | ||
| 6199 | static int __sdt_alloc(const struct cpumask *cpu_map) | 6254 | static int __sdt_alloc(const struct cpumask *cpu_map) |
| @@ -6642,6 +6697,7 @@ void __init sched_init_smp(void) | |||
| 6642 | mutex_unlock(&sched_domains_mutex); | 6697 | mutex_unlock(&sched_domains_mutex); |
| 6643 | put_online_cpus(); | 6698 | put_online_cpus(); |
| 6644 | 6699 | ||
| 6700 | hotcpu_notifier(sched_domains_numa_masks_update, CPU_PRI_SCHED_ACTIVE); | ||
| 6645 | hotcpu_notifier(cpuset_cpu_active, CPU_PRI_CPUSET_ACTIVE); | 6701 | hotcpu_notifier(cpuset_cpu_active, CPU_PRI_CPUSET_ACTIVE); |
| 6646 | hotcpu_notifier(cpuset_cpu_inactive, CPU_PRI_CPUSET_INACTIVE); | 6702 | hotcpu_notifier(cpuset_cpu_inactive, CPU_PRI_CPUSET_INACTIVE); |
| 6647 | 6703 | ||
