aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2011-01-11 02:44:01 -0500
committerPekka Enberg <penberg@kernel.org>2011-01-11 10:09:50 -0500
commit925268a06dc2b1ff7bfcc37419a6827a0e739639 (patch)
treec0a5b3a6dc8ea6c4ea8e469e58223877f52c2e5b /mm
parent3c0eee3fe6a3a1c745379547c7e7c904aa64f6d5 (diff)
memory hotplug: one more lock on memory hotplug
Now, memory_hotplug_(un)lock() is used for add/remove/offline pages for avoiding races with hibernation. But this should be held in online_pages(), too. It seems asymmetric. There are cases where one has to avoid a race with memory hotplug notifier and his own local code, and hotplug v.s. hotplug. This will add a generic solution for avoiding races. In other view, having lock here has no big impacts. online pages is tend to be done by udev script at el against each memory section one by one. Then, it's better to have lock here, too. Cc: <stable@kernel.org> # 2.6.37 Reviewed-by: Christoph Lameter <cl@linux.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory_hotplug.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2c6523af5473..83163c096a75 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -407,6 +407,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
407 int ret; 407 int ret;
408 struct memory_notify arg; 408 struct memory_notify arg;
409 409
410 lock_memory_hotplug();
410 arg.start_pfn = pfn; 411 arg.start_pfn = pfn;
411 arg.nr_pages = nr_pages; 412 arg.nr_pages = nr_pages;
412 arg.status_change_nid = -1; 413 arg.status_change_nid = -1;
@@ -419,6 +420,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
419 ret = notifier_to_errno(ret); 420 ret = notifier_to_errno(ret);
420 if (ret) { 421 if (ret) {
421 memory_notify(MEM_CANCEL_ONLINE, &arg); 422 memory_notify(MEM_CANCEL_ONLINE, &arg);
423 unlock_memory_hotplug();
422 return ret; 424 return ret;
423 } 425 }
424 /* 426 /*
@@ -443,6 +445,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
443 printk(KERN_DEBUG "online_pages %lx at %lx failed\n", 445 printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
444 nr_pages, pfn); 446 nr_pages, pfn);
445 memory_notify(MEM_CANCEL_ONLINE, &arg); 447 memory_notify(MEM_CANCEL_ONLINE, &arg);
448 unlock_memory_hotplug();
446 return ret; 449 return ret;
447 } 450 }
448 451
@@ -467,6 +470,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
467 470
468 if (onlined_pages) 471 if (onlined_pages)
469 memory_notify(MEM_ONLINE, &arg); 472 memory_notify(MEM_ONLINE, &arg);
473 unlock_memory_hotplug();
470 474
471 return 0; 475 return 0;
472} 476}