[PATCH 0/3] cgroup/cpuset: Speed up v2 mask updates and domain rebuilds

From: Chuyi Zhou

Date: Mon Nov 23 2026 - 07:46:09 EST


We run high-density container workloads on large bare-metal hosts using
cgroup v2. We may configure many root partitions on a single host.

Changing a member's cpuset.cpus scans its siblings under cpuset_mutex,
so the cost of a write grows with the number of children under the same
parent. Creating or resizing a root partition can trigger a scheduling
domain rebuild. The rebuild checks every pair of partition CPU masks for
overlap, so the number of checks grows quadratically with the number of
partitions.

This series speeds up cpuset.cpus updates and scheduling domain rebuilds
on these hosts. The timings below are from a dual-socket Xeon Platinum
8582C with 240 online CPUs.

1. All v2 partitions use the default scheduling domain attributes.
Passing NULL saves one array allocation per rebuild and one attribute
initialization per partition.

2. Check each partition's effective CPUs against the union of the masks
already seen to detect overlap in a single pass. With 128 root
partitions, median time in generate_sched_domains() fell from 42.9 us
to 3.14 us.

3. Skip the sibling scan when a member's cpuset.cpus.exclusive stays
empty. With 2,048 children under one parent and one sleeping task in
the target cpuset, median write latency for cpuset.cpus fell from
24.1 us to 0.85 us.

Thanks,
Chuyi

Chuyi Zhou (3):
cgroup/cpuset: Skip the sched domain attribute allocation on v2
cgroup/cpuset: Check v2 partition overlap in a single pass
cgroup/cpuset: Skip sibling checks for v2 members without exclusive
CPUs

kernel/cgroup/cpuset-internal.h | 1 -
kernel/cgroup/cpuset.c | 74 +++++++++++++++++----------------
2 files changed, 39 insertions(+), 36 deletions(-)


base-commit: a6ca40399708c4322e87448f6c47da7192d72895
--
2.20.1