From: Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
To: Cai Xinchen <caixinchen1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mkoutny-IBi9RG/b67k@public.gmane.org,
zhangqiao22-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
penguin-kernel-1yMVhJb1mP/7nzcFbJAaVXf5DAMn2ifp@public.gmane.org,
stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 4.19 0/3] Backport patches to fix threadgroup_rwsem <-> cpus_read_lock() deadlock
Date: Mon, 3 Apr 2023 15:30:51 +0200 [thread overview]
Message-ID: <2023040343-dingbat-undermine-3b2d@gregkh> (raw)
In-Reply-To: <20230320011507.129441-1-caixinchen1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
On Mon, Mar 20, 2023 at 01:15:04AM +0000, Cai Xinchen wrote:
> I am very sorry. My gcc version is 7.5 and it does not report error.
>
> We have a deadlock problem which can be solved by commit 4f7e7236435ca
> ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock").
> However, it makes lock order of cpus_read_lock and cpuset_mutex
> wrong in v4.19. The call sequence is as follows:
> cgroup_procs_write()
> cgroup_procs_write_start()
> get_online_cpus(); // cpus_read_lock()
> percpu_down_write(&cgroup_threadgroup_rwsem)
> cgroup_attach_task
> cgroup_migrate
> cgroup_migrate_execute
> ss->attach (cpust_attach)
> mutex_lock(&cpuset_mutex)
> it seems hard to make cpus_read_lock is locked before
> cgroup_threadgroup_rwsem and cpuset_mutex is locked before
> cpus_read_lock unless backport the commit d74b27d63a8beb
> ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock order")
>
> Changes in v2:
> * Add #include <linux/cpu.h> in kernel/cgroup/cgroup.c to
> avoid some compile error.
> * Exchange get_online_cpus() location in cpuset_attach to
> keep cpu_hotplug_lock->cpuset_mutex order, although it will
> be remove by ("cgroup: Fix threadgroup_rwsem <->
> cpus_read_lock() deadlock")
>
> Juri Lelli (1):
> cgroup/cpuset: Change cpuset_rwsem and hotplug lock order
>
> Tejun Heo (1):
> cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
>
> Tetsuo Handa (1):
> cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()
>
> include/linux/cpuset.h | 8 +++----
> kernel/cgroup/cgroup-v1.c | 3 +++
> kernel/cgroup/cgroup.c | 50 +++++++++++++++++++++++++++++++++++----
> kernel/cgroup/cpuset.c | 25 ++++++++++++--------
> 4 files changed, 67 insertions(+), 19 deletions(-)
Now queued up, thanks.
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Cai Xinchen <caixinchen1@huawei.com>
Cc: longman@redhat.com, lizefan.x@bytedance.com, tj@kernel.org,
hannes@cmpxchg.org, sashal@kernel.org, mkoutny@suse.com,
zhangqiao22@huawei.com, juri.lelli@redhat.com,
penguin-kernel@i-love.sakura.ne.jp, stable@vger.kernel.org,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4.19 0/3] Backport patches to fix threadgroup_rwsem <-> cpus_read_lock() deadlock
Date: Mon, 3 Apr 2023 15:30:51 +0200 [thread overview]
Message-ID: <2023040343-dingbat-undermine-3b2d@gregkh> (raw)
In-Reply-To: <20230320011507.129441-1-caixinchen1@huawei.com>
On Mon, Mar 20, 2023 at 01:15:04AM +0000, Cai Xinchen wrote:
> I am very sorry. My gcc version is 7.5 and it does not report error.
>
> We have a deadlock problem which can be solved by commit 4f7e7236435ca
> ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock").
> However, it makes lock order of cpus_read_lock and cpuset_mutex
> wrong in v4.19. The call sequence is as follows:
> cgroup_procs_write()
> cgroup_procs_write_start()
> get_online_cpus(); // cpus_read_lock()
> percpu_down_write(&cgroup_threadgroup_rwsem)
> cgroup_attach_task
> cgroup_migrate
> cgroup_migrate_execute
> ss->attach (cpust_attach)
> mutex_lock(&cpuset_mutex)
> it seems hard to make cpus_read_lock is locked before
> cgroup_threadgroup_rwsem and cpuset_mutex is locked before
> cpus_read_lock unless backport the commit d74b27d63a8beb
> ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock order")
>
> Changes in v2:
> * Add #include <linux/cpu.h> in kernel/cgroup/cgroup.c to
> avoid some compile error.
> * Exchange get_online_cpus() location in cpuset_attach to
> keep cpu_hotplug_lock->cpuset_mutex order, although it will
> be remove by ("cgroup: Fix threadgroup_rwsem <->
> cpus_read_lock() deadlock")
>
> Juri Lelli (1):
> cgroup/cpuset: Change cpuset_rwsem and hotplug lock order
>
> Tejun Heo (1):
> cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
>
> Tetsuo Handa (1):
> cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()
>
> include/linux/cpuset.h | 8 +++----
> kernel/cgroup/cgroup-v1.c | 3 +++
> kernel/cgroup/cgroup.c | 50 +++++++++++++++++++++++++++++++++++----
> kernel/cgroup/cpuset.c | 25 ++++++++++++--------
> 4 files changed, 67 insertions(+), 19 deletions(-)
Now queued up, thanks.
greg k-h
next prev parent reply other threads:[~2023-04-03 13:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 1:15 [PATCH v2 4.19 0/3] Backport patches to fix threadgroup_rwsem <-> cpus_read_lock() deadlock Cai Xinchen
2023-03-20 1:15 ` Cai Xinchen
2023-03-20 1:15 ` [PATCH v2 4.19 1/3] cgroup/cpuset: Change cpuset_rwsem and hotplug lock order Cai Xinchen
2023-03-20 1:15 ` Cai Xinchen
2023-03-20 1:15 ` [PATCH v2 4.19 3/3] cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all() Cai Xinchen
2023-03-20 1:15 ` Cai Xinchen
[not found] ` <20230320011507.129441-1-caixinchen1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-03-20 1:15 ` [PATCH v2 4.19 2/3] cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock Cai Xinchen
2023-03-20 1:15 ` Cai Xinchen
2023-04-03 13:30 ` Greg KH [this message]
2023-04-03 13:30 ` [PATCH v2 4.19 0/3] Backport patches to fix " Greg KH
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=2023040343-dingbat-undermine-3b2d@gregkh \
--to=gregkh-hqyy1w1ycw8ekmwlsbkhg0b+6bgklq7r@public.gmane.org \
--cc=caixinchen1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mkoutny-IBi9RG/b67k@public.gmane.org \
--cc=penguin-kernel-1yMVhJb1mP/7nzcFbJAaVXf5DAMn2ifp@public.gmane.org \
--cc=sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=zhangqiao22-hv44wF8Li93QT0dZR+AlfA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.