lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6aBRs3STxI7DzYk@gpd3>
Date: Fri, 7 Feb 2025 22:55:18 +0100
From: Andrea Righi <arighi@...dia.com>
To: Tejun Heo <tj@...nel.org>
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 11:46:51AM -1000, Tejun Heo wrote:
> 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.

How about for_each_node_state_by_dist()? It's essentialy a variant of
for_each_node_state(), as it also accepts a state, with the only difference
that node IDs are returned in increasing distance order.

-Andrea

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ