Blob Blame History Raw
From: Mel Gorman <mgorman@suse.de>
Date: Thu, 6 Feb 2014 10:28:22 +0000
Subject: [PATCH] mm: Warn users of node memory hot-remove if the memory ratio
 is a high risk

References: Memory node hot-remove (fate#316483), fate#319143, bnc#987598
Patch-mainline: Never, upstream developers refusing to acknowledge problem

Warn users of zone_movable (currently memory hot-remove or mirrored memory) if
lowmem:movable ratio is worse than 1:3. Such a configuration can lead to all sorts
of problems and it would be good to have a reminder that the zone_movable might
be the culprit.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/page_alloc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6991ccec9c32..73b7b90dc02e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5803,6 +5803,31 @@ void __ref build_all_zonelists(pg_data_t *pgdat)
 #ifdef CONFIG_NUMA
 	pr_info("Policy zone: %s\n", zone_names[policy_zone]);
 #endif
+
+	/*
+	 * Check normal :movable ratio when memory node hot-remove/mirrored
+	 * memory is enabled
+	 */
+	if (movable_node_is_enabled()) {
+		unsigned long nr_movable = 0;
+		struct zone *zone;
+
+		for_each_zone(zone) {
+			if (!populated_zone(zone) || zone_idx(zone) != ZONE_MOVABLE)
+				continue;
+
+			nr_movable += zone_managed_pages(zone);
+		}
+
+		/* Warn if lowmem:movable is worse than 1:3 */
+		if ((vm_total_pages >> 2) < nr_movable) {
+			pr_warn("lowmem:movable memory is very high. "
+				"There may be OOM or performance problems if the kernel "
+				"cannot allocate memory as it is all marked "
+				"for movable nodes.\n");
+			WARN_ON_ONCE(1);
+		}
+	}
 }
 
 /* If zone is ZONE_MOVABLE but memory is mirrored, it is an overlapped init */