Re: [PATCH v5 1/9] lib/group_cpus: let group_cpu_evenly return number initialized masks

From: Hannes Reinecke
Date: Mon Jan 13 2025 - 02:08:17 EST


On 1/10/25 17:26, Daniel Wagner wrote:
group_cpu_evenly might allocated less groups then the requested:

group_cpu_evenly
__group_cpus_evenly
alloc_nodes_groups
# allocated total groups may be less than numgrps when
# active total CPU number is less then numgrps

In this case, the caller will do an out of bound access because the
caller assumes the masks returned has numgrps.

Return the number of groups created so the caller can limit the access
range accordingly.

Signed-off-by: Daniel Wagner <wagi@xxxxxxxxxx>
---
block/blk-mq-cpumap.c | 6 +++---
drivers/virtio/virtio_vdpa.c | 9 +++++----
fs/fuse/virtio_fs.c | 6 +++---
include/linux/group_cpus.h | 3 ++-
kernel/irq/affinity.c | 9 +++++----
lib/group_cpus.c | 12 +++++++++---
6 files changed, 27 insertions(+), 18 deletions(-)

Reviewed-by: Hannes Reinecke <hare@xxxxxxx>

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@xxxxxxx +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich