Skip to content

Commit

Permalink
Merge branch 'slub/hotplug' into slab/urgent
Browse files Browse the repository at this point in the history
  • Loading branch information
penberg committed Jan 15, 2011
2 parents 3856733 + 04d9487 commit 597fb18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
extern void put_page_bootmem(struct page *page);
#endif

/*
* Lock for memory hotplug guarantees 1) all callbacks for memory hotplug
* notifier will be called under this. 2) offline/online/add/remove memory
* will not run simultaneously.
*/

void lock_memory_hotplug(void);
void unlock_memory_hotplug(void);

Expand Down
4 changes: 4 additions & 0 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
int ret;
struct memory_notify arg;

lock_memory_hotplug();
arg.start_pfn = pfn;
arg.nr_pages = nr_pages;
arg.status_change_nid = -1;
Expand All @@ -421,6 +422,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
ret = notifier_to_errno(ret);
if (ret) {
memory_notify(MEM_CANCEL_ONLINE, &arg);
unlock_memory_hotplug();
return ret;
}
/*
Expand All @@ -445,6 +447,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
nr_pages, pfn);
memory_notify(MEM_CANCEL_ONLINE, &arg);
unlock_memory_hotplug();
return ret;
}

Expand All @@ -469,6 +472,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)

if (onlined_pages)
memory_notify(MEM_ONLINE, &arg);
unlock_memory_hotplug();

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3797,7 +3797,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
}
}

down_read(&slub_lock);
lock_memory_hotplug();
#ifdef CONFIG_SLUB_DEBUG
if (flags & SO_ALL) {
for_each_node_state(node, N_NORMAL_MEMORY) {
Expand Down Expand Up @@ -3838,7 +3838,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
x += sprintf(buf + x, " N%d=%lu",
node, nodes[node]);
#endif
up_read(&slub_lock);
unlock_memory_hotplug();
kfree(nodes);
return x + sprintf(buf + x, "\n");
}
Expand Down

0 comments on commit 597fb18

Please sign in to comment.