Re: [PATCH 1/6] sched/topology: introduce for_each_numa_hop_node() / sched_numa_hop_node()
From: Tejun Heo
Date: Tue Dec 17 2024 - 17:08:55 EST
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.
Thanks.
--
tejun