From: Dan Williams Date: Sun, 16 Feb 2020 20:00:53 +0000 (-0800) Subject: mm/numa: Skip NUMA_NO_NODE and online nodes in numa_map_to_online_node() X-Git-Tag: v5.7-rc1~45^2~1^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4fcbe96e4d0bc4abe22ee10573ff663b9ebbcf17;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Aneesh Kumar K.V Link: https://lore.kernel.org/r/157401275716.43284.13185549705765009174.stgit@dwillia2-desk3.amr.corp.intel.com Reviewed-by: Ingo Molnar Signed-off-by: Dan Williams Link: https://lore.kernel.org/r/158188325316.894464.15650888748083329531.stgit@dwillia2-desk3.amr.corp.intel.com --- diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 756d6e5bb59f9..19f7e71945a72 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -135,21 +135,17 @@ static struct mempolicy preferred_node_policy[MAX_NUMNODES]; */ int numa_map_to_online_node(int node) { - int min_node; + int min_dist = INT_MAX, dist, n, min_node; - if (node == NUMA_NO_NODE) - node = 0; + if (node == NUMA_NO_NODE || node_online(node)) + return node; min_node = node; - if (!node_online(node)) { - int min_dist = INT_MAX, dist, n; - - for_each_online_node(n) { - dist = node_distance(node, n); - if (dist < min_dist) { - min_dist = dist; - min_node = n; - } + for_each_online_node(n) { + dist = node_distance(node, n); + if (dist < min_dist) { + min_dist = dist; + min_node = n; } }