Commit b2cebaeb authored by Mao Minkai's avatar Mao Minkai Committed by guzitao
Browse files

sw64: fix numa setup when acpi is disabled

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

If acpi is disabled and there's no memory on 2nd node, the 2nd node
would not be registered and all cpus would be registered to the 1st
node. Fix this issue by moving cpu_set_node() inside numa_init() and
make it set numa_nodes_parsed.

Signed-off-by: default avatarMao Minkai <maominkai@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent ee73c744
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -382,10 +382,6 @@ static int __init request_standard_resources(void)
}
subsys_initcall(request_standard_resources);

#ifdef CONFIG_NUMA
extern void cpu_set_node(void);
#endif

static int __init topology_init(void)
{
	int i, ret;
@@ -733,12 +729,6 @@ setup_arch(char **cmdline_p)

	/* Default root filesystem to sda2.  */
	ROOT_DEV = MKDEV(SCSI_DISK0_MAJOR, 2);

	if (acpi_disabled) {
#ifdef CONFIG_NUMA
		cpu_set_node();
#endif
	}
}

static int
+24 −31
Original line number Diff line number Diff line
@@ -289,6 +289,28 @@ static void __init get_numa_info_socket(void)
	}
}

static void cpu_set_node(void)
{
	int i;

	if (numa_off) {
		for (i = 0; i < nr_cpu_ids; i++)
			cpu_to_node_map[i] = 0;
	} else {
		for (i = 0; i < nr_cpu_ids; i++) {
			int nid = rcid_to_domain_id(cpu_to_rcid(i));

			cpu_to_node_map[i] = nid;
			node_set(nid, numa_nodes_parsed);
		}
	}
	/*
	 * Setup numa_node for cpu 0 before per_cpu area for booting.
	 * Actual setup of numa_node will be done in native_smp_prepare_cpus().
	 */
	set_cpu_numa_node(0, cpu_to_node_map[0]);
}

static int __init manual_numa_init(void)
{
	int ret, nid;
@@ -350,6 +372,8 @@ static int __init manual_numa_init(void)
		}
	}

	cpu_set_node();

	return 0;
}

@@ -385,37 +409,6 @@ void __init sw64_numa_init(void)
	numa_init(manual_numa_init);
}

void cpu_set_node(void)
{
	int i;

	if (numa_off) {
		for (i = 0; i < nr_cpu_ids; i++)
			cpu_to_node_map[i] = 0;
	} else {
		int rr, default_node, cid;

		rr = first_node(node_online_map);
		for (i = 0; i < nr_cpu_ids; i++) {
			cid = cpu_to_rcid(i);
			default_node = rcid_to_domain_id(cid);
			if (node_online(default_node)) {
				cpu_to_node_map[i] = default_node;
			} else {
				cpu_to_node_map[i] = rr;
				rr = next_node(rr, node_online_map);
				if (rr == MAX_NUMNODES)
					rr = first_node(node_online_map);
			}
		}
	}
	/*
	 * Setup numa_node for cpu 0 before per_cpu area for booting.
	 * Actual setup of numa_node will be done in native_smp_prepare_cpus().
	 */
	set_cpu_numa_node(0, cpu_to_node_map[0]);
}

void numa_store_cpu_info(unsigned int cpu)
{
	set_cpu_numa_node(cpu, cpu_to_node_map[cpu]);