]> www.infradead.org Git - users/dwmw2/linux.git/commit
mm/page_alloc: fix deadlock on cpu_hotplug_lock in __accept_page()
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Sat, 29 Mar 2025 17:10:29 +0000 (19:10 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Apr 2025 03:10:05 +0000 (20:10 -0700)
commit4067196a52278156d18d8d6fa7f43970611b1b49
tree464b0163dce8eb858c664b79c21f74cb6d756336
parentfc96b232f8e7c0a6c282f47726b2ff6a5fb341d2
mm/page_alloc: fix deadlock on cpu_hotplug_lock in __accept_page()

When the last page in the zone is accepted, __accept_page() calls
static_branch_dec().  This function takes cpu_hotplug_lock, which can lead
to a deadlock if the allocation occurs during CPU bringup path as
_cpu_up() also takes the lock.

To prevent this deadlock, defer static_branch_dec() to a workqueue.

Call static_branch_dec() only when the workqueue is not yet initialized.
Workqueues are initialized before CPU bring up, so this will not conflict
with the first scenario.

Link: https://lkml.kernel.org/r/20250329171030.3942298-1-kirill.shutemov@linux.intel.com
Fixes: 55ad43e8ba0f ("mm: add a helper to accept page")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Srikanth Aithal <sraithal@amd.com>
Tested-by: Srikanth Aithal <sraithal@amd.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Ashish Kalra <ashish.kalra@amd.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Mike Rapoport (IBM)" <rppt@kernel.org>
Cc: Thomas Lendacky <thomas.lendacky@amd.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mmzone.h
mm/internal.h
mm/mm_init.c
mm/page_alloc.c