mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chuyi Zhou" <zhouchuyi@bytedance.com>
To: "Ridong Chen" <ridong.chen@linux.dev>, <longman@redhat.com>,
	 <tj@kernel.org>, <hannes@cmpxchg.org>, <mkoutny@suse.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] cgroup/cpuset: Skip the sched domain attribute allocation on v2
Date: Thu, 26 Nov 2026 13:11:12 +0800	[thread overview]
Message-ID: <662116f4-8359-49c9-a78d-5635c2458cab@bytedance.com> (raw)
In-Reply-To: <4d70562b-6604-456f-9175-5b6b17f46f26@linux.dev>

On 2026-11-26 10:49 a.m., Ridong Chen wrote:
> 
> 
> On 11/23/2026 8:45 PM, 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>
>> ---
>>   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 c7b3a734cda8..633fd05f513e 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -867,7 +867,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;
>> @@ -875,7 +874,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 */
>> @@ -926,15 +924,8 @@ generate_doms:
>>           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++) {
>>           /*
>> @@ -946,8 +937,6 @@ generate_doms:
>>                       housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT));
>>           else
>>               cpumask_copy(doms[i], csa[i]->effective_cpus);
>> -        if (dattr)
>> -            dattr[i] = SD_ATTR_INIT;
>>       }
>>   done:
>> @@ -960,8 +949,12 @@ done:
>>       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;
>>   }
> 
> LGTM.
> 
> Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
> Thanks.
> 

Thanks for the review!
I'll add Reviewed-by tag if I need to send v2.

  reply	other threads:[~2026-11-26  5:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 12:45 [PATCH 0/3] cgroup/cpuset: Speed up v2 mask updates and domain rebuilds Chuyi Zhou
2026-11-23 12:45 ` [PATCH 1/3] cgroup/cpuset: Skip the sched domain attribute allocation on v2 Chuyi Zhou
2026-11-26  2:49   ` Ridong Chen
2026-11-26  5:11     ` Chuyi Zhou [this message]
2026-11-23 12:45 ` [PATCH 2/3] cgroup/cpuset: Check v2 partition overlap in a single pass Chuyi Zhou
2026-11-28  1:46   ` Ridong Chen
2026-11-23 12:45 ` [PATCH 3/3] cgroup/cpuset: Skip sibling checks for v2 members without exclusive CPUs Chuyi Zhou

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=662116f4-8359-49c9-a78d-5635c2458cab@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --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®