Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198261
b: refs/heads/master
c: cf23422
h: refs/heads/master
i:
  198259: c285523
v: v3
  • Loading branch information
minskey guo authored and Linus Torvalds committed May 25, 2010
1 parent 6bb11db commit 322c45c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8b25c6d2231b978ccce9c401e771932bde79aa9f
refs/heads/master: cf23422b9d76215316855253da491d4c9f294372
1 change: 1 addition & 0 deletions trunk/include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
}
#endif /* CONFIG_MEMORY_HOTREMOVE */

extern int mem_online_node(int nid);
extern int add_memory(int nid, u64 start, u64 size);
extern int arch_add_memory(int nid, u64 start, u64 size);
extern int remove_memory(u64 start, u64 size);
Expand Down
25 changes: 25 additions & 0 deletions trunk/kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
int __cpuinit cpu_up(unsigned int cpu)
{
int err = 0;

#ifdef CONFIG_MEMORY_HOTPLUG
int nid;
pg_data_t *pgdat;
#endif

if (!cpu_possible(cpu)) {
printk(KERN_ERR "can't online cpu %d because it is not "
"configured as may-hotadd at boot time\n", cpu);
Expand All @@ -336,6 +342,25 @@ int __cpuinit cpu_up(unsigned int cpu)
return -EINVAL;
}

#ifdef CONFIG_MEMORY_HOTPLUG
nid = cpu_to_node(cpu);
if (!node_online(nid)) {
err = mem_online_node(nid);
if (err)
return err;
}

pgdat = NODE_DATA(nid);
if (!pgdat) {
printk(KERN_ERR
"Can't online cpu %d due to NULL pgdat\n", cpu);
return -ENOMEM;
}

if (pgdat->node_zonelists->_zonerefs->zone == NULL)
build_all_zonelists();
#endif

cpu_maps_update_begin();

if (cpu_hotplug_disabled) {
Expand Down
23 changes: 23 additions & 0 deletions trunk/mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,29 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
}


/*
* called by cpu_up() to online a node without onlined memory.
*/
int mem_online_node(int nid)
{
pg_data_t *pgdat;
int ret;

lock_system_sleep();
pgdat = hotadd_new_pgdat(nid, 0);
if (pgdat) {
ret = -ENOMEM;
goto out;
}
node_set_online(nid);
ret = register_one_node(nid);
BUG_ON(ret);

out:
unlock_system_sleep();
return ret;
}

/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
int __ref add_memory(int nid, u64 start, u64 size)
{
Expand Down

0 comments on commit 322c45c

Please sign in to comment.