linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] mm/memory_hotplug: Don't take the cpu_hotplug_lock
@ 2019-09-24 14:36 David Hildenbrand
  2019-09-24 14:48 ` Michal Hocko
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: David Hildenbrand @ 2019-09-24 14:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, David Hildenbrand, Andrew Morton, Oscar Salvador,
	Michal Hocko, Pavel Tatashin, Dan Williams, Thomas Gleixner

Since commit 3f906ba23689 ("mm/memory-hotplug: switch locking to a percpu
rwsem") we do a cpus_read_lock() in mem_hotplug_begin(). This was
introduced to fix a potential deadlock between get_online_mems() and
get_online_cpus() - the memory and cpu hotplug lock. The root issue was
that build_all_zonelists() -> stop_machine() required the cpu hotplug lock:
    The reason is that memory hotplug takes the memory hotplug lock and
    then calls stop_machine() which calls get_online_cpus().  That's the
    reverse lock order to get_online_cpus(); get_online_mems(); in
    mm/slub_common.c

So memory hotplug never really required any cpu lock itself, only
stop_machine() and lru_add_drain_all() required it. Back then,
stop_machine_cpuslocked() and lru_add_drain_all_cpuslocked() were used
as the cpu hotplug lock was now obtained in the caller.

Since commit 11cd8638c37f ("mm, page_alloc: remove stop_machine from build
all_zonelists"), the stop_machine_cpuslocked() call is gone.
build_all_zonelists() does no longer require the cpu lock and does no
longer make use of stop_machine().

Since commit 9852a7212324 ("mm: drop hotplug lock from
lru_add_drain_all()"), lru_add_drain_all() "Doesn't need any cpu hotplug
locking because we do rely on per-cpu kworkers being shut down before our
page_alloc_cpu_dead callback is executed on the offlined cpu.". The
lru_add_drain_all_cpuslocked() variant was removed.

So there is nothing left that requires the cpu hotplug lock. The memory
hotplug lock and the device hotplug lock are sufficient.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Hildenbrand <david@redhat.com>
---

RFC -> v1:
- Reword and add more details why the cpu hotplug lock was needed here
  in the first place, and why we no longer require it.

---
 mm/memory_hotplug.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c3e9aed6023f..5fa30f3010e1 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -88,14 +88,12 @@ __setup("memhp_default_state=", setup_memhp_default_state);
 
 void mem_hotplug_begin(void)
 {
-	cpus_read_lock();
 	percpu_down_write(&mem_hotplug_lock);
 }
 
 void mem_hotplug_done(void)
 {
 	percpu_up_write(&mem_hotplug_lock);
-	cpus_read_unlock();
 }
 
 u64 max_mem_size = U64_MAX;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-10-04  7:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 14:36 [PATCH v1] mm/memory_hotplug: Don't take the cpu_hotplug_lock David Hildenbrand
2019-09-24 14:48 ` Michal Hocko
2019-09-24 15:01   ` David Hildenbrand
2019-09-24 15:03 ` Qian Cai
2019-09-24 15:11   ` Michal Hocko
2019-09-24 18:54     ` Qian Cai
2019-09-25  7:02       ` David Hildenbrand
2019-09-25 16:01         ` Qian Cai
2019-09-25 17:48           ` Michal Hocko
2019-09-25 18:20             ` Qian Cai
2019-09-25 19:48               ` David Hildenbrand
2019-09-25 20:32                 ` Qian Cai
2019-09-26  7:26                   ` David Hildenbrand
2019-09-26  7:38                     ` Michal Hocko
2019-09-26  7:26               ` Michal Hocko
2019-09-26 11:19                 ` Qian Cai
2019-09-26 11:52                   ` Michal Hocko
2019-09-26 13:02                     ` Qian Cai
2019-09-26 13:14                       ` David Hildenbrand
2019-09-25 10:03       ` Michal Hocko
2019-09-24 15:23   ` David Hildenbrand
2019-10-02 21:37 ` Qian Cai
2019-10-04  7:42   ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).