x86-64, NUMA: Clean up initmem_init()
This patch cleans initmem_init() so that it is more readable and doesn't use an unnecessary array of function pointers to convolute the flow of the code. It also makes it obvious that dummy_numa_init() will always succeed (and documents that requirement) so that the existing BUG() is never actually reached. No functional change. -tj: Updated comment for dummy_numa_init() slightly. Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
51b361b400
commit
c09cedf4f7
|
@ -562,6 +562,15 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dummy_numma_init - Fallback dummy NUMA init
|
||||||
|
*
|
||||||
|
* Used if there's no underlying NUMA architecture, NUMA initialization
|
||||||
|
* fails, or NUMA is disabled on the command line.
|
||||||
|
*
|
||||||
|
* Must online at least one node and add memory blocks that cover all
|
||||||
|
* allowed memory. This function must not fail.
|
||||||
|
*/
|
||||||
static int __init dummy_numa_init(void)
|
static int __init dummy_numa_init(void)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "%s\n",
|
printk(KERN_INFO "%s\n",
|
||||||
|
@ -575,26 +584,13 @@ static int __init dummy_numa_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init initmem_init(void)
|
static int __init numa_init(int (*init_func)(void))
|
||||||
{
|
{
|
||||||
int (*numa_init[])(void) = { [2] = dummy_numa_init };
|
int i;
|
||||||
int i, j;
|
int ret;
|
||||||
|
|
||||||
if (!numa_off) {
|
for (i = 0; i < MAX_LOCAL_APIC; i++)
|
||||||
#ifdef CONFIG_ACPI_NUMA
|
set_apicid_to_node(i, NUMA_NO_NODE);
|
||||||
numa_init[0] = x86_acpi_numa_init;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_AMD_NUMA
|
|
||||||
numa_init[1] = amd_numa_init;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(numa_init); i++) {
|
|
||||||
if (!numa_init[i])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (j = 0; j < MAX_LOCAL_APIC; j++)
|
|
||||||
set_apicid_to_node(j, NUMA_NO_NODE);
|
|
||||||
|
|
||||||
nodes_clear(numa_nodes_parsed);
|
nodes_clear(numa_nodes_parsed);
|
||||||
nodes_clear(node_possible_map);
|
nodes_clear(node_possible_map);
|
||||||
|
@ -603,29 +599,49 @@ void __init initmem_init(void)
|
||||||
remove_all_active_ranges();
|
remove_all_active_ranges();
|
||||||
numa_reset_distance();
|
numa_reset_distance();
|
||||||
|
|
||||||
if (numa_init[i]() < 0)
|
ret = init_func();
|
||||||
continue;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
if (numa_cleanup_meminfo(&numa_meminfo) < 0)
|
ret = numa_cleanup_meminfo(&numa_meminfo);
|
||||||
continue;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
numa_emulation(&numa_meminfo, numa_distance_cnt);
|
numa_emulation(&numa_meminfo, numa_distance_cnt);
|
||||||
|
|
||||||
if (numa_register_memblks(&numa_meminfo) < 0)
|
ret = numa_register_memblks(&numa_meminfo);
|
||||||
continue;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
for (j = 0; j < nr_cpu_ids; j++) {
|
for (i = 0; i < nr_cpu_ids; i++) {
|
||||||
int nid = early_cpu_to_node(j);
|
int nid = early_cpu_to_node(i);
|
||||||
|
|
||||||
if (nid == NUMA_NO_NODE)
|
if (nid == NUMA_NO_NODE)
|
||||||
continue;
|
continue;
|
||||||
if (!node_online(nid))
|
if (!node_online(nid))
|
||||||
numa_clear_node(j);
|
numa_clear_node(i);
|
||||||
}
|
}
|
||||||
numa_init_array();
|
numa_init_array();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __init initmem_init(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!numa_off) {
|
||||||
|
#ifdef CONFIG_ACPI_NUMA
|
||||||
|
ret = numa_init(x86_acpi_numa_init);
|
||||||
|
if (!ret)
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_AMD_NUMA
|
||||||
|
ret = numa_init(amd_numa_init);
|
||||||
|
if (!ret)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
BUG();
|
|
||||||
|
numa_init(dummy_numa_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long __init numa_free_all_bootmem(void)
|
unsigned long __init numa_free_all_bootmem(void)
|
||||||
|
|
Loading…
Reference in New Issue