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 1/4] cgroup/cpuset: Skip the sched domain attribute allocation on v2
Date: Mon, 30 Nov 2026 12:32:00 -0500 [thread overview]
Message-ID: <60a1d3b0-f45c-436f-922c-ed6dd3e440ac@redhat.com> (raw)
In-Reply-To: <5033dad1379435bbc1aa1610245df178b264a278.1796039668.git.zhouchuyi@bytedance.com>
On 11/30/26 7:04 AM, Chuyi Zhou wrote:
> Cgroup v2 cpusets use the default scheduling domain attributes for every
> partition. The scheduler treats a NULL attribute pointer as the default
> both when matching existing domains and when building new ones.
>
> generate_sched_domains() allocates an attribute array for v2 and fills
> each entry with SD_ATTR_INIT, even in the single-partition case.
>
> Return NULL for the v2 attributes. For N > 0 partitions, this saves one
> memory allocation and N attribute initializations per rebuild.
>
> Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
> Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
> ---
> kernel/cgroup/cpuset.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 45c6a2c99f20..23348b6b40f6 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -868,7 +868,6 @@ static int generate_sched_domains(cpumask_var_t **domains,
> struct cpuset **csa; /* array of all cpuset ptrs */
> int i, j; /* indices for partition finding loops */
> cpumask_var_t *doms; /* resulting partition; i.e. sched domains */
> - struct sched_domain_attr *dattr; /* attributes for custom domains */
> int ndoms = 0; /* number of sched domains in result */
> struct cgroup_subsys_state *pos_css;
>
> @@ -876,7 +875,6 @@ static int generate_sched_domains(cpumask_var_t **domains,
> return cpuset1_generate_sched_domains(domains, attributes);
>
> doms = NULL;
> - dattr = NULL;
> csa = NULL;
>
> /* Special case for the 99% of systems with one, full, sched domain */
> @@ -927,15 +925,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
> goto done;
>
> /*
> - * The rest of the code, including the scheduler, can deal with
> - * dattr==NULL case. No need to abort if alloc fails.
> - */
> - dattr = kmalloc_objs(struct sched_domain_attr, ndoms);
> -
> - /*
> - * Cgroup v2 doesn't support domain attributes, just set all of them
> - * to SD_ATTR_INIT. Also non-isolating partition root CPUs are a
> - * subset of HK_TYPE_DOMAIN_BOOT housekeeping CPUs.
> + * Non-isolating child partition root CPUs are a subset of
> + * HK_TYPE_DOMAIN_BOOT housekeeping CPUs.
> */
> for (i = 0; i < ndoms; i++) {
> /*
> @@ -947,8 +938,6 @@ static int generate_sched_domains(cpumask_var_t **domains,
> housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT));
> else
> cpumask_copy(doms[i], csa[i]->effective_cpus);
> - if (dattr)
> - dattr[i] = SD_ATTR_INIT;
> }
>
> done:
> @@ -961,8 +950,12 @@ static int generate_sched_domains(cpumask_var_t **domains,
> if (doms == NULL)
> ndoms = 1;
>
> + /*
> + * Cgroup v2 uses the default domain attributes. The scheduler treats
> + * a NULL attribute array as SD_ATTR_INIT for every partition.
> + */
> *domains = doms;
> - *attributes = dattr;
> + *attributes = NULL;
> return ndoms;
> }
>
The cpuset code is usually considered a slow path and so we don't pay
too much attention on performance. It looks like we will have to pay a
bit more attention going forward.
The code looks good to me.
Reviewed-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2026-11-30 17:32 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 [this message]
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
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=60a1d3b0-f45c-436f-922c-ed6dd3e440ac@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®