Re: [PATCH 2/6] sched/topology: Introduce for_each_numa_node() iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 07, 2025 at 09:40:49PM +0100, Andrea Righi wrote:
> +/**
> + * for_each_numa_node - iterate over nodes at increasing distances from a
> + *			given starting node.
> + * @node: the iteration variable and the starting node.
> + * @unvisited: a nodemask to keep track of the unvisited nodes.
> + * @state: state of NUMA nodes to iterate.
> + *
> + * This macro iterates over NUMA node IDs in increasing distance from the
> + * starting @node and yields MAX_NUMNODES when all the nodes have been
> + * visited.
> + *
> + * The difference between for_each_node() and for_each_numa_node() is that
> + * the former allows to iterate over nodes in numerical order, whereas the
> + * latter iterates over nodes in increasing order of distance.
> + *
> + * This complexity of this iterator is O(N^2), where N represents the
> + * number of nodes, as each iteration involves scanning all nodes to
> + * find the one with the shortest distance.
> + *
> + * Requires rcu_lock to be held.
> + */
> +#define for_each_numa_node(node, unvisited, state)				\
> +	for (int start = (node),						\
> +	     node = numa_nearest_nodemask((start), (state), &(unvisited));	\
> +	     node < MAX_NUMNODES;						\
> +	     node_clear(node, (unvisited)),					\
> +	     node = numa_nearest_nodemask((start), (state), &(unvisited)))
> +
>  /**
>   * for_each_numa_hop_mask - iterate over cpumasks of increasing NUMA distance
>   *                          from a given node.

Bikeshedding: Maybe this has already been argued back and forth but I find
the distinction between for_each_node() and for_each_numa_node() way too
subtle. I wouldn't suspect that they are doing different things when
glancing through their usages in isolation. Can we add *something* to the
name that indicates that this is iteration by distance? The next one uses
"hop" which is fine, "_by_dist" can be fine too, or even "_from_nearest". I
don't really care which but let's make the name clearly signal what it's
doing.

Thanks.

-- 
tejun




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux