Spurious lockdep splat in v4.15-rc9

From: Tejun Heo
Date: Mon Jan 22 2018 - 12:10:27 EST


Hello, Peter, Ingo.

I get the below lockdep warning if I try to write a config into cgroup
cpu.max file. It's warning about A-A deadlock, but it's obviously
spurious - the system doesn't lock up and the warning is about two
get_online_cpus() calls nesting.

Thanks.

[ 79.106704]
[ 79.106886] ============================================
[ 79.107319] WARNING: possible recursive locking detected
[ 79.107741] 4.15.0-rc9-work+ #61 Not tainted
[ 79.108080] --------------------------------------------
[ 79.108505] bash/2133 is trying to acquire lock:
[ 79.108872] (cpu_hotplug_lock.rw_sem){++++}, at: [<00000000b3203afd>] static_key_slow_inc+0xe/0xa0
[ 79.109593]
[ 79.109593] but task is already holding lock:
[ 79.110058] (cpu_hotplug_lock.rw_sem){++++}, at: [<00000000748e6cec>] tg_set_cfs_bandwidth+0x51/0x330
[ 79.110801]
[ 79.110801] other info that might help us debug this:
[ 79.111322] Possible unsafe locking scenario:
[ 79.111322]
[ 79.111792] CPU0
[ 79.111992] ----
[ 79.112197] lock(cpu_hotplug_lock.rw_sem);
[ 79.112537] lock(cpu_hotplug_lock.rw_sem);
[ 79.112880]
[ 79.112880] *** DEADLOCK ***
[ 79.112880]
[ 79.113355] May be due to missing lock nesting notation
[ 79.113355]
[ 79.113893] 5 locks held by bash/2133:
[ 79.114199] #0: (sb_writers#7){.+.+}, at: [<00000000259a9362>] vfs_write+0x18a/0x1c0
[ 79.114830] #1: (&of->mutex){+.+.}, at: [<00000000b1a2a028>] kernfs_fop_write+0xde/0x1a0
[ 79.115492] #2: (kn->count#182){.+.+}, at: [<000000008f74a9a4>] kernfs_fop_write+0xe6/0x1a0
[ 79.116182] #3: (cpu_hotplug_lock.rw_sem){++++}, at: [<00000000748e6cec>] tg_set_cfs_bandwidth+0x51/0x330
[ 79.116956] #4: (cfs_constraints_mutex){+.+.}, at: [<000000007a63f0e9>] tg_set_cfs_bandwidth+0x5f/0x330
[ 79.117717]
[ 79.117717] stack backtrace:
[ 79.118072] CPU: 13 PID: 2133 Comm: bash Not tainted 4.15.0-rc9-work+ #61
[ 79.118616] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-3.el7_4.1 04/01/2014
[ 79.119331] Call Trace:
[ 79.119539] dump_stack+0x5e/0x8f
[ 79.119809] __lock_acquire+0x150e/0x15f0
[ 79.120136] ? tg_set_cfs_bandwidth+0x5f/0x330
[ 79.120497] ? __mutex_lock+0x204/0x930
[ 79.120805] ? tg_set_cfs_bandwidth+0x5f/0x330
[ 79.121164] lock_acquire+0xb0/0x200
[ 79.121454] ? static_key_slow_inc+0xe/0xa0
[ 79.121798] cpus_read_lock+0x43/0xb0
[ 79.122095] ? static_key_slow_inc+0xe/0xa0
[ 79.122438] static_key_slow_inc+0xe/0xa0
[ 79.122763] tg_set_cfs_bandwidth+0x30e/0x330
[ 79.123112] ? tg_set_cfs_bandwidth+0xaa/0x330
[ 79.123473] cpu_max_write+0xb8/0x100
[ 79.123773] cgroup_file_write+0x69/0x200
[ 79.124100] kernfs_fop_write+0x10e/0x1a0
[ 79.124430] __vfs_write+0x23/0x130
[ 79.124721] ? rcu_read_lock_sched_held+0x96/0xa0
[ 79.125100] ? rcu_sync_lockdep_assert+0x2a/0x50
[ 79.125475] ? __sb_start_write+0x194/0x230
[ 79.125812] ? vfs_write+0x18a/0x1c0
[ 79.126109] ? __close_fd+0x66/0xd0
[ 79.126392] vfs_write+0xbf/0x1c0
[ 79.126660] SyS_write+0x45/0xa0
[ 79.126928] entry_SYSCALL_64_fastpath+0x18/0x85
[ 79.127306] RIP: 0033:0x7f3b040e21f0

--
tejun