Re: [PATCH 1/6] sched/topology: introduce for_each_numa_hop_node() / sched_numa_hop_node()
From: Andrea Righi
Date: Wed Dec 18 2024 - 05:23:57 EST
On Tue, Dec 17, 2024 at 11:57:44AM -1000, Tejun Heo wrote:
> Hello,
>
> On Tue, Dec 17, 2024 at 10:32:26AM +0100, Andrea Righi wrote:
> ...
> > +int sched_numa_hop_node(nodemask_t *hop_nodes, int start, unsigned int state)
> > +{
> > + int dist, n, min_node, min_dist;
> > +
> > + if (state >= NR_NODE_STATES)
> > + return NUMA_NO_NODE;
> > +
> > + min_node = NUMA_NO_NODE;
> > + min_dist = INT_MAX;
> > +
> > + for_each_node_state(n, state) {
> > + if (n == start || node_isset(n, *hop_nodes))
> > + continue;
> > + dist = node_distance(start, n);
> > + if (dist < min_dist) {
> > + min_dist = dist;
> > + min_node = n;
> > + }
> > + }
> > + if (min_node != NUMA_NO_NODE)
> > + node_set(min_node, *hop_nodes);
> > +
> > + return min_node;
> > +}
>
> So, this would work but given that there is nothing dynamic about this
> ordering, would it make more sense to build the ordering and store it
> per-node? Then, the iteration just becomes walking that array.
I've also considered doing that. I don't know if it'd work with offline
nodes, but maybe we can just check node_online(node) at each iteration and
skip those that are not online.
-Andrea