Skip to content

Commit 42f47e2

Browse files
tang-chentorvalds
authored andcommitted
page_alloc: make movablemem_map have higher priority
If kernelcore or movablecore is specified at the same time with movablemem_map, movablemem_map will have higher priority to be satisfied. This patch will make find_zone_movable_pfns_for_nodes() calculate zone_movable_pfn[] with the limit from zone_movable_limit[]. Signed-off-by: Tang Chen <[email protected]> Reviewed-by: Wen Congyang <[email protected]> Cc: Wu Jianguo <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Tested-by: Lin Feng <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6981ec3 commit 42f47e2

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

mm/page_alloc.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4905,9 +4905,17 @@ static void __init find_zone_movable_pfns_for_nodes(void)
49054905
required_kernelcore = max(required_kernelcore, corepages);
49064906
}
49074907

4908-
/* If kernelcore was not specified, there is no ZONE_MOVABLE */
4909-
if (!required_kernelcore)
4908+
/*
4909+
* If neither kernelcore/movablecore nor movablemem_map is specified,
4910+
* there is no ZONE_MOVABLE. But if movablemem_map is specified, the
4911+
* start pfn of ZONE_MOVABLE has been stored in zone_movable_limit[].
4912+
*/
4913+
if (!required_kernelcore) {
4914+
if (movablemem_map.nr_map)
4915+
memcpy(zone_movable_pfn, zone_movable_limit,
4916+
sizeof(zone_movable_pfn));
49104917
goto out;
4918+
}
49114919

49124920
/* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */
49134921
usable_startpfn = arch_zone_lowest_possible_pfn[movable_zone];
@@ -4937,10 +4945,24 @@ static void __init find_zone_movable_pfns_for_nodes(void)
49374945
for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
49384946
unsigned long size_pages;
49394947

4948+
/*
4949+
* Find more memory for kernelcore in
4950+
* [zone_movable_pfn[nid], zone_movable_limit[nid]).
4951+
*/
49404952
start_pfn = max(start_pfn, zone_movable_pfn[nid]);
49414953
if (start_pfn >= end_pfn)
49424954
continue;
49434955

4956+
if (zone_movable_limit[nid]) {
4957+
end_pfn = min(end_pfn, zone_movable_limit[nid]);
4958+
/* No range left for kernelcore in this node */
4959+
if (start_pfn >= end_pfn) {
4960+
zone_movable_pfn[nid] =
4961+
zone_movable_limit[nid];
4962+
break;
4963+
}
4964+
}
4965+
49444966
/* Account for what is only usable for kernelcore */
49454967
if (start_pfn < usable_startpfn) {
49464968
unsigned long kernel_pages;
@@ -5000,12 +5022,12 @@ static void __init find_zone_movable_pfns_for_nodes(void)
50005022
if (usable_nodes && required_kernelcore > usable_nodes)
50015023
goto restart;
50025024

5025+
out:
50035026
/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
50045027
for (nid = 0; nid < MAX_NUMNODES; nid++)
50055028
zone_movable_pfn[nid] =
50065029
roundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES);
50075030

5008-
out:
50095031
/* restore the node_state */
50105032
node_states[N_MEMORY] = saved_node_state;
50115033
}

0 commit comments

Comments
 (0)