Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/topology: Introduce for_each_numa_hop_mask()

The recently introduced sched_numa_hop_mask() exposes cpumasks of CPUs
reachable within a given distance budget, wrap the logic for iterating over
all (distance, mask) values inside an iterator macro.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Reviewed-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Valentin Schneider and committed by
Jakub Kicinski
06ac0172 9feae658

+18
+18
include/linux/topology.h
··· 261 261 } 262 262 #endif /* CONFIG_NUMA */ 263 263 264 + /** 265 + * for_each_numa_hop_mask - iterate over cpumasks of increasing NUMA distance 266 + * from a given node. 267 + * @mask: the iteration variable. 268 + * @node: the NUMA node to start the search from. 269 + * 270 + * Requires rcu_lock to be held. 271 + * 272 + * Yields cpu_online_mask for @node == NUMA_NO_NODE. 273 + */ 274 + #define for_each_numa_hop_mask(mask, node) \ 275 + for (unsigned int __hops = 0; \ 276 + mask = (node != NUMA_NO_NODE || __hops) ? \ 277 + sched_numa_hop_mask(node, __hops) : \ 278 + cpu_online_mask, \ 279 + !IS_ERR_OR_NULL(mask); \ 280 + __hops++) 281 + 264 282 #endif /* _LINUX_TOPOLOGY_H */