From: Waiman Long <longman@redhat.com>
To: Chuyi Zhou <zhouchuyi@bytedance.com>,
tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com,
ridong.chen@linux.dev
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] cgroup/cpuset: Skip sibling checks for v2 members without exclusive CPUs
Date: Mon, 30 Nov 2026 13:04:07 -0500 [thread overview]
Message-ID: <7b9f5d97-5edf-4963-ace8-9385d159b887@redhat.com> (raw)
In-Reply-To: <7b9ec8acd1d5fbc2e977ac08450aaf5de5952ce0.1796039668.git.zhouchuyi@bytedance.com>
On 11/30/26 7:04 AM, Chuyi Zhou wrote:
> Changing cpuset.cpus on a cgroup v2 member calls validate_change(),
> which walks all siblings under cpuset_mutex to check CPU and memory
> exclusivity. The cost of changing one member's CPU mask grows with
> the number of children under its parent.
>
> Skip the walk when the member's cpuset.cpus.exclusive stays empty.
> An empty exclusive mask cannot intersect a sibling's exclusive mask.
> The check for a sibling whose allowed CPUs are all in the member's
> exclusive mask applies only when that mask changes. Only the top
> cpuset is memory-exclusive on v2, so the walk can also be skipped
> when changing cpuset.mems on these members.
>
> On a dual-socket Xeon Platinum 8582C with 240 online CPUs, the target
> cpuset contained one sleeping task. A writer pinned to CPU 1 alternated
> its cpuset.cpus between 2 and 2-3. Each table entry gives the median
> latency of 256 write() calls.
>
> Children Before (ns) After (ns)
> 1 861 859
> 64 1425 856
> 512 5184 855
> 2048 24056 853
>
> Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
> ---
> kernel/cgroup/cpuset.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index fb2c08b31b53..fb6359d72b68 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -805,12 +805,21 @@ int validate_change(struct cpuset *cur, struct cpuset *trial)
> !cpuset_cpumask_can_shrink(cur->effective_cpus, user_xcpus(trial)))
> goto out;
>
> + xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus);
> +
> + /*
> + * On v2 an unchanged, empty exclusive CPU mask cannot conflict with
> + * a sibling's CPU masks. Only the top cpuset is memory-exclusive.
> + */
> + if (cpuset_v2() && cs_is_member(cur) && !xcpus_changed &&
> + cpumask_empty(trial->exclusive_cpus))
> + goto valid;
> +
> /*
> * If either I or some sibling (!= me) is exclusive, we can't
> * overlap. exclusive_cpus cannot overlap with each other if set.
> */
> ret = -EINVAL;
> - xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus);
> cpuset_for_each_child(c, css, par) {
> if (c == cur)
> continue;
> @@ -820,6 +829,7 @@ int validate_change(struct cpuset *cur, struct cpuset *trial)
> goto out;
> }
>
> +valid:
> ret = 0;
> out:
> rcu_read_unlock();
Reviewed-by: Waiman Long <longman@redhat.com>
prev parent reply other threads:[~2026-11-30 18:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:04 [PATCH v2 0/4] cgroup/cpuset: Speed up v2 mask updates and domain rebuilds Chuyi Zhou
2026-11-30 12:04 ` [PATCH v2 1/4] cgroup/cpuset: Skip the sched domain attribute allocation on v2 Chuyi Zhou
2026-11-30 17:32 ` Waiman Long
2026-11-30 12:04 ` [PATCH v2 2/4] cgroup/cpuset: Check v2 partition overlap in a single pass Chuyi Zhou
2026-11-30 18:02 ` Waiman Long
2026-11-30 18:04 ` Waiman Long
2026-11-30 12:04 ` [PATCH v2 3/4] cgroup/cpuset: Drop cpusets_overlap() Chuyi Zhou
2026-11-30 18:03 ` Waiman Long
2026-11-30 18:11 ` Waiman Long
2026-11-30 12:04 ` [PATCH v2 4/4] cgroup/cpuset: Skip sibling checks for v2 members without exclusive CPUs Chuyi Zhou
2026-11-30 18:04 ` Waiman Long [this message]
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=7b9f5d97-5edf-4963-ace8-9385d159b887@redhat.com \
--to=longman@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=tj@kernel.org \
--cc=zhouchuyi@bytedance.com \
/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®