Skip to content

Commit 4fcbe96

Browse files
committed
mm/numa: Skip NUMA_NO_NODE and online nodes in numa_map_to_online_node()
Update numa_map_to_online_node() to stop falling back to numa node 0 when the input is NUMA_NO_NODE. Also, skip the lookup if @node is online. This makes the routine compatible with other arch node mapping routines. Reported-by: Aneesh Kumar K.V <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Link: https://lore.kernel.org/r/157401275716.43284.13185549705765009174.stgit@dwillia2-desk3.amr.corp.intel.com Reviewed-by: Ingo Molnar <[email protected]> Signed-off-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/158188325316.894464.15650888748083329531.stgit@dwillia2-desk3.amr.corp.intel.com
1 parent b2ca916 commit 4fcbe96

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

mm/mempolicy.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,17 @@ static struct mempolicy preferred_node_policy[MAX_NUMNODES];
135135
*/
136136
int numa_map_to_online_node(int node)
137137
{
138-
int min_node;
138+
int min_dist = INT_MAX, dist, n, min_node;
139139

140-
if (node == NUMA_NO_NODE)
141-
node = 0;
140+
if (node == NUMA_NO_NODE || node_online(node))
141+
return node;
142142

143143
min_node = node;
144-
if (!node_online(node)) {
145-
int min_dist = INT_MAX, dist, n;
146-
147-
for_each_online_node(n) {
148-
dist = node_distance(node, n);
149-
if (dist < min_dist) {
150-
min_dist = dist;
151-
min_node = n;
152-
}
144+
for_each_online_node(n) {
145+
dist = node_distance(node, n);
146+
if (dist < min_dist) {
147+
min_dist = dist;
148+
min_node = n;
153149
}
154150
}
155151

0 commit comments

Comments
 (0)