Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69efcc6d authored by Yinghai Lu's avatar Yinghai Lu Committed by Tejun Heo
Browse files

x86-64, NUMA: Do not scan two times for setup_node_bootmem()



By the time setup_node_bootmem() is called, all the memblocks are
already registered.  As node_data is allocated from these memblocks,
calling it more than once doesn't make any difference.  Drop the loop.

tj: Dropped comment referencing to the old behavior as suggested by
    David and rephrased the description.

Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 6d496f9f
Loading
Loading
Loading
Loading
+12 −20
Original line number Original line Diff line number Diff line
@@ -480,7 +480,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)


static int __init numa_register_memblks(struct numa_meminfo *mi)
static int __init numa_register_memblks(struct numa_meminfo *mi)
{
{
	int i, j, nid;
	int i, nid;


	/* Account for nodes with cpus and no memory */
	/* Account for nodes with cpus and no memory */
	node_possible_map = numa_nodes_parsed;
	node_possible_map = numa_nodes_parsed;
@@ -506,29 +506,21 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)


	init_memory_mapping_high();
	init_memory_mapping_high();


	/*
	/* Finally register nodes. */
	 * Finally register nodes.  Do it twice in case setup_node_bootmem
	 * missed one due to missing bootmem.
	 */
	for (i = 0; i < 2; i++) {
	for_each_node_mask(nid, node_possible_map) {
	for_each_node_mask(nid, node_possible_map) {
		u64 start = (u64)max_pfn << PAGE_SHIFT;
		u64 start = (u64)max_pfn << PAGE_SHIFT;
		u64 end = 0;
		u64 end = 0;


			if (node_online(nid))
		for (i = 0; i < mi->nr_blks; i++) {
				continue;
			if (nid != mi->blk[i].nid)

			for (j = 0; j < mi->nr_blks; j++) {
				if (nid != mi->blk[j].nid)
				continue;
				continue;
				start = min(mi->blk[j].start, start);
			start = min(mi->blk[i].start, start);
				end = max(mi->blk[j].end, end);
			end = max(mi->blk[i].end, end);
		}
		}


		if (start < end)
		if (start < end)
			setup_node_bootmem(nid, start, end);
			setup_node_bootmem(nid, start, end);
	}
	}
	}


	return 0;
	return 0;
}
}