To ensure 1:1 peer node mapping on broken BIOS

        node distances:
        node   0   1   2   3
          0:  10  21  20  20
          1:  21  10  20  20
          2:  20  20  10  20
          3:  20  20  20  10

or with numa=fake=4U

        node distances:
        node   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
          0:  10  10  10  10  21  21  21  21  17  17  17  17  28  28  28  28
          1:  10  10  10  10  21  21  21  21  17  17  17  17  28  28  28  28
          2:  10  10  10  10  21  21  21  21  17  17  17  17  28  28  28  28
          3:  10  10  10  10  21  21  21  21  17  17  17  17  28  28  28  28
          4:  21  21  21  21  10  10  10  10  28  28  28  28  17  17  17  17
          5:  21  21  21  21  10  10  10  10  28  28  28  28  17  17  17  17
          6:  21  21  21  21  10  10  10  10  28  28  28  28  17  17  17  17
          7:  21  21  21  21  10  10  10  10  28  28  28  28  17  17  17  17
          8:  17  17  17  17  28  28  28  28  10  10  10  10  28  28  28  28
          9:  17  17  17  17  28  28  28  28  10  10  10  10  28  28  28  28
         10:  17  17  17  17  28  28  28  28  10  10  10  10  28  28  28  28
         11:  17  17  17  17  28  28  28  28  10  10  10  10  28  28  28  28
         12:  28  28  28  28  17  17  17  17  28  28  28  28  10  10  10  10
         13:  28  28  28  28  17  17  17  17  28  28  28  28  10  10  10  10
         14:  28  28  28  28  17  17  17  17  28  28  28  28  10  10  10  10
         15:  28  28  28  28  17  17  17  17  28  28  28  28  10  10  10  10

Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---
 mm/page_alloc.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- linux.orig/mm/page_alloc.c  2018-12-23 19:48:27.366110325 +0800
+++ linux/mm/page_alloc.c       2018-12-23 19:48:27.362110332 +0800
@@ -6941,16 +6941,22 @@ static int find_best_peer_node(int nid)
        int n, val;
        int min_val = INT_MAX;
        int peer = NUMA_NO_NODE;
+       static nodemask_t target_nodes = NODE_MASK_NONE;
 
        for_each_online_node(n) {
                if (n == nid)
                        continue;
                val = node_distance(nid, n);
+               if (val == LOCAL_DISTANCE)
+                       continue;
+               if (node_isset(n, target_nodes))
+                       continue;
                if (val < min_val) {
                        min_val = val;
                        peer = n;
                }
        }
+       node_set(peer, target_nodes);
        return peer;
 }
 


Reply via email to