[PATCH] memory hotplug: fix alignment check (Was Re: PROBLEM:__offline_isolated_pages may offline too many pages

From: KAMEZAWA Hiroyuki
Date: Thu Dec 16 2010 - 19:03:18 EST


On Thu, 16 Dec 2010 10:26:41 +0000
Mel Gorman <mel@xxxxxxxxx> wrote:

> Other than the spelling mistakes in the changelog and the lack of a
> subject;
>
> Acked-by: Mel Gorman <mel@xxxxxxxxx>
>
Thank you. fixed one.
==

offline_pages()'s sanity check of given range is wrong. It should
be aligned to MAX_ORDER. Current existing caller uses SECTION_SIZE
alignment, so this change has no influence to existing callers.

Reported-by: Ingo Korb <ingo@xxxxxxxx>
Acked-by: Mel Gorman <mel@xxxxxxxxx>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
---
mm/memory_hotplug.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.37-rc5/mm/memory_hotplug.c
===================================================================
--- linux-2.6.37-rc5.orig/mm/memory_hotplug.c
+++ linux-2.6.37-rc5/mm/memory_hotplug.c
@@ -798,10 +798,14 @@ static int offline_pages(unsigned long s
struct memory_notify arg;

BUG_ON(start_pfn >= end_pfn);
- /* at least, alignment against pageblock is necessary */
- if (!IS_ALIGNED(start_pfn, pageblock_nr_pages))
+ /*
+ * Considering Buddy system which joins nearby pages, the range
+ * in offline should be aligned to MAX_ORDER. If not, isolated
+ * page will be joined to other (not isolated) pages.
+ */
+ if (!IS_ALIGNED(start_pfn, MAX_ORDER_NR_PAGES))
return -EINVAL;
- if (!IS_ALIGNED(end_pfn, pageblock_nr_pages))
+ if (!IS_ALIGNED(end_pfn, MAX_ORDER_NR_PAGES))
return -EINVAL;
/* This makes hotplug much easier...and readable.
we assume this for now. .*/


--
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/