On Wed, Jul 22, 2020 at 6:01 AM Paul E. McKenney paulmck@kernel.org wrote:
On Wed, Jul 22, 2020 at 10:04:21AM +0200, Arnd Bergmann wrote:
On Wed, Jul 22, 2020 at 9:44 AM Naresh Kamboju naresh.kamboju@linaro.org wrote:
Kernel BUG noticed on arm64 db410c device while booting linux next 20200721 tag. Continually popping up these BUG messages on the boot console and kernel warning also noticed.
metadata: git branch: master git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git commit: de2e69cfe54a8f2ed4b75f09d3110c514f45d38e git describe: next-20200721 kernel-config: http://snapshots.linaro.org/openembedded/lkft/lkft/sumo/dragonboard-410c/lkf... build-location: http://snapshots.linaro.org/openembedded/lkft/lkft/sumo/dragonboard-410c/lkf...
Crash log: [ 0.444349] BUG: sleeping function called from invalid context at /usr/src/kernel/kernel/locking/mutex.c:935 [ 0.444422] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 30, name: kworker/0:1 [ 0.444458] 2 locks held by kworker/0:1/30: [ 0.444489] #0: ffff00000eb15138 ((wq_completion)rcu_gp){+.+.}-{0:0}, at: process_one_work+0x208/0x768 [ 0.444627] #1: ffff800013713df0 ((work_completion)(&sdp->work)){+.+.}-{0:0}, at: process_one_work+0x208/0x768 [ 0.444761] CPU: 0 PID: 30 Comm: kworker/0:1 Not tainted 5.8.0-rc6-next-20200721 #1 [ 0.444787] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 0.444817] Workqueue: rcu_gp srcu_invoke_callbacks [ 0.444856] Call trace: [ 0.444883] dump_backtrace+0x0/0x1f8 [ 0.444910] show_stack+0x2c/0x38 [ 0.444939] dump_stack+0xf0/0x16c [ 0.444969] ___might_sleep+0x144/0x208 [ 0.444996] __might_sleep+0x54/0x90 [ 0.445027] __mutex_lock+0x64/0x970 [ 0.445055] mutex_lock_nested+0x54/0x70 [ 0.445084] device_del+0x44/0x3c0 [ 0.445110] device_unregister+0x24/0x78 [ 0.445138] __device_link_free_srcu+0x64/0x70 [ 0.445164] srcu_invoke_callbacks+0x10c/0x1a0
The device_unregister() was added to __device_link_free_srcu() as part of commit 287905e68dd2 ("driver core: Expose device link details in sysfs")
I'm fairly sure this is what introduced the console output, though the code before it is already suspicious:
call_srcu(&device_links_srcu, &link->rcu_head, __device_link_free_srcu);
According to the documentation, call_srcu() must not call any sleeping functions, which is what the 'in_atomic(): 1' above is about.
Yes, the callback function, in this case __device_link_free_srcu(), will execute from softirq context.
However, from what I can tell, the put_device() and pm_runtime_put() calls in device_link_free() can also potentially sleep even if they normally don't warn about that.
The usual workaround is to have __device_link_free_srcu() schedule a workqueue that invokes the potentially sleeping functions.
Thanx, Paul
Thanks for reporting. It was already reported and fixed last week. Waiting on Greg to pull it in. https://lore.kernel.org/lkml/CAGETcx9quqtV9TeD8WEcLLijGeV+7hXqnyiMv7F8xo+vyF...
-Saravana