[PATCH 3/6] page_alloc: Introduce zone_movable_limit[] to keepmovable limit for nodes

From: Jiang Liu
Date: Wed Dec 05 2012 - 10:58:42 EST


This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.

Signed-off-by: Tang Chen <tangchen@xxxxxxxxxxxxxx>
Reviewed-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
Reviewed-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Tested-by: Lin Feng <linfeng@xxxxxxxxxxxxxx>

page_alloc: Make movablecore_map has higher priority

If kernelcore or movablecore is specified at the same time
with movablecore_map, movablecore_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 <tangchen@xxxxxxxxxxxxxx>
Reviewed-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
Reviewed-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Tested-by: Lin Feng <linfeng@xxxxxxxxxxxxxx>
---
mm/page_alloc.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 65 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e35ee27..41c3b51 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4338,6 +4338,60 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
}

+/**
+ * Try to figure out zone_movable_pfn[] from movablecore_map.
+ */
+static int __init find_zone_movable_from_movablecore_map(void)
+{
+ int map_pos = 0, i, nid;
+ unsigned long start_pfn, end_pfn;
+
+ if (!movablecore_map.nr_map)
+ return 0;
+
+ /* Iterate all ranges from minimum to maximum */
+ for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {
+ /*
+ * If we have found lowest pfn of ZONE_MOVABLE of the node
+ * specified by user, just go on to check next range.
+ */
+ if (zone_movable_pfn[nid])
+ continue;
+
+#ifdef CONFIG_HIGHMEM
+ /* Skip lowmem if ZONE_MOVABLE is highmem */
+ if (zone_movable_is_highmem() &&
+ start_pfn < arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
+ start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+ if (start_pfn > end_pfn)
+ continue;
+#endif
+
+ while (map_pos < movablecore_map.nr_map) {
+ if (end_pfn < movablecore_map.map[map_pos].start)
+ break;
+
+ if (start_pfn > movablecore_map.map[map_pos].end) {
+ map_pos++;
+ continue;
+ }
+
+ /*
+ * The start_pfn of ZONE_MOVABLE is either the minimum
+ * pfn specified by movablecore_map, or 0, which means
+ * the node has no ZONE_MOVABLE.
+ */
+ start_pfn = max(start_pfn,
+ movablecore_map.map[map_pos].start);
+ zone_movable_pfn[nid] = roundup(zone_movable_pfn[nid],
+ MAX_ORDER_NR_PAGES);
+ break;
+ }
+ }
+
+ return 1;
+}
+
#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
unsigned long zone_type,
@@ -4356,6 +4410,11 @@ static inline unsigned long __meminit zone_absent_pages_in_node(int nid,
return zholes_size[zone_type];
}

+static int __init find_zone_movable_from_movablecore_map(void)
+{
+ return 0;
+}
+
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */

static void __meminit calculate_node_totalpages(struct pglist_data *pgdat,
@@ -4739,6 +4798,12 @@ static void __init find_zone_movable_pfns_for_nodes(void)
unsigned long totalpages = early_calculate_totalpages();
int usable_nodes = nodes_weight(node_states[N_HIGH_MEMORY]);

+ find_usable_zone_for_movable();
+
+ /* movablecore_map takes precedence over movablecore/kernelcore */
+ if (find_zone_movable_from_movablecore_map())
+ return;
+
/*
* If movablecore was specified, calculate what size of
* kernelcore that corresponds so that memory usable for
@@ -4766,7 +4831,6 @@ static void __init find_zone_movable_pfns_for_nodes(void)
goto out;

/* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */
- find_usable_zone_for_movable();
usable_startpfn = arch_zone_lowest_possible_pfn[movable_zone];

restart:
--
1.7.9.5


--------------000405000507070407010101--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/