Commit 6140a0c7 authored by John Stultz's avatar John Stultz
Browse files

ANDROID: cgroup: Fix bad merge of "Fix threadgroup_rwsem <-> cpus_read_lock() deadlock"



In commit 7e9fc616 ("Merge 5.10.143 into android13-5.10-lts")
the fix dee1e2b1 ("cgroup: Fix threadgroup_rwsem <->
cpus_read_lock() deadlock") was merged in.

However, it seems like the merge went awry and undid the
critical locking fix in cpuset_attach().

This causes lockdep to give the following splat:
[   35.132948] ============================================
[   35.132951] WARNING: possible recursive locking detected
[   35.132957] 5.10.157-android13-4-00001-g87c7751c5c84-dirty #1 Tainted: G           OE
[   35.132959] --------------------------------------------
[   35.132963] init/400 is trying to acquire lock:
[   35.132968] ffffffe936b8c0f0 (cpu_hotplug_lock){++++}-{0:0}, at: cpuset_attach+0x54/0x30c
[   35.132994] but task is already holding lock:
[   35.132997] ffffffe936b8c0f0 (cpu_hotplug_lock){++++}-{0:0}, at: cgroup_procs_write_start+0x98/0x28c
[   35.133016] other info that might help us debug this:
[   35.133018] Possible unsafe locking scenario:
[   35.133021] CPU0
[   35.133024] ----
[   35.133026] lock(cpu_hotplug_lock);
[   35.133033] lock(cpu_hotplug_lock);
[   35.133040]  *** DEADLOCK ***
[   35.133042] May be due to missing lock nesting notation
[   35.133046] 5 locks held by init/400:
[   35.133049] #0: ffffff880700a490 (sb_writers#9){.+.+}-{0:0}, at: vfs_write+0xc8/0x358
[   35.133073] #1: ffffff8804fdbc88 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0xc8/0x200
[   35.133093] #2: ffffffe936c15488 (cgroup_mutex){+.+.}-{4:4}, at: cgroup_kn_lock_live+0x80/0xe8
[   35.133112] #3: ffffffe936b8c0f0 (cpu_hotplug_lock){++++}-{0:0}, at: cgroup_procs_write_start+0x98/0x28c
[   35.133128] #4: ffffffe936c15610 (cgroup_threadgroup_rwsem){++++}-{0:0}, at: cgroup_procs_write_start+0xa8/0x28c
[   35.133149] stack backtrace:
[   35.133155] CPU: 3 PID: 400 Comm: init Tainted: G           OE     5.10.157-android13-4-00001-g87c7751c5c84-dirty #1
[   35.133159] Hardware name: Oriole DVT (DT)
[   35.133162] Call trace:
[   35.133171] dump_backtrace.cfi_jt+0x0/0x8
[   35.133178] show_stack+0x1c/0x2c
[   35.133186] dump_stack_lvl+0xe0/0x17c
[   35.133193] __lock_acquire+0x5e4/0x2fb4
[   35.133197] lock_acquire+0x100/0x210
[   35.133205] cpus_read_lock+0x7c/0x1b0
[   35.133210] cpuset_attach+0x54/0x30c
[   35.133215] cgroup_migrate_execute+0x2e4/0x568
[   35.133221] cgroup_migrate+0x104/0x120
[   35.133226] cgroup_attach_task+0x204/0x2b8
[   35.133233] __cgroup1_procs_write+0x104/0x1bc
[   35.133239] cgroup1_procs_write+0x18/0x28
[   35.133243] cgroup_file_write+0xac/0x308
[   35.133248] kernfs_fop_write_iter+0x134/0x200
[   35.133252] vfs_write+0x2e4/0x358
[   35.133256] ksys_write+0x7c/0xec
[   35.133261] __arm64_sys_write+0x20/0x30
[   35.133269] el0_svc_common.llvm.12320387402837011898+0xd4/0x1ec
[   35.133273] do_el0_svc+0x28/0xa0
[   35.133280] el0_svc+0x24/0x38
[   35.133285] el0_sync_handler+0x88/0xec
[   35.133292] el0_sync+0x1b4/0x1c0

So this patch tries to fix that merge by including the dropped
changes.

Original upstream commit: 4f7e7236

Cc: Greg Kroah-Hartman <gregkh@google.com>
Bug: 287147292
Fixes: f5094ecc ("Merge 5.10.150 into android13-5.10-lts")
Signed-off-by: default avatarJohn Stultz <jstultz@google.com>
Change-Id: Iaadcdc76ed9470bf02e352a5ea8b0f254a1df976
parent 7a7749b8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment