* [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks()
@ 2023-05-17 7:45 Qi Zheng
2023-05-17 7:51 ` Muchun Song
[not found] ` <20230517074545.2045035-1-qi.zheng-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Qi Zheng @ 2023-05-17 7:45 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
hannes-druUgvl0LCNAfugRpC6u6w
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
muchun.song-fxUVXftIFDnyG1zEObXtfA, Qi Zheng, Zhao Gongyi
From: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
The commit 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock()
deadlock") fixed the deadlock between cgroup_threadgroup_rwsem and
cpus_read_lock() by introducing cgroup_attach_{lock,unlock}() and removing
cpus_read_{lock,unlock}() from cpuset_attach(). But cgroup_transfer_tasks()
was missed and not handled, which will cause th following warning:
WARNING: CPU: 0 PID: 589 at kernel/cpu.c:526 lockdep_assert_cpus_held+0x32/0x40
CPU: 0 PID: 589 Comm: kworker/1:4 Not tainted 6.4.0-rc2-next-20230517 #50
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
Workqueue: events cpuset_hotplug_workfn
RIP: 0010:lockdep_assert_cpus_held+0x32/0x40
<...>
Call Trace:
<TASK>
cpuset_attach+0x40/0x240
cgroup_migrate_execute+0x452/0x5e0
? _raw_spin_unlock_irq+0x28/0x40
cgroup_transfer_tasks+0x1f3/0x360
? find_held_lock+0x32/0x90
? cpuset_hotplug_workfn+0xc81/0xed0
cpuset_hotplug_workfn+0xcb1/0xed0
? process_one_work+0x248/0x5b0
process_one_work+0x2b9/0x5b0
worker_thread+0x56/0x3b0
? process_one_work+0x5b0/0x5b0
kthread+0xf1/0x120
? kthread_complete_and_exit+0x20/0x20
ret_from_fork+0x1f/0x30
</TASK>
So just use the cgroup_attach_{lock,unlock}() helper to fix it.
Fixes: 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
Reported-by: Zhao Gongyi <zhaogongyi-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Signed-off-by: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
---
kernel/cgroup/cgroup-v1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index aeef06c465ef..5407241dbb45 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -108,7 +108,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
cgroup_lock();
- percpu_down_write(&cgroup_threadgroup_rwsem);
+ cgroup_attach_lock(true);
/* all tasks in @from are being moved, all csets are source */
spin_lock_irq(&css_set_lock);
@@ -144,7 +144,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
} while (task && !ret);
out_err:
cgroup_migrate_finish(&mgctx);
- percpu_up_write(&cgroup_threadgroup_rwsem);
+ cgroup_attach_unlock(true);
cgroup_unlock();
return ret;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks()
2023-05-17 7:45 [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks() Qi Zheng
@ 2023-05-17 7:51 ` Muchun Song
[not found] ` <75E872A8-652F-40B0-80D0-378569E77775-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
[not found] ` <20230517074545.2045035-1-qi.zheng-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Muchun Song @ 2023-05-17 7:51 UTC (permalink / raw)
To: Qi Zheng
Cc: Tejun Heo, Zefan Li, Johannes Weiner, cgroups, linux-kernel,
Qi Zheng, Zhao Gongyi
> On May 17, 2023, at 15:45, Qi Zheng <qi.zheng@linux.dev> wrote:
>
> From: Qi Zheng <zhengqi.arch@bytedance.com>
>
> The commit 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock()
> deadlock") fixed the deadlock between cgroup_threadgroup_rwsem and
> cpus_read_lock() by introducing cgroup_attach_{lock,unlock}() and removing
> cpus_read_{lock,unlock}() from cpuset_attach(). But cgroup_transfer_tasks()
> was missed and not handled, which will cause th following warning:
>
> WARNING: CPU: 0 PID: 589 at kernel/cpu.c:526 lockdep_assert_cpus_held+0x32/0x40
> CPU: 0 PID: 589 Comm: kworker/1:4 Not tainted 6.4.0-rc2-next-20230517 #50
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
> Workqueue: events cpuset_hotplug_workfn
> RIP: 0010:lockdep_assert_cpus_held+0x32/0x40
> <...>
> Call Trace:
> <TASK>
> cpuset_attach+0x40/0x240
> cgroup_migrate_execute+0x452/0x5e0
> ? _raw_spin_unlock_irq+0x28/0x40
> cgroup_transfer_tasks+0x1f3/0x360
> ? find_held_lock+0x32/0x90
> ? cpuset_hotplug_workfn+0xc81/0xed0
> cpuset_hotplug_workfn+0xcb1/0xed0
> ? process_one_work+0x248/0x5b0
> process_one_work+0x2b9/0x5b0
> worker_thread+0x56/0x3b0
> ? process_one_work+0x5b0/0x5b0
> kthread+0xf1/0x120
> ? kthread_complete_and_exit+0x20/0x20
> ret_from_fork+0x1f/0x30
> </TASK>
>
> So just use the cgroup_attach_{lock,unlock}() helper to fix it.
>
> Fixes: 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
> Reported-by: Zhao Gongyi <zhaogongyi@bytedance.com>
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks()
[not found] ` <75E872A8-652F-40B0-80D0-378569E77775-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
@ 2023-05-22 2:23 ` Qi Zheng
0 siblings, 0 replies; 4+ messages in thread
From: Qi Zheng @ 2023-05-22 2:23 UTC (permalink / raw)
To: Muchun Song, Tejun Heo
Cc: Zefan Li, Johannes Weiner, cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Qi Zheng, Zhao Gongyi
On 2023/5/17 15:51, Muchun Song wrote:
>
>
>> On May 17, 2023, at 15:45, Qi Zheng <qi.zheng-fxUVXftIFDnyG1zEObXtfA@public.gmane.org> wrote:
>>
>> From: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
>>
>> The commit 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock()
>> deadlock") fixed the deadlock between cgroup_threadgroup_rwsem and
>> cpus_read_lock() by introducing cgroup_attach_{lock,unlock}() and removing
>> cpus_read_{lock,unlock}() from cpuset_attach(). But cgroup_transfer_tasks()
>> was missed and not handled, which will cause th following warning:
>>
>> WARNING: CPU: 0 PID: 589 at kernel/cpu.c:526 lockdep_assert_cpus_held+0x32/0x40
>> CPU: 0 PID: 589 Comm: kworker/1:4 Not tainted 6.4.0-rc2-next-20230517 #50
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
>> Workqueue: events cpuset_hotplug_workfn
>> RIP: 0010:lockdep_assert_cpus_held+0x32/0x40
>> <...>
>> Call Trace:
>> <TASK>
>> cpuset_attach+0x40/0x240
>> cgroup_migrate_execute+0x452/0x5e0
>> ? _raw_spin_unlock_irq+0x28/0x40
>> cgroup_transfer_tasks+0x1f3/0x360
>> ? find_held_lock+0x32/0x90
>> ? cpuset_hotplug_workfn+0xc81/0xed0
>> cpuset_hotplug_workfn+0xcb1/0xed0
>> ? process_one_work+0x248/0x5b0
>> process_one_work+0x2b9/0x5b0
>> worker_thread+0x56/0x3b0
>> ? process_one_work+0x5b0/0x5b0
>> kthread+0xf1/0x120
>> ? kthread_complete_and_exit+0x20/0x20
>> ret_from_fork+0x1f/0x30
>> </TASK>
>>
>> So just use the cgroup_attach_{lock,unlock}() helper to fix it.
>>
>> Fixes: 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
>> Reported-by: Zhao Gongyi <zhaogongyi-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
>> Signed-off-by: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
>
> Acked-by: Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Thanks. And hi Tejun, Can this patch be applied?
>
> Thanks.
>
--
Thanks,
Qi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks()
[not found] ` <20230517074545.2045035-1-qi.zheng-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
@ 2023-05-22 18:45 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2023-05-22 18:45 UTC (permalink / raw)
To: Qi Zheng
Cc: lizefan.x-EC8Uxl6Npydl57MIdRCFDg, hannes-druUgvl0LCNAfugRpC6u6w,
cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
muchun.song-fxUVXftIFDnyG1zEObXtfA, Qi Zheng, Zhao Gongyi
On Wed, May 17, 2023 at 07:45:45AM +0000, Qi Zheng wrote:
> From: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
>
> The commit 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock()
> deadlock") fixed the deadlock between cgroup_threadgroup_rwsem and
> cpus_read_lock() by introducing cgroup_attach_{lock,unlock}() and removing
> cpus_read_{lock,unlock}() from cpuset_attach(). But cgroup_transfer_tasks()
> was missed and not handled, which will cause th following warning:
>
> WARNING: CPU: 0 PID: 589 at kernel/cpu.c:526 lockdep_assert_cpus_held+0x32/0x40
> CPU: 0 PID: 589 Comm: kworker/1:4 Not tainted 6.4.0-rc2-next-20230517 #50
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
> Workqueue: events cpuset_hotplug_workfn
> RIP: 0010:lockdep_assert_cpus_held+0x32/0x40
> <...>
> Call Trace:
> <TASK>
> cpuset_attach+0x40/0x240
> cgroup_migrate_execute+0x452/0x5e0
> ? _raw_spin_unlock_irq+0x28/0x40
> cgroup_transfer_tasks+0x1f3/0x360
> ? find_held_lock+0x32/0x90
> ? cpuset_hotplug_workfn+0xc81/0xed0
> cpuset_hotplug_workfn+0xcb1/0xed0
> ? process_one_work+0x248/0x5b0
> process_one_work+0x2b9/0x5b0
> worker_thread+0x56/0x3b0
> ? process_one_work+0x5b0/0x5b0
> kthread+0xf1/0x120
> ? kthread_complete_and_exit+0x20/0x20
> ret_from_fork+0x1f/0x30
> </TASK>
>
> So just use the cgroup_attach_{lock,unlock}() helper to fix it.
>
> Fixes: 4f7e7236435c ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
> Reported-by: Zhao Gongyi <zhaogongyi-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
> Signed-off-by: Qi Zheng <zhengqi.arch-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Applied to cgroupp/for-6.4-fixes w/ Fixes tag updated to 05c7b7a92cc8 (the
commit that 4f7e7236435c fixes) and stable tag added.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-22 18:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17 7:45 [PATCH] cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks() Qi Zheng
2023-05-17 7:51 ` Muchun Song
[not found] ` <75E872A8-652F-40B0-80D0-378569E77775-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
2023-05-22 2:23 ` Qi Zheng
[not found] ` <20230517074545.2045035-1-qi.zheng-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
2023-05-22 18:45 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox