[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <e0b16cc8349b38a5f3f9.1206664118@localhost>
Date: Thu, 27 Mar 2008 17:28:38 -0700
From: Jeremy Fitzhardinge <jeremy@...p.org>
To: Ingo Molnar <mingo@...e.hu>
Cc: LKML <linux-kernel@...r.kernel.org>,
Rusty Russell <rusty@...tcorp.com.au>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Yasunori Goto <y-goto@...fujitsu.com>,
Christoph Lameter <clameter@....com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 2 of 4] hotplug-memory: adding non-section-aligned memory is
bad
Adding non-section-aligned memory will cause bad results, because page
structures are only built on section-aligned boundaries. Also, memory
whose size isn't a multiple of the section size is silently ignored.
This patch adds a couple of WARN_ONs to help confused programmers work
out what's going wrong when they hotplug memory without being aware of
these constraints.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: Yasunori Goto <y-goto@...fujitsu.com>
Cc: Christoph Lameter <clameter@....com>
Cc: Dave Hansen <dave@...ux.vnet.ibm.com>
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -784,6 +784,9 @@
#define PAGES_PER_SECTION (1UL << PFN_SECTION_SHIFT)
#define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1))
+#define SECTION_SIZE (1UL << SECTION_SIZE_BITS)
+#define SECTION_SIZE_MASK (SECTION_SIZE - 1)
+
#define SECTION_BLOCKFLAGS_BITS \
((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -300,6 +300,11 @@
int ret;
u64 start = res->start;
u64 size = res->end - res->start + 1;
+
+ /* Adding non-section-aligned memory will give unexpected
+ and unintuitive results. */
+ WARN_ON((start & SECTION_SIZE_MASK) != 0);
+ WARN_ON((size & SECTION_SIZE_MASK) != 0);
if (!node_online(nid)) {
pgdat = hotadd_new_pgdat(nid, start);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists