From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796059930; b=nxaDwk6NEL5wSJZWa4LN51cROMQa+EMRfZvZE5Q/zryYi4iVkNJGE2SRY9hDZHrimpcO Z9VLT1DT03dMHyrBX/nBCx3UMIwDq3j6rIHb0sL4Q8wu7sdPQtO7vX+4kMUc4cP/T4SV3 6ZArasH4Tn1ufWJdXJDrmUUEm3lL+yEB/P7BetqGGGYji2gYJKwQO0Eg/3d+Q9L7vX4aa EdXPsty96lfxkM6iNc+IjOSnNbB7vU9Zb/+5POuQQteRWfsQ57A+gCt7Ip6nNgR2VLzZe uR6wjJuDnusawcYLLHobtTVMVOrY95SfGOnAhx7MWARxEVK/w/yLsVMzbZ1+sw+LTzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796059930; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Scanned-By; bh=HR/vHNPADUaxEggWIOJ6cweEcMewwNA6D0o2H0rXH3c=; b=h1okJLzwsnJW4o6gz3cNYr4aGR0ugc9yYJBPMFppC5cn/AG4MACXopebAZAnQ3RyDCDx cVCsDd7nZ9SGLx+UWSbR2KATDvWI1GWMGvI9qjeH3p1F+b4yJ5mKnURBqI1i00tmaFHpk GJaGigPCkVHW7Pvp306AYW9X5IjStcRAIVOipFTq1vqxa0LxykEdGBo/Oa8vAP9hFkud1 p325KfyvdDfvLdcsowvAjRETwnPZI4LJyKXGOnvdfTkmNZhM4qNopKNo5foWS0ZOlpokP j8fT0WjEzDdE2twmWv1YAE9o+dJ9Q3Jjx1NYAH86kcmWt+FngU6SpHmzsusXQSSnR5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KQicTYRV; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91BDE606A333 for ; Mon, 30 Nov 2026 17:32:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 91BDE606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KQicTYRV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796059928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HR/vHNPADUaxEggWIOJ6cweEcMewwNA6D0o2H0rXH3c=; b=KQicTYRV26ca/NJH9FLvUw0izTGNN8Oky17amhqt8TVfN6Xy4ne/gT0fVvTkfvBZ+FgUwQ 5Bi43+fEm2P/gcXOxS+SYGJGFhHEblOItx6nEW8HHnWF+r1SRXXD0pW+AWu0rK76DY6Fjf OcOGQsggokZM65aub9P+MAD1/JcBYME= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-S0HeVWKDOyq-GgJehMUH9A-1; Mon, 30 Nov 2026 17:32:04 +0000 X-MC-Unique: S0HeVWKDOyq-GgJehMUH9A-1 X-Mimecast-MFC-AGG-ID: S0HeVWKDOyq-GgJehMUH9A_1796059923 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B89321955F2F; Mon, 30 Nov 2026 17:32:02 +0000 (UTC) Received: from [100.91.18.181] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8111A195604C; Mon, 30 Nov 2026 17:32:01 +0000 (UTC) Message-ID: <60a1d3b0-f45c-436f-922c-ed6dd3e440ac@redhat.com> Date: Mon, 30 Nov 2026 12:32:00 -0500 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] cgroup/cpuset: Skip the sched domain attribute allocation on v2 To: Chuyi Zhou , tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, ridong.chen@linux.dev Cc: linux-kernel@vger.kernel.org References: <5033dad1379435bbc1aa1610245df178b264a278.1796039668.git.zhouchuyi@bytedance.com> Content-Language: en-US From: Waiman Long In-Reply-To: <5033dad1379435bbc1aa1610245df178b264a278.1796039668.git.zhouchuyi@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 > Reviewed-by: Ridong Chen > --- > 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