diff options
| author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2006-08-05 15:14:58 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-08-06 11:57:48 -0400 |
| commit | 6f712711dbd180aa3777efe5ae3b9b0e915b9471 (patch) | |
| tree | afc406afbc330641eb66029e5c9c6d201be847c3 | |
| parent | 94f563c426a78c97fc2a377315995e6ec8343872 (diff) | |
[PATCH] memory hotadd fixes: not-aligned memory hotadd handling fix
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>
| -rw-r--r-- | mm/memory_hotplug.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 01c9fb97c619..7d25cc12235f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
| @@ -76,15 +76,22 @@ int __add_pages(struct zone *zone, unsigned long phys_start_pfn, | |||
| 76 | { | 76 | { |
| 77 | unsigned long i; | 77 | unsigned long i; |
| 78 | int err = 0; | 78 | int err = 0; |
| 79 | int start_sec, end_sec; | ||
| 80 | /* during initialize mem_map, align hot-added range to section */ | ||
| 81 | start_sec = pfn_to_section_nr(phys_start_pfn); | ||
| 82 | end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1); | ||
| 79 | 83 | ||
| 80 | for (i = 0; i < nr_pages; i += PAGES_PER_SECTION) { | 84 | for (i = start_sec; i <= end_sec; i++) { |
| 81 | err = __add_section(zone, phys_start_pfn + i); | 85 | err = __add_section(zone, i << PFN_SECTION_SHIFT); |
| 82 | 86 | ||
| 83 | /* We want to keep adding the rest of the | 87 | /* |
| 84 | * sections if the first ones already exist | 88 | * EEXIST is finally dealed with by ioresource collision |
| 89 | * check. see add_memory() => register_memory_resource() | ||
| 90 | * Warning will be printed if there is collision. | ||
| 85 | */ | 91 | */ |
| 86 | if (err && (err != -EEXIST)) | 92 | if (err && (err != -EEXIST)) |
| 87 | break; | 93 | break; |
| 94 | err = 0; | ||
| 88 | } | 95 | } |
| 89 | 96 | ||
| 90 | return err; | 97 | return err; |
| @@ -213,10 +220,10 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat) | |||
| 213 | } | 220 | } |
| 214 | 221 | ||
| 215 | /* add this memory to iomem resource */ | 222 | /* add this memory to iomem resource */ |
| 216 | static void register_memory_resource(u64 start, u64 size) | 223 | static int register_memory_resource(u64 start, u64 size) |
| 217 | { | 224 | { |
| 218 | struct resource *res; | 225 | struct resource *res; |
| 219 | 226 | int ret = 0; | |
| 220 | res = kzalloc(sizeof(struct resource), GFP_KERNEL); | 227 | res = kzalloc(sizeof(struct resource), GFP_KERNEL); |
| 221 | BUG_ON(!res); | 228 | BUG_ON(!res); |
| 222 | 229 | ||
| @@ -228,7 +235,9 @@ static void register_memory_resource(u64 start, u64 size) | |||
| 228 | printk("System RAM resource %llx - %llx cannot be added\n", | 235 | printk("System RAM resource %llx - %llx cannot be added\n", |
| 229 | (unsigned long long)res->start, (unsigned long long)res->end); | 236 | (unsigned long long)res->start, (unsigned long long)res->end); |
| 230 | kfree(res); | 237 | kfree(res); |
| 238 | ret = -EEXIST; | ||
| 231 | } | 239 | } |
| 240 | return ret; | ||
| 232 | } | 241 | } |
| 233 | 242 | ||
| 234 | 243 | ||
| @@ -269,7 +278,7 @@ int add_memory(int nid, u64 start, u64 size) | |||
| 269 | } | 278 | } |
| 270 | 279 | ||
| 271 | /* register this memory as resource */ | 280 | /* register this memory as resource */ |
| 272 | register_memory_resource(start, size); | 281 | ret = register_memory_resource(start, size); |
| 273 | 282 | ||
| 274 | return ret; | 283 | return ret; |
| 275 | error: | 284 | error: |
