]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Revert "powerpc/xive: Fix the size of the cpumask used in xive_find_target_in_mask()"
authorYury Norov <ynorov@nvidia.com>
Thu, 19 Mar 2026 03:36:45 +0000 (23:36 -0400)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 1 Apr 2026 03:51:04 +0000 (09:21 +0530)
This reverts commit a9dadc1c512807f955f0799e85830b420da47932.

The commit message states:

    When called from xive_irq_startup(), the size of the cpumask can be
    larger than nr_cpu_ids. This can result in a WARN_ON.
    [...]
    This happens because we're being called with our affinity mask set to
    irq_default_affinity. That in turn was populated using
    cpumask_setall(), which sets NR_CPUs worth of bits, not nr_cpu_ids
    worth. Finally cpumask_weight() will return > nr_cpu_ids when passed a
    mask which has > nr_cpu_ids bits set.

In modern kernel, cpumask_weight() can't return > nr_cpu_ids.

In inline case, cpumask_setall() explicitly clears all bits above
nr_cpu_ids, see commit 63355b9884b3 ("cpumask: be more careful with
'cpumask_setall()'"). So, despite that cpumask_weight() is passed
with small_cpumask_bits, which is NR_CPUS in this case, it can't
count over the nr_cpu_ids.

In outline case, cpumask_setall() may set bits beyond the limit up to
the next byte alignment, but in this case small_cpumask_bits is wired
to nr_cpu_ids, thus making overcounting impossible.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
Tested-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260319033647.881246-2-ynorov@nvidia.com
arch/powerpc/sysdev/xive/common.c

index 6b1b7541ca311ec97bd3499ae227ea81eec204d4..33e9fb3436e1a83b26221012ae72feb40cad829a 100644 (file)
@@ -551,7 +551,7 @@ static int xive_find_target_in_mask(const struct cpumask *mask,
        int cpu, first, num, i;
 
        /* Pick up a starting point CPU in the mask based on  fuzz */
-       num = min_t(int, cpumask_weight(mask), nr_cpu_ids);
+       num = cpumask_weight(mask);
        first = fuzz % num;
 
        /* Locate it */