Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp612787ybi; Wed, 3 Jul 2019 01:56:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPgz7K1EiNzH6WN9CV5FOdOhEiD0JCUA7HcLGEXzYfHdV62hvPmTrO1//9i37kcguwIh4b X-Received: by 2002:a63:d70b:: with SMTP id d11mr35997762pgg.178.1562144171228; Wed, 03 Jul 2019 01:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562144171; cv=none; d=google.com; s=arc-20160816; b=wJ5J5M/y2Age5HfqGdDoKikqsEkK2MUg41rk9atzudQdEtn1k4d1eo6k7JO7JVjn3J QgLFeMwq7DgZ5HUC9kvQdfYP9NSDNCnW+PZI+TT7FiHZ3S9v1RoD35iJ89mUh23GrYux eDGkGDV7kZ6FODhGOXJgZISV092LhgJpsl9epzIFXpn3+4kMCd9AlmZLlYti0A/aU7cK AWVtnMGTqeHEGvF6dHJIVY7IyM6biqPpguNia+n3MNc70gHQlGtHqXnQ+03L08PBSkg4 gi761B+rFkCHcfxpzC1x5t267CFlga57LTHqGMgrmzJvlNNC04+IQkEUjGx3zhFfSGyt MDmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=/ZwZ9I08z0+N4y4oAHEHrhJ308dnz3SfHQY6nFtQvJc=; b=uRAx2pKBiuljyYo+x4nu+nlMbvGa+OtpIGMbWQXU+elBOB+DPUUZ9E3jQYmZznpgHG 5lCXZM/kUCizkPhtFragrKCg26OqGA7+2v3fSp2bOna9u9BSzF9PS27A163U7Gm9Gmr7 Gx/qz6yCUkpPCdJ8/dRq3SZTNsEB4Y9p0/DqZOwec6rUFpKAkfUtlK4MapHJANO3cNVz uLg5h015tHSw5A/6a+dYmSDYliSfPDQOoij7cF2uCf70l3YT9a/hJiT+iek2DT1MwCQv Eryt6e4DFfe4RDA8EmtCF/ueji7dpf8ZeNiilcEIqSexemnM7rHf87qsQ7XhcCKgEx3V CNCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si1713649plv.153.2019.07.03.01.55.56; Wed, 03 Jul 2019 01:56:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbfGCIy5 (ORCPT + 99 others); Wed, 3 Jul 2019 04:54:57 -0400 Received: from mail5.windriver.com ([192.103.53.11]:54076 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbfGCIy5 (ORCPT ); Wed, 3 Jul 2019 04:54:57 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id x638oNPH007150 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 3 Jul 2019 01:50:43 -0700 Received: from pek-lpggp3.wrs.com (128.224.153.76) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.439.0; Wed, 3 Jul 2019 01:50:13 -0700 From: Song liwei To: CC: Thomas Gleixner , Daniel Lezcano , Palmer Dabbelt , Will Deacon , Borislav Petkov , Kulkarni , Guo Ren , Joseph Lo , Hoan Tran , "Anju T Sudhakar" , Rafael J , liwei Subject: [PATCH] x86/microcode, cpuhotplug: move microcode hotplug callback after cpu teardown Date: Wed, 3 Jul 2019 04:48:48 -0400 Message-ID: <1562143728-78052-1-git-send-email-liwei.song@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liwei Song Fix the following BUG: [ 236.599792] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:255 [ 236.599796] in_atomic(): 1, irqs_disabled(): 1, pid: 14, name: migration/1 [ 236.599798] Preemption disabled at: [ 236.599807] [] cpu_stopper_thread+0x71/0x100 [ 236.599816] Call Trace: [ 236.599826] dump_stack+0x4f/0x6a [ 236.599830] ? cpu_stopper_thread+0x71/0x100 [ 236.599836] ___might_sleep.cold+0xd1/0xe2 [ 236.599841] __might_sleep+0x4b/0x80 [ 236.599847] mutex_lock+0x21/0x50 [ 236.599852] kernfs_find_and_get_ns+0x24/0x60 [ 236.599857] sysfs_remove_group+0x2a/0x80 [ 236.599862] ? mc_device_remove+0x50/0x50 [ 236.599866] mc_cpu_down_prep+0x1d/0x30 [ 236.599871] cpuhp_invoke_callback+0x98/0x670 [ 236.599876] ? cpu_disable_common+0x26a/0x280 [ 236.599882] take_cpu_down+0x70/0xb0 [ 236.599886] multi_cpu_stop+0x64/0xc0 [ 236.599890] ? cpu_stop_queue_work+0x110/0x110 [ 236.599894] cpu_stopper_thread+0x79/0x100 [ 236.599899] ? smpboot_thread_fn+0x2d/0x290 [ 236.599904] smpboot_thread_fn+0x1e7/0x290 [ 236.599910] kthread+0x112/0x150 [ 236.599914] ? sort_range+0x30/0x30 [ 236.599918] ? kthread_park+0x90/0x90 [ 236.599922] ret_from_fork+0x35/0x40 [ 236.599965] smpboot: CPU 1 is now offline After CPUHP_TEARDOWN_CPU callback was invoked, the context will become atomic and IRQ disabled, while mc_cpu_down_prep will called kernfs_find_and_get_ns which will try to acquire mutext lock which may sleep. Adjust CPUHP_AP_MICROCODE_LOADER callback function run before CPUHP_TEARDOWN_CPU to fix this bug. Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback") Signed-off-by: Liwei Song --- include/linux/cpuhotplug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 5c6062206760..6724bc8a17cd 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -101,7 +101,6 @@ enum cpuhp_state { CPUHP_AP_IRQ_BCM2836_STARTING, CPUHP_AP_IRQ_MIPS_GIC_STARTING, CPUHP_AP_ARM_MVEBU_COHERENCY, - CPUHP_AP_MICROCODE_LOADER, CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING, CPUHP_AP_PERF_X86_STARTING, CPUHP_AP_PERF_X86_AMD_IBS_STARTING, @@ -143,6 +142,7 @@ enum cpuhp_state { CPUHP_AP_ARM_CACHE_B15_RAC_DYING, CPUHP_AP_ONLINE, CPUHP_TEARDOWN_CPU, + CPUHP_AP_MICROCODE_LOADER, CPUHP_AP_ONLINE_IDLE, CPUHP_AP_SMPBOOT_THREADS, CPUHP_AP_X86_VDSO_VMA_ONLINE, -- 2.7.4