From: "Badole, Vishal" <vishal.badole@amd.com>
To: "Guo, Wangyang" <wangyang.guo@intel.com>,
"tglx@kernel.org" <tglx@kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "bp@alien8.de" <bp@alien8.de>,
"Li, Tianyou" <tianyou.li@intel.com>,
"tim.c.chen@linux.intel.com" <tim.c.chen@linux.intel.com>,
"Liang, Dan" <dan.liang@intel.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v6] lib/group_cpus: Snapshot cluster masks to keep grouping hotplug invariant
Date: Fri, 6 Nov 2026 17:12:51 +0530 [thread overview]
Message-ID: <9859121c-06c9-4e2f-8003-d9d782658dda@amd.com> (raw)
In-Reply-To: <MW4PR11MB698287F2EBAD1EE84171931592692@MW4PR11MB6982.namprd11.prod.outlook.com>
Hello Wangyang,
Thanks for reviewing this patch.
On 11/3/2026 11:55 AM, Guo, Wangyang wrote:
>
> Why not use original topology_sibling_cpumask(cpu) if snapshot not
> available?
>> - siblmsk = topology_sibling_cpumask(cpu);
>> + siblmsk = sibling_snapshot ? sibling_snapshot[cpu] : cpumask_of(cpu);
>
As Andrew noted, topology_sibling_cpumask() changes during CPU hotplug,
so using it as the fallback could change the grouping. cpumask_of(cpu)
deliberately drops SMT preference when no snapshot is available, keeping
grouping independent of the online CPU set.
>
>> - * Return: true if success, false otherwise.
>> + * Return: 1 if successful, 0 if inapplicable, or -ENOMEM on allocation failure.
>> */
>> -static bool __try_group_cluster_cpus(unsigned int ncpus,
>> +static int __try_group_cluster_cpus(unsigned int ncpus,
>
> If use ncluster as ret: >= 1 successful, 0 inapplicable, and -ENOMEM for
> error.
> the code should become simpler.
Sure, I will include this change in next patch revision.
>> ncluster = alloc_cluster_groups(ncpus, ngroups, node_cpumask, nmsk,
>> &clusters, &cluster_groups);
>>
>> - if (ncluster == 0)
>> + ret = ncluster;
>> + if (ncluster <= 0)
>> goto fail_no_clusters;
>>
>> for (i = 0; i < ncluster; i++) {
>> @@ -392,12 +477,11 @@ static bool __try_group_cluster_cpus(unsigned int ncpus,
>> assign_cpus_to_groups(nc, nmsk, nv, masks, curgrp, last_grp);
>> }
>>
>> - ret = true;
>> + ret = 1;
>> kfree(cluster_groups);
>> kfree(clusters);
>> fail_no_clusters:
>> free_cpumask_var(nmsk);
>> - fail_nmsk_alloc:
> return ncluster;
>> return ret;
>> }
>
>
>> @@ -442,6 +526,7 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps,
>> - if (__try_group_cluster_cpus(ncpus, nv->ngroups, nmsk,
>> - masks, &curgrp, last_grp)) {
>> + ret = __try_group_cluster_cpus(ncpus, nv->ngroups, nmsk,
>> + masks, &curgrp, last_grp);
>> + if (ret < 0) {
>> + kfree(node_groups);
>> + return ret;
>> + }
>> + if (ret) {
>> done += nv->ngroups;
>> continue;
>> }
>
> There is duplication for "done += nv->ngroups", my suggestion:
> If (ret < 0) { kfree(node_groups); return ret;}
> elIf (!ret) assign_cpus_to_groups(ncpus, nmsk, nv, masks, &curgrp, last_grp);
> done += nv->ngroups;
> } // end of "for" loop
Thanks for the suggestion. I'll consolidate the done increment in the
next revision.
prev parent reply other threads:[~2026-11-06 11:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 7:09 Vishal Badole
2026-11-03 6:25 ` Guo, Wangyang
2026-11-06 11:42 ` Badole, Vishal [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=9859121c-06c9-4e2f-8003-d9d782658dda@amd.com \
--to=vishal.badole@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=tianyou.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=wangyang.guo@intel.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®