@@ -4905,9 +4905,17 @@ static void __init find_zone_movable_pfns_for_nodes(void)
4905
4905
required_kernelcore = max (required_kernelcore , corepages );
4906
4906
}
4907
4907
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 ));
4910
4917
goto out ;
4918
+ }
4911
4919
4912
4920
/* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */
4913
4921
usable_startpfn = arch_zone_lowest_possible_pfn [movable_zone ];
@@ -4937,10 +4945,24 @@ static void __init find_zone_movable_pfns_for_nodes(void)
4937
4945
for_each_mem_pfn_range (i , nid , & start_pfn , & end_pfn , NULL ) {
4938
4946
unsigned long size_pages ;
4939
4947
4948
+ /*
4949
+ * Find more memory for kernelcore in
4950
+ * [zone_movable_pfn[nid], zone_movable_limit[nid]).
4951
+ */
4940
4952
start_pfn = max (start_pfn , zone_movable_pfn [nid ]);
4941
4953
if (start_pfn >= end_pfn )
4942
4954
continue ;
4943
4955
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
+
4944
4966
/* Account for what is only usable for kernelcore */
4945
4967
if (start_pfn < usable_startpfn ) {
4946
4968
unsigned long kernel_pages ;
@@ -5000,12 +5022,12 @@ static void __init find_zone_movable_pfns_for_nodes(void)
5000
5022
if (usable_nodes && required_kernelcore > usable_nodes )
5001
5023
goto restart ;
5002
5024
5025
+ out :
5003
5026
/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
5004
5027
for (nid = 0 ; nid < MAX_NUMNODES ; nid ++ )
5005
5028
zone_movable_pfn [nid ] =
5006
5029
roundup (zone_movable_pfn [nid ], MAX_ORDER_NR_PAGES );
5007
5030
5008
- out :
5009
5031
/* restore the node_state */
5010
5032
node_states [N_MEMORY ] = saved_node_state ;
5011
5033
}
0 commit comments