aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2011-05-11 03:25:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-11 18:19:27 -0400
commit5409d2cd841cf2c76396470e566500f6505f8d2a (patch)
treeba91b4eb9d982461b45cf810380b53a2a9916408 /drivers
parent1f8e1cdac616e510eeb2dc2a9226bf597bc6cfd6 (diff)
memory hotplug: Speed up add/remove when blocks are larger than PAGES_PER_SECTION
On ppc64 the minimum memory section for hotplug is 16MB but most recent machines have a memory block size of 256MB. This means memory_block_change_state does 16 separate calls to memory_section_action. This also means we call the notifiers 16 times and the hook in the ehea network driver is quite costly. To offline one 256MB region takes: # time echo offline > /sys/devices/system/memory/memory32/state 7.9s This patch removes the loop and calls online_pages or remove_memory once for the entire region and in doing so makes the logic simpler since we don't have to back out if things fail part way through. The same test to offline one region now takes: # time echo online > /sys/devices/system/memory/memory32/state 0.67s Over 11 times faster. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/memory.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 3e9aa3d00044..c4c443db7cbf 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -229,10 +229,11 @@ int memory_isolate_notify(unsigned long val, void *v)
229 * OK to have direct references to sparsemem variables in here. 229 * OK to have direct references to sparsemem variables in here.
230 */ 230 */
231static int 231static int
232memory_section_action(unsigned long phys_index, unsigned long action) 232memory_block_action(unsigned long phys_index, unsigned long action)
233{ 233{
234 int i; 234 int i;
235 unsigned long start_pfn, start_paddr; 235 unsigned long start_pfn, start_paddr;
236 unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
236 struct page *first_page; 237 struct page *first_page;
237 int ret; 238 int ret;
238 239
@@ -244,7 +245,7 @@ memory_section_action(unsigned long phys_index, unsigned long action)
244 * that way. 245 * that way.
245 */ 246 */
246 if (action == MEM_ONLINE) { 247 if (action == MEM_ONLINE) {
247 for (i = 0; i < PAGES_PER_SECTION; i++) { 248 for (i = 0; i < nr_pages; i++) {
248 if (PageReserved(first_page+i)) 249 if (PageReserved(first_page+i))
249 continue; 250 continue;
250 251
@@ -258,12 +259,12 @@ memory_section_action(unsigned long phys_index, unsigned long action)
258 switch (action) { 259 switch (action) {
259 case MEM_ONLINE: 260 case MEM_ONLINE:
260 start_pfn = page_to_pfn(first_page); 261 start_pfn = page_to_pfn(first_page);
261 ret = online_pages(start_pfn, PAGES_PER_SECTION); 262 ret = online_pages(start_pfn, nr_pages);
262 break; 263 break;
263 case MEM_OFFLINE: 264 case MEM_OFFLINE:
264 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; 265 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT;
265 ret = remove_memory(start_paddr, 266 ret = remove_memory(start_paddr,
266 PAGES_PER_SECTION << PAGE_SHIFT); 267 nr_pages << PAGE_SHIFT);
267 break; 268 break;
268 default: 269 default:
269 WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " 270 WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: "
@@ -289,20 +290,11 @@ static int memory_block_change_state(struct memory_block *mem,
289 if (to_state == MEM_OFFLINE) 290 if (to_state == MEM_OFFLINE)
290 mem->state = MEM_GOING_OFFLINE; 291 mem->state = MEM_GOING_OFFLINE;
291 292
292 for (i = 0; i < sections_per_block; i++) { 293 ret = memory_block_action(mem->start_section_nr, to_state);
293 ret = memory_section_action(mem->start_section_nr + i,
294 to_state);
295 if (ret)
296 break;
297 }
298
299 if (ret) {
300 for (i = 0; i < sections_per_block; i++)
301 memory_section_action(mem->start_section_nr + i,
302 from_state_req);
303 294
295 if (ret)
304 mem->state = from_state_req; 296 mem->state = from_state_req;
305 } else 297 else
306 mem->state = to_state; 298 mem->state = to_state;
307 299
308out: 300out: