Commit 58c1b5b0 authored by KAMEZAWA Hiroyuki's avatar KAMEZAWA Hiroyuki Committed by Linus Torvalds

[PATCH] memory hotadd fixes: find_next_system_ram catch range fix

find_next_system_ram() is used to find available memory resource at onlining
newly added memory.  This patch fixes following problem.

find_next_system_ram() cannot catch this case.

Resource:      (start)-------------(end)
Section :                (start)-------------(end)
Signed-off-by: default avatarKAMEZAWA 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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0f04ab5e
...@@ -244,6 +244,7 @@ int find_next_system_ram(struct resource *res) ...@@ -244,6 +244,7 @@ int find_next_system_ram(struct resource *res)
start = res->start; start = res->start;
end = res->end; end = res->end;
BUG_ON(start >= end);
read_lock(&resource_lock); read_lock(&resource_lock);
for (p = iomem_resource.child; p ; p = p->sibling) { for (p = iomem_resource.child; p ; p = p->sibling) {
...@@ -254,7 +255,7 @@ int find_next_system_ram(struct resource *res) ...@@ -254,7 +255,7 @@ int find_next_system_ram(struct resource *res)
p = NULL; p = NULL;
break; break;
} }
if (p->start >= start) if ((p->end >= start) && (p->start < end))
break; break;
} }
read_unlock(&resource_lock); read_unlock(&resource_lock);
......
...@@ -163,7 +163,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages) ...@@ -163,7 +163,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
res.flags = IORESOURCE_MEM; /* we just need system ram */ res.flags = IORESOURCE_MEM; /* we just need system ram */
section_end = res.end; section_end = res.end;
while (find_next_system_ram(&res) >= 0) { while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) {
start_pfn = (unsigned long)(res.start >> PAGE_SHIFT); start_pfn = (unsigned long)(res.start >> PAGE_SHIFT);
nr_pages = (unsigned long) nr_pages = (unsigned long)
((res.end + 1 - res.start) >> PAGE_SHIFT); ((res.end + 1 - res.start) >> PAGE_SHIFT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment