diff options
author | Yury Norov <yury.norov@gmail.com> | 2023-01-21 07:24:30 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-02-08 05:20:00 +0300 |
commit | cd7f55359c90a4108e6528e326b8623fce1ad72a (patch) | |
tree | ee6f3686234c12a3cc9e1685dd375753b08e810b /include/linux/topology.h | |
parent | 62f4386e564d31c7d0ed7d835843e2685f99ae71 (diff) | |
download | linux-cd7f55359c90a4108e6528e326b8623fce1ad72a.tar.xz |
sched: add sched_numa_find_nth_cpu()
The function finds Nth set CPU in a given cpumask starting from a given
node.
Leveraging the fact that each hop in sched_domains_numa_masks includes the
same or greater number of CPUs than the previous one, we can use binary
search on hops instead of linear walk, which makes the overall complexity
of O(log n) in terms of number of cpumask_weight() calls.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Peter Lafreniere <peter@n8pjl.ca>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux/topology.h')
-rw-r--r-- | include/linux/topology.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/topology.h b/include/linux/topology.h index 4564faafd0e1..72f264575698 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -245,5 +245,13 @@ static inline const struct cpumask *cpu_cpu_mask(int cpu) return cpumask_of_node(cpu_to_node(cpu)); } +#ifdef CONFIG_NUMA +int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node); +#else +static __always_inline int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node) +{ + return cpumask_nth(cpu, cpus); +} +#endif /* CONFIG_NUMA */ #endif /* _LINUX_TOPOLOGY_H */ |