Re: [PATCH v2 3/8] sched/topology: add for_each_numa_cpu() macro

From: Valentin Schneider
Date: Tue Apr 25 2023 - 05:55:49 EST


On 19/04/23 22:19, Yury Norov wrote:
> +/**
> + * for_each_numa_cpu - iterate over cpus in increasing order taking into account
> + * NUMA distances from a given node.
> + * @cpu: the (optionally unsigned) integer iterator
> + * @hop: the iterator variable, must be initialized to a desired minimal hop.
> + * @node: the NUMA node to start the search from.
> + * @mask: the cpumask pointer
> + *
> + * Requires rcu_lock to be held.
> + */
> +#define for_each_numa_cpu(cpu, hop, node, mask) \
> + for ((cpu) = 0, (hop) = 0; \
> + (cpu) = sched_numa_find_next_cpu((mask), (cpu), (node), &(hop)),\
> + (cpu) < nr_cpu_ids; \
> + (cpu)++)
> +

I think we can keep sched_numa_find_next_cpu() as-is, but could we make
that macro use cpu_possible_mask by default? We can always add a variant
if/when we need to feed in a different mask.

> #endif /* _LINUX_TOPOLOGY_H */
> --
> 2.34.1