summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/sched/isolation.c12
-rw-r--r--kernel/sched/sched.h8
-rw-r--r--kernel/sched/topology.c20
3 files changed, 35 insertions, 5 deletions
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index ccb28085b114..9fcb2a695a41 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -22,9 +22,17 @@ EXPORT_SYMBOL_GPL(housekeeping_enabled);
22 22
23int housekeeping_any_cpu(enum hk_flags flags) 23int housekeeping_any_cpu(enum hk_flags flags)
24{ 24{
25 if (static_branch_unlikely(&housekeeping_overridden)) 25 int cpu;
26 if (housekeeping_flags & flags) 26
27 if (static_branch_unlikely(&housekeeping_overridden)) {
28 if (housekeeping_flags & flags) {
29 cpu = sched_numa_find_closest(housekeeping_mask, smp_processor_id());
30 if (cpu < nr_cpu_ids)
31 return cpu;
32
27 return cpumask_any_and(housekeeping_mask, cpu_online_mask); 33 return cpumask_any_and(housekeeping_mask, cpu_online_mask);
34 }
35 }
28 return smp_processor_id(); 36 return smp_processor_id();
29} 37}
30EXPORT_SYMBOL_GPL(housekeeping_any_cpu); 38EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index aaca0e743776..16126efd14ed 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1262,16 +1262,18 @@ enum numa_topology_type {
1262extern enum numa_topology_type sched_numa_topology_type; 1262extern enum numa_topology_type sched_numa_topology_type;
1263extern int sched_max_numa_distance; 1263extern int sched_max_numa_distance;
1264extern bool find_numa_distance(int distance); 1264extern bool find_numa_distance(int distance);
1265#endif
1266
1267#ifdef CONFIG_NUMA
1268extern void sched_init_numa(void); 1265extern void sched_init_numa(void);
1269extern void sched_domains_numa_masks_set(unsigned int cpu); 1266extern void sched_domains_numa_masks_set(unsigned int cpu);
1270extern void sched_domains_numa_masks_clear(unsigned int cpu); 1267extern void sched_domains_numa_masks_clear(unsigned int cpu);
1268extern int sched_numa_find_closest(const struct cpumask *cpus, int cpu);
1271#else 1269#else
1272static inline void sched_init_numa(void) { } 1270static inline void sched_init_numa(void) { }
1273static inline void sched_domains_numa_masks_set(unsigned int cpu) { } 1271static inline void sched_domains_numa_masks_set(unsigned int cpu) { }
1274static inline void sched_domains_numa_masks_clear(unsigned int cpu) { } 1272static inline void sched_domains_numa_masks_clear(unsigned int cpu) { }
1273static inline int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
1274{
1275 return nr_cpu_ids;
1276}
1275#endif 1277#endif
1276 1278
1277#ifdef CONFIG_NUMA_BALANCING 1279#ifdef CONFIG_NUMA_BALANCING
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index f751ce0b783e..4eea2c9bc732 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1724,6 +1724,26 @@ void sched_domains_numa_masks_clear(unsigned int cpu)
1724 } 1724 }
1725} 1725}
1726 1726
1727/*
1728 * sched_numa_find_closest() - given the NUMA topology, find the cpu
1729 * closest to @cpu from @cpumask.
1730 * cpumask: cpumask to find a cpu from
1731 * cpu: cpu to be close to
1732 *
1733 * returns: cpu, or nr_cpu_ids when nothing found.
1734 */
1735int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
1736{
1737 int i, j = cpu_to_node(cpu);
1738
1739 for (i = 0; i < sched_domains_numa_levels; i++) {
1740 cpu = cpumask_any_and(cpus, sched_domains_numa_masks[i][j]);
1741 if (cpu < nr_cpu_ids)
1742 return cpu;
1743 }
1744 return nr_cpu_ids;
1745}
1746
1727#endif /* CONFIG_NUMA */ 1747#endif /* CONFIG_NUMA */
1728 1748
1729static int __sdt_alloc(const struct cpumask *cpu_map) 1749static int __sdt_alloc(const struct cpumask *cpu_map)