Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

KAMEZAWA Hiroyuki and committed by
Linus Torvalds
6f712711 94f563c4

+16 -7
+16 -7
mm/memory_hotplug.c
··· 76 76 { 77 77 unsigned long i; 78 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) { 81 - err = __add_section(zone, phys_start_pfn + i); 84 + for (i = start_sec; i <= end_sec; i++) { 85 + err = __add_section(zone, i << PFN_SECTION_SHIFT); 82 86 83 - /* We want to keep adding the rest of the 84 - * sections if the first ones already exist 87 + /* 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 92 if (err && (err != -EEXIST)) 87 93 break; 94 + err = 0; 88 95 } 89 96 90 97 return err; ··· 220 213 } 221 214 222 215 /* add this memory to iomem resource */ 223 - static void register_memory_resource(u64 start, u64 size) 216 + static int register_memory_resource(u64 start, u64 size) 224 217 { 225 218 struct resource *res; 226 - 219 + int ret = 0; 227 220 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 228 221 BUG_ON(!res); 229 222 ··· 235 228 printk("System RAM resource %llx - %llx cannot be added\n", 236 229 (unsigned long long)res->start, (unsigned long long)res->end); 237 230 kfree(res); 231 + ret = -EEXIST; 238 232 } 233 + return ret; 239 234 } 240 235 241 236 ··· 278 269 } 279 270 280 271 /* register this memory as resource */ 281 - register_memory_resource(start, size); 272 + ret = register_memory_resource(start, size); 282 273 283 274 return ret; 284 275 error: