mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song liwei <liwei.song@windriver.com>
To: <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Will Deacon <will@kernel.org>, Borislav Petkov <bp@suse.de>,
	Kulkarni <Ganapatrao.Kulkarni@cavium.com>,
	Guo Ren <ren_guo@c-sky.com>, Joseph Lo <josephl@nvidia.com>,
	Hoan Tran <Hoan@os.amperecomputing.com>,
	"Anju T Sudhakar" <anju@linux.vnet.ibm.com>,
	Rafael J <rafael.j.wysocki@intel.com>,
	liwei <liwei.song@windriver.com>
Subject: [PATCH] x86/microcode, cpuhotplug: move microcode hotplug callback after cpu teardown
Date: Wed, 3 Jul 2019 04:48:48 -0400	[thread overview]
Message-ID: <1562143728-78052-1-git-send-email-liwei.song@windriver.com> (raw)

From: Liwei Song <liwei.song@windriver.com>

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] [<ffffffffb3998fa1>] 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 <liwei.song@windriver.com>
---
 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


             reply	other threads:[~2019-07-03  8:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  8:48 Song liwei [this message]
2019-07-03  9:17 ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1562143728-78052-1-git-send-email-liwei.song@windriver.com \
    --to=liwei.song@windriver.com \
    --cc=Ganapatrao.Kulkarni@cavium.com \
    --cc=Hoan@os.amperecomputing.com \
    --cc=anju@linux.vnet.ibm.com \
    --cc=bp@suse.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=josephl@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=ren_guo@c-sky.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®