Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 debug updates from Ingo Molnar:
"Various fixes to the NUMA emulation code"

* 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/numa_emulation: Recalculate numa_nodes_parsed from emulated nodes
x86/numa_emulation: Assign physnode_mask directly from numa_nodes_parsed
x86/numa_emulation: Refine the calculation of max_emu_nid and dfl_phys_nid

+32 -23
+32 -23
arch/x86/mm/numa_emulation.c
··· 75 75 76 76 /* 77 77 * Sets up nr_nodes fake nodes interleaved over physical nodes ranging from addr 78 - * to max_addr. The return value is the number of nodes allocated. 78 + * to max_addr. 79 + * 80 + * Returns zero on success or negative on error. 79 81 */ 80 82 static int __init split_nodes_interleave(struct numa_meminfo *ei, 81 83 struct numa_meminfo *pi, 82 84 u64 addr, u64 max_addr, int nr_nodes) 83 85 { 84 - nodemask_t physnode_mask = NODE_MASK_NONE; 86 + nodemask_t physnode_mask = numa_nodes_parsed; 85 87 u64 size; 86 88 int big; 87 89 int nid = 0; ··· 117 115 "NUMA emulation disabled.\n"); 118 116 return -1; 119 117 } 120 - 121 - for (i = 0; i < pi->nr_blks; i++) 122 - node_set(pi->blk[i].nid, physnode_mask); 123 118 124 119 /* 125 120 * Continue to fill physical nodes with fake nodes until there is no ··· 199 200 200 201 /* 201 202 * Sets up fake nodes of `size' interleaved over physical nodes ranging from 202 - * `addr' to `max_addr'. The return value is the number of nodes allocated. 203 + * `addr' to `max_addr'. 204 + * 205 + * Returns zero on success or negative on error. 203 206 */ 204 207 static int __init split_nodes_size_interleave(struct numa_meminfo *ei, 205 208 struct numa_meminfo *pi, 206 209 u64 addr, u64 max_addr, u64 size) 207 210 { 208 - nodemask_t physnode_mask = NODE_MASK_NONE; 211 + nodemask_t physnode_mask = numa_nodes_parsed; 209 212 u64 min_size; 210 213 int nid = 0; 211 214 int i, ret; ··· 231 230 size = min_size; 232 231 } 233 232 size &= FAKE_NODE_MIN_HASH_MASK; 234 - 235 - for (i = 0; i < pi->nr_blks; i++) 236 - node_set(pi->blk[i].nid, physnode_mask); 237 233 238 234 /* 239 235 * Fill physical nodes with fake nodes of size until there is no memory ··· 276 278 } 277 279 } 278 280 return 0; 281 + } 282 + 283 + int __init setup_emu2phys_nid(int *dfl_phys_nid) 284 + { 285 + int i, max_emu_nid = 0; 286 + 287 + *dfl_phys_nid = NUMA_NO_NODE; 288 + for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) { 289 + if (emu_nid_to_phys[i] != NUMA_NO_NODE) { 290 + max_emu_nid = i; 291 + if (*dfl_phys_nid == NUMA_NO_NODE) 292 + *dfl_phys_nid = emu_nid_to_phys[i]; 293 + } 294 + } 295 + 296 + return max_emu_nid; 279 297 } 280 298 281 299 /** ··· 390 376 * Determine the max emulated nid and the default phys nid to use 391 377 * for unmapped nodes. 392 378 */ 393 - max_emu_nid = 0; 394 - dfl_phys_nid = NUMA_NO_NODE; 395 - for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) { 396 - if (emu_nid_to_phys[i] != NUMA_NO_NODE) { 397 - max_emu_nid = i; 398 - if (dfl_phys_nid == NUMA_NO_NODE) 399 - dfl_phys_nid = emu_nid_to_phys[i]; 400 - } 401 - } 402 - if (dfl_phys_nid == NUMA_NO_NODE) { 403 - pr_warning("NUMA: Warning: can't determine default physical node, disabling emulation\n"); 404 - goto no_emu; 405 - } 379 + max_emu_nid = setup_emu2phys_nid(&dfl_phys_nid); 406 380 407 381 /* commit */ 408 382 *numa_meminfo = ei; 383 + 384 + /* Make sure numa_nodes_parsed only contains emulated nodes */ 385 + nodes_clear(numa_nodes_parsed); 386 + for (i = 0; i < ARRAY_SIZE(ei.blk); i++) 387 + if (ei.blk[i].start != ei.blk[i].end && 388 + ei.blk[i].nid != NUMA_NO_NODE) 389 + node_set(ei.blk[i].nid, numa_nodes_parsed); 409 390 410 391 /* 411 392 * Transform __apicid_to_node table to use emulated nids by