[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Ygqyj7nns+mxH81t@slm.duckdns.org>
Date: Mon, 14 Feb 2022 09:50:39 -1000
From: Tejun Heo <tj@...nel.org>
To: Zhang Qiao <zhangqiao22@...wei.com>
Cc: linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
lizefan.x@...edance.com, hannes@...xchg.org, matthltc@...ibm.com,
bblum@...gle.com, menage@...gle.com, akpm@...ux-foundation.org,
longman@...hat.com, mkoutny@...e.com, zhaogongyi@...wei.com
Subject: Re: [PATCH] cgroup/cpuset: Fix a race between cpuset_attach() and
cpu hotplug
On Fri, Jan 21, 2022 at 06:12:10PM +0800, Zhang Qiao wrote:
> As previously discussed(https://lkml.org/lkml/2022/1/20/51),
> cpuset_attach() is affected with similar cpu hotplug race,
> as follow scenario:
>
> cpuset_attach() cpu hotplug
> --------------------------- ----------------------
> down_write(cpuset_rwsem)
> guarantee_online_cpus() // (load cpus_attach)
> sched_cpu_deactivate
> set_cpu_active()
> // will change cpu_active_mask
> set_cpus_allowed_ptr(cpus_attach)
> __set_cpus_allowed_ptr_locked()
> // (if the intersection of cpus_attach and
> cpu_active_mask is empty, will return -EINVAL)
> up_write(cpuset_rwsem)
>
> To avoid races such as described above, protect cpuset_attach() call
> with cpu_hotplug_lock.
>
> Fixes: be367d099270 ("cgroups: let ss->can_attach and ss->attach do whole threadgroups at a time")
> Reported-by: Zhao Gongyi <zhaogongyi@...wei.com>
> Signed-off-by: Zhang Qiao <zhangqiao22@...wei.com>
Applied to cgroup/for-5.17-fixes w/ stable cc'd.
Thanks and sorry about the delay.
--
tejun
Powered by blists - more mailing lists