[PATCH] catch valid mem range at onlining memory
This patch allows hot-add memory which is not aligned to section. Now, hot-added memory has to be aligned to section size. Considering big section sized archs, this is not useful. When hot-added memory is registerd as iomem resoruce by iomem resource patch, we can make use of that information to detect valid memory range. Note: With this, not-aligned memory can be registerd. To allow hot-add memory with holes, we have to do more work around add_memory(). (It doesn't allows add memory to already existing mem section.) Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:

committed by
Linus Torvalds

parent
0a54703904
commit
2842f11419
@@ -232,6 +232,44 @@ int release_resource(struct resource *old)
|
||||
|
||||
EXPORT_SYMBOL(release_resource);
|
||||
|
||||
#ifdef CONFIG_MEMORY_HOTPLUG
|
||||
/*
|
||||
* Finds the lowest memory reosurce exists within [res->start.res->end)
|
||||
* the caller must specify res->start, res->end, res->flags.
|
||||
* If found, returns 0, res is overwritten, if not found, returns -1.
|
||||
*/
|
||||
int find_next_system_ram(struct resource *res)
|
||||
{
|
||||
resource_size_t start, end;
|
||||
struct resource *p;
|
||||
|
||||
BUG_ON(!res);
|
||||
|
||||
start = res->start;
|
||||
end = res->end;
|
||||
|
||||
read_lock(&resource_lock);
|
||||
for (p = iomem_resource.child; p ; p = p->sibling) {
|
||||
/* system ram is just marked as IORESOURCE_MEM */
|
||||
if (p->flags != res->flags)
|
||||
continue;
|
||||
if (p->start > end) {
|
||||
p = NULL;
|
||||
break;
|
||||
}
|
||||
if (p->start >= start)
|
||||
break;
|
||||
}
|
||||
read_unlock(&resource_lock);
|
||||
if (!p)
|
||||
return -1;
|
||||
/* copy data */
|
||||
res->start = p->start;
|
||||
res->end = p->end;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find empty slot in the resource tree given range and alignment.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user