]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] memory hotadd fixes: not-aligned memory hotadd handling fix
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Sat, 5 Aug 2006 19:14:58 +0000 (12:14 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 6 Aug 2006 15:57:48 +0000 (08:57 -0700)
ioresouce handling code in memory hotplug allows not-aligned memory hot add.
But when memmap and other memory structures are initialized, parameters should
be aligned.  (if not aligned, initialization of mem_map will do wrong, it
assumes parameters are aligned.) This patch fix it.

And this patch allows ioresource collision check to handle -EEXIST.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Keith Mannthey <kmannth@gmail.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/memory_hotplug.c

index 01c9fb97c619135edce3431d265e397f49113b58..7d25cc12235f377c5cc15e4eb5bbd8dccca763fc 100644 (file)
@@ -76,15 +76,22 @@ int __add_pages(struct zone *zone, unsigned long phys_start_pfn,
 {
        unsigned long i;
        int err = 0;
+       int start_sec, end_sec;
+       /* during initialize mem_map, align hot-added range to section */
+       start_sec = pfn_to_section_nr(phys_start_pfn);
+       end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1);
 
-       for (i = 0; i < nr_pages; i += PAGES_PER_SECTION) {
-               err = __add_section(zone, phys_start_pfn + i);
+       for (i = start_sec; i <= end_sec; i++) {
+               err = __add_section(zone, i << PFN_SECTION_SHIFT);
 
-               /* We want to keep adding the rest of the
-                * sections if the first ones already exist
+               /*
+                * EEXIST is finally dealed with by ioresource collision
+                * check. see add_memory() => register_memory_resource()
+                * Warning will be printed if there is collision.
                 */
                if (err && (err != -EEXIST))
                        break;
+               err = 0;
        }
 
        return err;
@@ -213,10 +220,10 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
 }
 
 /* add this memory to iomem resource */
-static void register_memory_resource(u64 start, u64 size)
+static int register_memory_resource(u64 start, u64 size)
 {
        struct resource *res;
-
+       int ret = 0;
        res = kzalloc(sizeof(struct resource), GFP_KERNEL);
        BUG_ON(!res);
 
@@ -228,7 +235,9 @@ static void register_memory_resource(u64 start, u64 size)
                printk("System RAM resource %llx - %llx cannot be added\n",
                (unsigned long long)res->start, (unsigned long long)res->end);
                kfree(res);
+               ret = -EEXIST;
        }
+       return ret;
 }
 
 
@@ -269,7 +278,7 @@ int add_memory(int nid, u64 start, u64 size)
        }
 
        /* register this memory as resource */
-       register_memory_resource(start, size);
+       ret = register_memory_resource(start, size);
 
        return ret;
 error: