From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-scsi@vger.kernel.org, virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v17 03/10] lib/group_cpus: Add group_mask_cpus_evenly()
Date: Sun, 29 Nov 2026 07:33:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-239378@kernel.org> (raw)
In-Reply-To: <20261129045436.255364-4-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] lib/group_cpus: group_mask_cpus_evenly() duplicates
group_cpus_evenly()
--
commit ea8c98b46f36bc22b6c75e4130661116efe0e69c
Author: Daniel Wagner <wagi@kernel.org>
lib/group_cpus: Add group_mask_cpus_evenly()
This commit introduces group_mask_cpus_evenly() to distribute a specific
caller-provided CPU mask evenly across groups using a two-stage present and
non-present spreading pass.
> diff --git a/lib/group_cpus.c b/lib/group_cpus.c
> index b8d54398f88a1..75bd082e00bf4 100644
> --- a/lib/group_cpus.c
> +++ b/lib/group_cpus.c
> @@ -563,3 +563,113 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps, unsigned int *nummasks)
> return masks;
> }
> EXPORT_SYMBOL_GPL(group_cpus_evenly);
> +
> +/**
> + * group_mask_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality
[ ... ]
> +struct cpumask *group_mask_cpus_evenly(unsigned int numgrps,
> + const struct cpumask *mask,
> + unsigned int *nummasks)
> +{
> + unsigned int curgrp = 0, nr_present = 0, nr_others = 0;
> + cpumask_var_t *node_to_cpumask;
> + cpumask_var_t nmsk, local_mask, npresmsk;
> + int ret = -ENOMEM;
> + struct cpumask *masks = NULL;
[ ... ]
> + cpumask_copy(local_mask, mask);
> +
> + /*
> + * Grouping present CPUs first. We intersect the provided mask with
> + * cpu_present_mask to ensure that we prioritise physically
> + * available CPUs for the initial distribution.
> + */
> + cpumask_and(npresmsk, local_mask, cpu_present_mask);
> + ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask,
> + npresmsk, nmsk, masks);
> + if (ret < 0)
> + goto fail_node_to_cpumask;
> + nr_present = ret;
> +
> + /*
> + * Allocate non-present CPUs starting from the next group to be
> + * handled. If the grouping of present CPUs already exhausted the
> + * group space, assign the non-present CPUs to the already
> + * allocated out groups.
> + */
> + if (nr_present >= numgrps)
> + curgrp = 0;
> + else
> + curgrp = nr_present;
> + cpumask_andnot(npresmsk, local_mask, npresmsk);
> + ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask,
> + npresmsk, nmsk, masks);
> + if (ret >= 0)
> + nr_others = ret;
[Severity: Low]
Could group_cpus_evenly() simply call group_mask_cpus_evenly(numgrps,
cpu_possible_mask, nummasks) instead of duplicating the allocation,
two-stage spreading, and cleanup logic? Since cpu_present_mask is a subset
of cpu_possible_mask, passing cpu_possible_mask as mask produces the same
two-stage distribution.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129045436.255364-1-atomlin@atomlin.com?part=3
next prev parent reply other threads:[~2026-11-29 7:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 4:54 [PATCH v17 00/10] blk: honor isolcpus configuration Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 01/10] scsi: aacraid: use block layer helpers to calculate num of queues Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 02/10] lib/group_cpus: remove dead !SMP code Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 03/10] lib/group_cpus: Add group_mask_cpus_evenly() Aaron Tomlin
2026-11-29 7:33 ` sashiko-bot [this message]
2026-11-29 4:54 ` [PATCH v17 04/10] sched/isolation: Prevent out-of-bounds read in isolcpus= boot parameter parser Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 05/10] blk-mq: use hk cpus only when isolcpus=managed_irq is enabled Aaron Tomlin
2026-11-29 7:58 ` sashiko-bot
2026-11-29 7:26 ` [PATCH v17 06/10] blk-mq: prevent offlining hk CPUs with associated online isolated CPUs Aaron Tomlin
2026-11-29 7:46 ` sashiko-bot
2026-11-29 7:26 ` [PATCH v17 07/10] virtio-fs: honour isolcpus=managed_irq in queue mapping Aaron Tomlin
2026-11-29 7:26 ` [PATCH v17 08/10] genirq/affinity: Restrict managed IRQ affinity to housekeeping CPUs Aaron Tomlin
2026-11-29 7:48 ` sashiko-bot
2026-11-29 7:26 ` [PATCH v17 09/10] docs: update isolcpus=managed_irq documentation Aaron Tomlin
2026-11-29 7:26 ` [PATCH v17 10/10] genirq/affinity: Confine pre and post vectors to housekeeping CPUs Aaron Tomlin
2026-11-29 7:41 ` sashiko-bot
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=sashiko-outbox-239378@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=eperezma@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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