Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287402
b: refs/heads/master
c: 321bf4e
h: refs/heads/master
v: v3
  • Loading branch information
Yinghai Lu authored and Greg Kroah-Hartman committed Feb 2, 2012
1 parent dcfb3e9 commit 3e8b98c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2885e25c422fb68208f677f944a45fce8eda2a3c
refs/heads/master: 321bf4ed5ff5f7c62ef59f33b7eec5b154391f0a
31 changes: 26 additions & 5 deletions trunk/drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,19 +572,36 @@ static int init_memory_block(struct memory_block **memory,
}

static int add_memory_section(int nid, struct mem_section *section,
struct memory_block **mem_p,
unsigned long state, enum mem_add_context context)
{
struct memory_block *mem;
struct memory_block *mem = NULL;
int scn_nr = __section_nr(section);
int ret = 0;

mutex_lock(&mem_sysfs_mutex);

mem = find_memory_block(section);
if (context == BOOT) {
/* same memory block ? */
if (mem_p && *mem_p)
if (scn_nr >= (*mem_p)->start_section_nr &&
scn_nr <= (*mem_p)->end_section_nr) {
mem = *mem_p;
kobject_get(&mem->dev.kobj);
}
} else
mem = find_memory_block(section);

if (mem) {
mem->section_count++;
kobject_put(&mem->dev.kobj);
} else
} else {
ret = init_memory_block(&mem, section, state);
/* store memory_block pointer for next loop */
if (!ret && context == BOOT)
if (mem_p)
*mem_p = mem;
}

if (!ret) {
if (context == HOTPLUG &&
Expand Down Expand Up @@ -627,7 +644,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
*/
int register_new_memory(int nid, struct mem_section *section)
{
return add_memory_section(nid, section, MEM_OFFLINE, HOTPLUG);
return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
}

int unregister_memory_section(struct mem_section *section)
Expand All @@ -647,6 +664,7 @@ int __init memory_dev_init(void)
int ret;
int err;
unsigned long block_sz;
struct memory_block *mem = NULL;

ret = subsys_system_register(&memory_subsys, NULL);
if (ret)
Expand All @@ -662,7 +680,10 @@ int __init memory_dev_init(void)
for (i = 0; i < NR_MEM_SECTIONS; i++) {
if (!present_section_nr(i))
continue;
err = add_memory_section(0, __nr_to_section(i), MEM_ONLINE,
/* don't need to reuse memory_block if only one per block */
err = add_memory_section(0, __nr_to_section(i),
(sections_per_block == 1) ? NULL : &mem,
MEM_ONLINE,
BOOT);
if (!ret)
ret = err;
Expand Down
8 changes: 8 additions & 0 deletions trunk/drivers/base/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,15 @@ static int link_mem_sections(int nid)
if (!present_section_nr(section_nr))
continue;
mem_sect = __nr_to_section(section_nr);

/* same memblock ? */
if (mem_blk)
if ((section_nr >= mem_blk->start_section_nr) &&
(section_nr <= mem_blk->end_section_nr))
continue;

mem_blk = find_memory_block_hinted(mem_sect, mem_blk);

ret = register_mem_sect_under_node(mem_blk, nid);
if (!err)
err = ret;
Expand Down

0 comments on commit 3e8b98c

Please sign in to comment.