From: Waiman Long <llong@redhat.com>
To: Tejun Heo <tj@kernel.org>, Waiman Long <llong@redhat.com>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 01/10] cgroup/cpuset: Fix race between newly created partition and dying one
Date: Tue, 1 Apr 2025 16:41:55 -0400 [thread overview]
Message-ID: <d9c96490-98bf-406b-8324-6cf86a536433@redhat.com> (raw)
In-Reply-To: <Z-xFqkBsh640l5j0@mtj.duckdns.org>
On 4/1/25 3:59 PM, Tejun Heo wrote:
> Hello, Waiman.
>
> On Mon, Mar 31, 2025 at 11:12:06PM -0400, Waiman Long wrote:
>> The problem is the RCU delay between the time a cgroup is killed and is in a
>> dying state and when the partition is deactivated when cpuset_css_offline()
>> is called. That delay can be rather lengthy depending on the current
>> workload.
> If we don't have to do it too often, synchronize_rcu_expedited() may be
> workable too. What do you think?
I don't think we ever call synchronize_rcu() in the cgroup code except
for rstat flush. In fact, we didn't use to have an easy way to know if
there were dying cpusets hanging around. Now we can probably use the
root cgroup's nr_dying_subsys[cpuset_cgrp_id] to know if we need to use
synchronize_rcu*() call to wait for it. However, I still need to check
if there is any racing window that will cause us to miss it.
>
>> Another alternative that I can think of is to scan the remote partition list
>> for remote partition and sibling cpusets for local partition whenever some
>> kind of conflicts are detected when enabling a partition. When a dying
>> cpuset partition is detected, deactivate it immediately to resolve the
>> conflict. Otherwise, the dying partition will still be deactivated at
>> cpuset_css_offline() time.
>>
>> That will be a bit more complex and I think can still get the problem solved
>> without adding a new method. What do you think? If you are OK with that, I
>> will send out a new patch later this week.
> If synchronize_rcu_expedited() won't do, let's go with the original patch.
> The operation does make general sense in that it's for a distinctive step in
> the destruction process although I'm a bit curious why it's called before
> DYING is set.
Again, we have to synchronize between the css_is_dying() call in
is_cpuset_online() which is used by cpuset_for_each_child() against the
calling of cpuset_css_killed(). Since setting of the CSS_DYING flag is
protected by cgroup_mutex() while most of the cpuset code is protected
by cpuset_mutex. The two operations can be asynchronous with each other.
So I have to make sure that by the time CSS_DYING is set, the
cpuset_css_killed() call has been invoked. I need to do similar check if
we decide to use synchronize_rcu*() to wait for the completion of
cpuset_css_offline() call.
As I am also dealing with a lot of locking related issues, I am more
attuned to this kind of racing conditions to make sure nothing bad will
happen.
Cheers,
Longman
next prev parent reply other threads:[~2025-04-01 20:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-30 21:52 [PATCH 00/10] cgroup/cpuset: Miscellaneous partition bug fixes and enhancements Waiman Long
2025-03-30 21:52 ` [PATCH 01/10] cgroup/cpuset: Fix race between newly created partition and dying one Waiman Long
2025-03-31 23:13 ` Tejun Heo
2025-04-01 3:12 ` Waiman Long
2025-04-01 19:59 ` Tejun Heo
2025-04-01 20:41 ` Waiman Long [this message]
2025-04-01 20:56 ` Waiman Long
2025-04-02 7:49 ` Tejun Heo
2025-04-03 13:34 ` Michal Koutný
2025-04-03 16:15 ` Tejun Heo
2025-03-30 21:52 ` [PATCH 02/10] cgroup/cpuset: Fix incorrect isolated_cpus update in update_parent_effective_cpumask() Waiman Long
2025-03-30 21:52 ` [PATCH 03/10] cgroup/cpuset: Fix error handling in remote_partition_disable() Waiman Long
2025-03-30 21:52 ` [PATCH 04/10] cgroup/cpuset: Remove remote_partition_check() & make update_cpumasks_hier() handle remote partition Waiman Long
2025-03-30 21:52 ` [PATCH 05/10] cgroup/cpuset: Don't allow creation of local partition over a remote one Waiman Long
2025-04-03 13:33 ` Michal Koutný
2025-04-03 13:48 ` Waiman Long
2025-03-30 21:52 ` [PATCH 06/10] cgroup/cpuset: Code cleanup and comment update Waiman Long
2025-03-30 21:52 ` [PATCH 07/10] cgroup/cpuset: Remove unneeded goto in sched_partition_write() and rename it Waiman Long
2025-04-03 13:33 ` Michal Koutný
2025-04-03 13:49 ` Waiman Long
2025-03-30 21:52 ` [PATCH 08/10] selftest/cgroup: Update test_cpuset_prs.sh to use | as effective CPUs and state separator Waiman Long
2025-03-30 21:52 ` [PATCH 09/10] selftest/cgroup: Clean up and restructure test_cpuset_prs.sh Waiman Long
2025-03-30 21:52 ` [PATCH 10/10] selftest/cgroup: Add a remote partition transition test to test_cpuset_prs.sh Waiman Long
2025-03-31 23:28 ` Tejun Heo
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=d9c96490-98bf-406b-8324-6cf86a536433@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=shuah@kernel.org \
--cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®