[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6Z_S6UDg80LUQEi@slm.duckdns.org>
Date: Fri, 7 Feb 2025 11:46:51 -1000
From: Tejun Heo <tj@...nel.org>
To: Andrea Righi <arighi@...dia.com>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>, Ian May <ianm@...dia.com>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
Yury Norov <yury.norov@...il.com>
Subject: Re: [PATCH 2/6] sched/topology: Introduce for_each_numa_node()
iterator
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
Powered by blists - more mailing lists