sched/cache: "Make LLC id continuous" causes NULL cpumask dereference in build_sched_domains on POWER9
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Traces:
[ 0.038567] Big cores detected but using small core scheduling
[ 0.038796] BUG: Kernel NULL pointer dereference at 0x00000000
[ 0.038804] Faulting instruction address: 0xc000000000e58504
[ 0.038812] Oops: Kernel access of bad area, sig: 11 [#1]
[ 0.038819] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=8192 NUMA pSeries
[ 0.038830] Modules linked in:
[ 0.038840] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.0.0-rc6+ #14 PREEMPTLAZY
[ 0.038851] Hardware name: IBM,8375-42A POWER9 (architected) 0x4e0202 0xf000005 of:IBM,FW950.80 (VL950_131) hv:phyp pSeries
[ 0.038860] NIP: c000000000e58504 LR: c000000000e58500 CTR: 0000000000000000
[ 0.038869] REGS: c0000000090e78e0 TRAP: 0380 Not tainted (7.0.0-rc6+)
[ 0.038878] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002242 XER: 20040003
[ 0.038907] CFAR: c00000000093f3f0 IRQMASK: 0
[ 0.038907] GPR00: c00000000038b3b8 c0000000090e7b80 c00000000259a800 0000000000000000
[ 0.038907] GPR04: 0000000000000038 0000000000000038 c00000000c6e2560 0000000000000000
[ 0.038907] GPR08: 0000000000000000 0000000000000037 0000ffffffffffff 0000000000000000
[ 0.038907] GPR12: c000000000072730 c0000000051b0000 c00000000c6ee560 00000000ffffffff
[ 0.038907] GPR16: 0000000000000000 0000000000000038 c0000000032c6b08 fffffffffffffff6
[ 0.038907] GPR20: 0000000000000000 c000000004d1a6e0 0000000000000000 0000000000000000
[ 0.038907] GPR24: 0000000000000000 0000000000000000 00000000ffffffff c00000000a3bf940
[ 0.038907] GPR28: 0000000000000038 0000000000000000 0000000000000000 0000000000000000
[ 0.039029] NIP [c000000000e58504] _find_first_bit+0x44/0x130
[ 0.039043] LR [c000000000e58500] _find_first_bit+0x40/0x130
[ 0.039054] Call Trace:
[ 0.039060] [c0000000090e7b80] [c00000000416af20] schedutil_gov+0x0/0xa0 (unreliable)
[ 0.039076] [c0000000090e7bc0] [c00000000038b3b8] build_sched_domains+0xad8/0xe50
[ 0.039089] [c0000000090e7ce0] [c000000003045d78] sched_init_smp+0xa8/0x164
[ 0.039102] [c0000000090e7d30] [c00000000300f374] kernel_init_freeable+0x250/0x370
[ 0.039117] [c0000000090e7de0] [c000000000011f90] kernel_init+0x34/0x1e4
[ 0.039129] [c0000000090e7e50] [c00000000000debc] ret_from_kernel_user_thread+0x14/0x1c
[ 0.039142] ---- interrupt: 0 at 0x0
[ 0.039150] Code: 41820090 7c0802a6 393cffff fbe10038 7c7f1b78 fba10028 fbc10030 3bc00000 793dd7e2 f8010050 4bae6e9d 60000000 <e93f0000> 2c290000 408200bc 283c0040 [ 0.039196] ---[ end trace 0000000000000000 ]---
Git bisect is pointing to b5ea300a17e3 sched/cache: Make LLC id continuous as first bad commit.
Git Bisect Logs:
# git bisect log git bisect start # status: waiting for both good and bad commits # bad: [c1ecb239fa3456529a32255359fc78b69eb9d847] Add linux-next specific files for 20260522 git bisect bad c1ecb239fa3456529a32255359fc78b69eb9d847 # status: waiting for good commit(s), bad commit known # good: [5200f5f493f79f14bbdc349e402a40dfb32f23c8] Linux 7.1-rc4 git bisect good 5200f5f493f79f14bbdc349e402a40dfb32f23c8 # good: [7cd27a0d57b8539366c98bb04fe48d1aff779ea9] Merge branch 'main' of https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git git bisect good 7cd27a0d57b8539366c98bb04fe48d1aff779ea9 # good: [efb3dd6031ec9858c7285fd673970320c86c01f3] Merge branch 'next' of https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git git bisect good efb3dd6031ec9858c7285fd673970320c86c01f3 # bad: [1a6066d1c1243fdc5ed464032bbdf12e6710c027] Merge branch 'driver-core-next' of https://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git git bisect bad 1a6066d1c1243fdc5ed464032bbdf12e6710c027 # good: [409a99cbc316d912c999fd75b9df042b25900e50] Merge branch 'for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git git bisect good 409a99cbc316d912c999fd75b9df042b25900e50 # bad: [af73f6b022c8c09a3234176892a18216be4cd984] Merge branch 'next' of git://git.kernel.org/pub/scm/virt/kvm/kvm.git git bisect bad af73f6b022c8c09a3234176892a18216be4cd984 # bad: [6a459eb254e4bff61546587eccd3091955123d24] Merge branch into tip/master: 'sched/core' git bisect bad 6a459eb254e4bff61546587eccd3091955123d24 # good: [71ba4bb66c3a9287245d0f5fcfb27d4b951ba402] Merge branch into tip/master: 'locking/core' git bisect good 71ba4bb66c3a9287245d0f5fcfb27d4b951ba402 # good: [f3b45696a160a2230d846de8f706e835984ae65b] Merge branch into tip/master: 'objtool/core' git bisect good f3b45696a160a2230d846de8f706e835984ae65b # bad: [c99b8593b060931c5a0a4b701689f8d6a2c00dbf] sched/cache: Fix stale preferred_llc for a new task git bisect bad c99b8593b060931c5a0a4b701689f8d6a2c00dbf # bad: [5b1d5e6db20a6c64ffb95d04578db8c4b0228eea] sched/cache: Respect LLC preference in task migration and detach git bisect bad 5b1d5e6db20a6c64ffb95d04578db8c4b0228eea # bad: [46afe3af7ead57190b6d362e214814ec804e3b7b] sched/cache: Track LLC-preferred tasks per runqueue git bisect bad 46afe3af7ead57190b6d362e214814ec804e3b7b # good: [f025ef275388742643a2c33f00a0d9c0af3112ee] sched/cache: Record per LLC utilization to guide cache aware scheduling decisions git bisect good f025ef275388742643a2c33f00a0d9c0af3112ee # bad: [b5ea300a17e37eada7a98561fbd34a3054578713] sched/cache: Make LLC id continuous git bisect bad b5ea300a17e37eada7a98561fbd34a3054578713 # good: [23b2b5ccc45ce2a38b9336a916088fffdc4cdfb1] sched/cache: Introduce helper functions to enforce LLC migration policy git bisect good 23b2b5ccc45ce2a38b9336a916088fffdc4cdfb1 # first bad commit: [b5ea300a17e37eada7a98561fbd34a3054578713] sched/cache: Make LLC id continuous
b5ea300a17e37eada7a98561fbd34a3054578713 is the first bad commit commit b5ea300a17e37eada7a98561fbd34a3054578713
Author: Tim Chen <[email protected]>
Date: Wed Apr 1 14:52:17 2026 -0700
sched/cache: Make LLC id continuous
Introduce an index mapping between CPUs and their LLCs. This provides a roughly continuous per LLC index needed for cache-aware load balancing in later patches.
The existing per_cpu llc_id usually points to the first CPU of the LLC domain, which is sparse and unsuitable as an array index. Using llc_id directly would waste memory.
With the new mapping, CPUs in the same LLC share an approximate continuous id:
per_cpu(llc_id, CPU=0...15) = 0
per_cpu(llc_id, CPU=16...31) = 1
per_cpu(llc_id, CPU=32...47) = 2
...
Note that the LLC IDs are allocated via bitmask, so the IDs may be reused during CPU offline->online transitions.
kernel/sched/core.c | 2 ++
kernel/sched/sched.h | 3 ++
kernel/sched/topology.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 93 insertions(+), 2 deletions(-)
If you happen to fix this, please add below tag.
Regards,
Venkat.
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Thanks for the test.
Quoted 14 lines
Traces:
[ 0.038567] Big cores detected but using small core scheduling
[ 0.038796] BUG: Kernel NULL pointer dereference at0x00000000
[ 0.038804] Faulting instruction address:0xc000000000e58504
[ 0.038812] Oops: Kernel access of bad area, sig: 11 [#1]
[ 0.038819] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=8192 NUMA pSeries
[ 0.038830] Modules linked in:
[ 0.038840] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.0.0- rc6+ #14 PREEMPTLAZY
[ 0.038851] Hardware name: IBM,8375-42A POWER9 (architected)0x4e02020xf000005of:IBM,FW950.80 (VL950_131) hv:phyp pSeries [ 0.039029] NIP [c000000000e58504]_find_first_bit+0x44/0x130
[ 0.039043] LR [c000000000e58500]_find_first_bit+0x40/0x130
[ 0.039076] [c0000000090e7bc0] [c00000000038b3b8]build_sched_domains+0xad8/0xe50
It seems that cpumask_first(llc_mask(i)) is accessing NULL cpu_coregroup_mask():has_coregroup_support() is false, thus cpu_coregroup_map is never allocated in smp_prepare_cpus().
This machine is a "shared system" VM. We should probably let the LLC id generation fall back to using L2 id if cpu_coregroup_mask is unavailable (which restores the behavior before this patch). I'm wondering if the following change would help(need IBM friends' help on this):
arch/powerpc/kernel/smp.c +8 -5
@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ }#endif -struct cpumask *cpu_coregroup_mask (int cpu) -{ -return per_cpu (cpu_coregroup_map, cpu); -} -static bool has_coregroup_support (void ) {/* Coregroup identification not available on shared systems */
@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void)return coregroup_enabled; } +struct cpumask *cpu_coregroup_mask (int cpu) +{ +if (!has_coregroup_support ()) +return cpu_l2_cache_mask (cpu); + +return per_cpu (cpu_coregroup_map, cpu); +} +static int __init init_big_cores (void ) {int cpu;
K Prateek Nayak
reviewerHello Chenyu, Venkat,
Quoted 17 lines · Yu C
arch/powerpc/kernel/smp.c +0
-5@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endif -struct cpumask *cpu_coregroup_mask (int cpu) -{ - return per_cpu(cpu_coregroup_map, cpu); -} - static bool has_coregroup_support(void) { /* Coregroup identification not available on shared systems */
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1058
Quoted 8 lines
arch/powerpc/kernel/smp.c +5
-0@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void) return coregroup_enabled; } +struct cpumask *cpu_coregroup_mask (int cpu) +{ + if (!has_coregroup_support()) + return cpu_l2_cache_mask(cpu); +> + return per_cpu(cpu_coregroup_map, cpu);
Interestingly, on powerpc, the MC domain doesn't have SD_SHARE_LLC flag set but I believe there is still some benefit of keeping the tasks on the same hemisphere?
If we are actually aiming for LLC, I think cpu_l2_cache_mask() is the right cpumask for all cases since tl_cache_mask() also returns that and the l2_cache_mask is set in all cases covered by update_mask_by_l2() in the same file.
If consolidation on hemisphere is beneficial, then the above diff looks correct.
Note: For has_coregroup_support(), with the above fix, the scheduler side llc_id will now be based on MC domain's span which seems wrong since it doesn't have SD_SHARE_LLC flag and might lead to other behavioral changes now.
Quoted 5 lines
arch/powerpc/kernel/smp.c +2
-0+} + static int __init init_big_cores(void) { int cpu;
Signature · 2 lines
Thanks and Regards, Prateek
Quoted 23 lines · K Prateek Nayak
Hello Chenyu, Venkat,
Quoted 20 lines · Yu C
arch/powerpc/kernel/smp.c +0
-5@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endif -struct cpumask *cpu_coregroup_mask (int cpu) -{ - return per_cpu(cpu_coregroup_map, cpu); -} - static bool has_coregroup_support(void) { /* Coregroup identification not available on shared systems */@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void) return coregroup_enabled; }
Quoted 10 lines
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1058
Quoted 5 lines
arch/powerpc/kernel/smp.c +5
-0+struct cpumask *cpu_coregroup_mask (int cpu) +{ + if (!has_coregroup_support()) + return cpu_l2_cache_mask(cpu); +> + return per_cpu(cpu_coregroup_map, cpu);Interestingly, on powerpc, the MC domain doesn't have
SD_SHARE_LLCflag set but I believe there is still some benefit of keeping the tasks on the same hemisphere?
You are right. I guess power9 reported here does not have hemisphere and power10 has, according to commit fb2ff9fa72e2:
"From Power10 processors onwards, each chip has 2 hemispheres" but yes on both power9 and power10, MC domain doesn't have SD_SHARE_LLC thus aggregating threads to 1 L2 domain might bring benefit. A side note is that, cache aware scheduling is disabled on power for now because power does not use the generic cacheinfo framework, thus its cache size is returned as 0 so get_effective_llc_bytes() returns 0(for now, unless we get the help from IBM friends to support it)
commit 7030513a0877 ("7030513a0877")
Quoted 5 lines
If we are actually aiming for LLC, I think
cpu_l2_cache_mask()is the right cpumask for all cases sincetl_cache_mask()also returns that and thel2_cache_maskis set in all cases covered byupdate_mask_by_l2()in the same file.
Quoted 8 lines
If consolidation on hemisphere is beneficial, then the above diff looks correct.
Note: For
has_coregroup_support(), with the above fix, the scheduler sidellc_idwill now be based on MC domain's span which seems wrong since it doesn't haveSD_SHARE_LLCflag and might lead to other behavioral changes now.
You are right, it seems to be a bug when has_coregroup_support() is enabled. Maybe we can always return l2 id for power?
How about this(revert previous diff):
arch/powerpc/include/asm/topology.h +3 -1
@@ -130,13 +130,15 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_SMP #include <asm/cputable.h> +#include <asm/smp.h> struct cpumask *cpu_coregroup_mask (int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu); +#define arch_llc_mask (cpu) cpu_l2_cache_mask(cpu) +#ifdef CONFIG_PPC64 -#include <asm/smp.h> #define topology_physical_package_id (cpu) (cpu_to_chip_id(cpu))#define topology_sibling_cpumask (cpu)
(per_cpu(cpu_sibling_map, cpu))
kernel/sched/topology.c +8 -2
@@ -2063,12 +2063,18 @@ const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpureturn cpu_coregroup_mask (cpu); } -#define llc_mask (cpu) cpu_coregroup_mask(cpu) +#ifndef arch_llc_mask +#define arch_llc_mask (cpu) cpu_coregroup_mask(cpu) +#endif #else -#define llc_mask (cpu) cpumask_of(cpu) +#ifndef arch_llc_mask +#define arch_llc_mask (cpu) cpumask_of(cpu) +#endif #endif +#define llc_mask (cpu) arch_llc_mask(cpu) + const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level
*tl, int cpu)
{
return cpu_node_mask(cpu);thanks,
Chenyu
Quoted 6 lines
Quoted 5 lines
arch/powerpc/kernel/smp.c +2
-0+} + static int __init init_big_cores(void) { int cpu;
Quoted 11 lines · Chen, Yu C
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
It seems that cpumask_first(llc_mask(i)) is accessing NULL
cpu_coregroup_mask():
Quoted 7 lines
has_coregroup_support()is false, thuscpu_coregroup_mapis never allocated insmp_prepare_cpus().
This machine is a "shared system" VM. We should probably let the LLC id generation fall back to using L2 id ifcpu_coregroup_maskis unavailable (which restores the behavior before this patch). I'm wondering if the following change would help(need IBM friends' help on this):
Power9 and below systems, dont have coregroup.
Its not because of shared LPAR. But its true for dedicated LPARs too. Only Power10 and above systems have hemisphere where we add MC/coregroup support.
Quoted 20 lines
arch/powerpc/kernel/smp.c +0
-5@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endif -struct cpumask *cpu_coregroup_mask (int cpu) -{ -return per_cpu (cpu_coregroup_map, cpu); -} -static bool has_coregroup_support (void ) {/* Coregroup identification not available on shared systems */arch/powerpc/kernel/smp.c +0
-0@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void)return coregroup_enabled;
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1061
Quoted 10 lines
arch/powerpc/kernel/smp.c +8
-0} +struct cpumask *cpu_coregroup_mask (int cpu) +{ +if (!has_coregroup_support ()) +return cpu_l2_cache_mask (cpu); + +return per_cpu (cpu_coregroup_map, cpu); +} +
While this is a work-around for the problem in Power9
It will hurt Power10 and Power11 systems.
As has been alluded by Prateek, MC is not LLC on Power.
So by using llc_mask as cpu_coregroup_mask() we run the trouble of assuming MC to be similar to LLC. So it will impact Power 10/11 Systems.
In commit b5ea300a17e3 sched/cache: Make LLC id continuous, we define #define llc_mask(cpu) cpu_coregroup_mask(cpu)
defining it llc_mask to cpu_coregroup_mask means MC should be LLC. This is not true for some architectures atleast on Power.
So shouldn't it be using
#define llc_mask(cpu) per_cpu(sd_llc, cpu)
This should work for systems where LLC is sub-coregroup, coregroup (or super
coregroup: Lets say some archs want LLC at PKG and cluster at coregroup).
if we do that, I dont think we even need the else case where we say #define llc_mask(cpu) cpumask_of(cpu)
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Hi Venkat,
Quoted 21 lines · Srikar Dronamraju
Quoted 11 lines · Chen, Yu C
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
It seems that cpumask_first(llc_mask(i)) is accessing NULL
cpu_coregroup_mask():Quoted 7 lines
has_coregroup_support()is false, thuscpu_coregroup_mapis never allocated insmp_prepare_cpus().
This machine is a "shared system" VM. We should probably let the LLC id generation fall back to using L2 id ifcpu_coregroup_maskis unavailable (which restores the behavior before this patch). I'm wondering if the following change would help(need IBM friends' help on this):
Quoted 5 lines
Power9 and below systems, dont have coregroup.
Its not because of shared LPAR. But its true for dedicated LPARs too. Only Power10 and above systems have hemisphere where we add MC/coregroup support.
OK, thanks for the correction. Are you saying coregroup_enabled is false on Power9 and older hardware, and set to true on Power10? Power10 has a corresponding device-tree property, which is parsed to enable hemisphere support in find_possible_nodes(). This is why has_coregroup_support() returns true for Power10.
Quoted 22 lines
Quoted 22 lines
arch/powerpc/kernel/smp.c +0
-5@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endif -struct cpumask *cpu_coregroup_mask (int cpu) -{ -return per_cpu (cpu_coregroup_map, cpu); -} -static bool has_coregroup_support (void ) {/* Coregroup identification not available on shared systems */arch/powerpc/kernel/smp.c +0
-0@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void)return coregroup_enabled; }
Quoted 12 lines
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1061
Quoted 8 lines
arch/powerpc/kernel/smp.c +8
-0+struct cpumask *cpu_coregroup_mask (int cpu) +{ +if (!has_coregroup_support ()) +return cpu_l2_cache_mask (cpu); + +return per_cpu (cpu_coregroup_map, cpu); +} +While this is a work-around for the problem in Power9 It will hurt Power10 and Power11 systems.
As has been alluded by Prateek, MC is not LLC on Power.
Could you please elaborate on the cache topology? Specifically, could you clarify what the LLC is for Power9 and Power10 respectively? Is it always the L2 cache?
I have checked the IBM documentation available at:
https://hc32.hotchips.org/assets/program/conference/day1/HotChips2020_Server_Processors_IBM_Starke_POWER10_v33.pdf
According to the document, a hemisphere corresponds to a 64MB L3 cache shared by 8 cores. Since the MC domain spans a single hemisphere, I wonder why the SD_SHARE_LLC flag is not enabled for the MC domain?
Quoted 9 lines
So by using
llc_maskascpu_coregroup_mask()we run the trouble of assuming MC to be similar to LLC. So it will impact Power 10/11 Systems.In commit
b5ea300a17e3sched/cache: Make LLC id continuous, we define #definellc_mask(cpu)cpu_coregroup_mask(cpu)defining it
llc_masktocpu_coregroup_maskmeans MC should be LLC. This is not true for some architectures atleast on Power.
OK.
Quoted 9 lines
So shouldn't it be using
#definellc_mask(cpu)per_cpu(sd_llc, cpu)This should work for systems where LLC is sub-coregroup, coregroup (or super
coregroup: Lets say some archs want LLC at PKG and cluster at coregroup).if we do that, I dont think we even need the else case where we say #define
llc_mask(cpu)cpumask_of(cpu)
I suppose you are referring tosched_domain_span(per_cpu(sd_llc, cpu)).
Indeed, deriving the LLC from the SD_SHARE_LLC level offers better scalability. However, this approach would involve scheduler domains, which can be truncated by cpuset partitions - a scenario we prefer to avoid.
thanks,
Chenyu
Hi Chen,
Quoted 17 lines
Quoted 11 lines
Quoted 10 lines
It seems that cpumask_first(llc_mask(i)) is accessing NULL
cpu_coregroup_mask():
has_coregroup_support()is false, thuscpu_coregroup_mapis never allocated insmp_prepare_cpus().
This machine is a "shared system" VM. We should probably let the LLC id generation fall back to using L2 id ifcpu_coregroup_maskis unavailable (which restores the behavior before this patch). I'm wondering if the following change would help(need IBM friends' help on this):Quoted 5 lines
Power9 and below systems, dont have coregroup.
Its not because of shared LPAR. But its true for dedicated LPARs too. Only Power10 and above systems have hemisphere where we add MC/coregroup support.
Quoted 6 lines
OK, thanks for the correction. Are you saying
coregroup_enabledis false on Power9 and older hardware, and set to true on Power10? Power10 has a corresponding device-tree property, which is parsed to enable hemisphere support infind_possible_nodes(). This is whyhas_coregroup_support()returns true for Power10.
Yes, Chen,coregroup_enabled is true only on Power 10 +
Yes we decipher coregroup from the device-tree properties.
Quoted 17 lines
Quoted 4 lines
Quoted 4 lines
arch/powerpc/kernel/smp.c +4
-0+struct cpumask *cpu_coregroup_mask (int cpu) +{ +if (!has_coregroup_support ()) +return cpu_l2_cache_mask (cpu);Quoted 8 lines
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1061
Quoted 4 lines
arch/powerpc/kernel/smp.c +4
-0+ +return per_cpu (cpu_coregroup_map, cpu); +} +While this is a work-around for the problem in Power9 It will hurt Power10 and Power11 systems.
As has been alluded by Prateek, MC is not LLC on Power.Could you please elaborate on the cache topology? Specifically, could you clarify what the LLC is for Power9 and Power10 respectively? Is it always the L2 cache?
Quoted 6 lines
I have checked the IBM documentation available at:
https://hc32.hotchips.org/assets/program/conference/day1/HotChips2020_Server_Processors_IBM_Starke_POWER10_v33.pdf
According to the document, a hemisphere corresponds to a 64MB L3 cache shared by 8 cores. Since the MC domain spans a single hemisphere, I wonder why theSD_SHARE_LLCflag is not enabled for the MC domain?
If we look at the presentation you pointed above, L2 is 2Mb per SMT8 Core. L3 is local 8MB per SMT8 core which together form a 64MB l3-buffer per hemisphere. L3 is a Victim cache and All L3 together form a L3.1 buffer.
In practice, we split the cache per small core aka SMT4 core. So we have 1Mb L2 per SMT4 core, 4Mb L3 per SMT4 Core. L3 is a Victim cache and All L3 combine to form L3.1 buffer. Hence for now we still consider L2 to be LLC.
On Power9, L2 is at CACHE domain
On all other Power Systems (P7,P8, P10, P11), L2 is at SMT domain. On Power, We haven taken L2 as LLC.
lscpu (on Power 10)
Architecture: ppc64le Byte Order: Little Endian CPU(s): 480 On-line CPU(s) list: 0-479 Thread(s) per core: 8 Core(s) per socket: 15 Socket(s): 4 NUMA node(s): 4 Model: 2.0 (pvr 0080 0200) Model name: POWER10, altivec supported CPU max MHz: 3249.0000 CPU min MHz: 3249.0000 L1d cache: 32K L1i cache: 48K L2 cache: 1024K L3 cache: 4096K NUMA node0 CPU(s): 0-119 NUMA node1 CPU(s): 120-239 NUMA node2 CPU(s): 240-359 NUMA node3 CPU(s): 360-479
L2 Cache reported here is for SMT4 Core.
lscpu (on Power 9)
Architecture: ppc64le Byte Order: Little Endian CPU(s): 128 On-line CPU(s) list: 0-127 Thread(s) per core: 8 Core(s) per socket: 8 Socket(s): 2 NUMA node(s): 2 Model: 2.2 (pvr 004e 0202) Model name: POWER9 (architected), altivec supported Hypervisor vendor: pHyp Virtualization type: para L1d cache: 32K L1i cache: 32K L2 cache: 512K L3 cache: 10240K NUMA node0 CPU(s): 0-63 NUMA node1 CPU(s): 64-127 Physical sockets: 2 Physical chips: 1 Physical cores/chip: 8
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Quoted 23 lines
Quoted 10 lines
So by using
llc_maskascpu_coregroup_mask()we run the trouble of assuming MC to be similar to LLC. So it will impact Power 10/11 Systems.In commit
b5ea300a17e3sched/cache: Make LLC id continuous, we define #definellc_mask(cpu)cpu_coregroup_mask(cpu)defining it
llc_masktocpu_coregroup_maskmeans MC should be LLC. This is not true for some architectures atleast on Power.OK.
Quoted 9 lines
So shouldn't it be using
#definellc_mask(cpu)per_cpu(sd_llc, cpu)This should work for systems where LLC is sub-coregroup, coregroup (or super
coregroup: Lets say some archs want LLC at PKG and cluster at coregroup).if we do that, I dont think we even need the else case where we say #define
llc_mask(cpu)cpumask_of(cpu)
Quoted 8 lines
I suppose you are referring to
sched_domain_span(per_cpu(sd_llc, cpu)).Indeed, deriving the LLC from the
SD_SHARE_LLClevel offers better scalability. However, this approach would involve scheduler domains, which can be truncated by cpuset partitions - a scenario we prefer to avoid.
Shouldnt cache-aware scheduling be worried about cpuset partitions too. If a cpuset has subset of LLC cores, then we should Scheduler assume it can control complete LLC?
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
K Prateek Nayak
reviewerHello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about cpu_coregroup_mask() except for drivers/base/arch_topology.c but Power doesn't select GENERIC_ARCH_TOPOLOGY.
Why can't Power have an internal mask for MC domain (tl_mc_mask) and the scheduler can use cpu_coregroup_mask() for the actual LLc? (The L2 mask in this case.)
Power anyways adds its own topology via set_sched_topology() so the default_topology from kernel/sched/topology.c remains unused.
...
Quoted 3 lines
Shouldnt cache-aware scheduling be worried about cpuset partitions too. If a cpuset has subset of LLC cores, then we should Scheduler assume it can control complete LLC?
Well, the scheduling takes care of partitions and the cache aware scheduling bits take care of looking at the full system perspective for stats aggregation and pointing to a particular LLc.
We don't compare llc_id across cpusets so we keeping one unique llc_id per H/W LLC instance is feasible and it enables us to keep llc_id space limited for optimizing cache-aware scheduling.
Now if we have threads of same process across partitions, we'll still aggregate the utilization numbers across the full LLC but the load balancers at individual partitions will make a call on the aggregation.
Signature · 2 lines
Thanks and Regards, Prateek
Re: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Hi Prateek,
Quoted 26 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)Power anyways adds its own topology via
set_sched_topology()so thedefault_topologyfromkernel/sched/topology.cremains unused....
Quoted 3 lines
Shouldnt cache-aware scheduling be worried about cpuset partitions too. If a cpuset has subset of LLC cores, then we should Scheduler assume it can control complete LLC?
Well, the scheduling takes care of partitions and the cache aware scheduling bits take care of looking at the full system perspective for stats aggregation and pointing to a particular LLc.
Quoted 14 lines
We don't compare
llc_idacross cpusets so we keeping one uniquellc_idper H/W LLC instance is feasible and it enables us to keepllc_idspace limited for optimizing cache-aware scheduling.Now if we have threads of same process across partitions, we'll still aggregate the utilization numbers across the full LLC but the load balancers at individual partitions will make a call on the aggregation.
Signature · 2 lines
Thanks and Regards, Prateek
I suppose what you suggested looks like below:
powerpc/smp: make cpu_coregroup_mask() return the LLC
On pSeries shared LPARs(or coregroup_enabled is false on Power9 and earlier) the hemisphere map is not allocated, so build_sched_domains() dereferences a NULL cpumask and crashes.
The generic scheduler expects cpu_coregroup_mask() to span the LLC. On powerpc the LLC is the L2. Return cpu_l2_cache_mask() instead of the hemisphere map. Use a coregroup_map() helper for the in-file hemisphere users, and a powerpc_tl_mc_mask() wrapper for the MC sched-domain level.
--- arch/powerpc/kernel/smp.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
arch/powerpc/kernel/smp.c +21 -10
@@ -1040,11 +1040,22 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ }#endif +static inline struct cpumask *coregroup_map (int cpu) +{ +return per_cpu (cpu_coregroup_map, cpu); +} +struct cpumask *cpu_coregroup_mask (int cpu) { -return per_cpu (cpu_coregroup_map, cpu); +return cpu_l2_cache_mask (cpu); +} + +static const struct cpumask * +powerpc_tl_mc_mask (struct sched_domain_topology_level *tl,int cpu) +{ +return coregroup_map (cpu); }static bool has_coregroup_support (void ) {if (is_shared_processor ())
@@ -1155,7 +1166,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)cpumask_set_cpu (boot_cpuid,cpu_core_mask (boot_cpuid));if (has_coregroup_support ()) -cpumask_set_cpu (boot_cpuid,cpu_coregroup_mask (boot_cpuid)); +cpumask_set_cpu (boot_cpuid,coregroup_map (boot_cpuid));init_big_cores ();if (has_big_cores) {
@@ -1520,8 +1531,8 @@ static void remove_cpu_from_masks(int cpu)set_cpus_unrelated (cpu, i, cpu_core_mask);if (has_coregroup_support ()) { -for_each_cpu (i,cpu_coregroup_mask (cpu)) -set_cpus_unrelated (cpu, i, cpu_coregroup_mask); +for_each_cpu (i,coregroup_map (cpu)) +set_cpus_unrelated (cpu, i, coregroup_map); } }#endif
@@ -1553,7 +1564,7 @@ static void update_coregroup_mask(int cpu, cpumask_var_t *mask)if (!*mask) {/* Assume only siblings are part of this CPU's coregroup */ for_each_cpu (i,submask_fn (cpu)) -set_cpus_related (cpu, i, cpu_coregroup_mask); +set_cpus_related (cpu, i, coregroup_map);return ; }
@@ -1561,18 +1572,18 @@ static void update_coregroup_mask(int cpu, cpumask_var_t *mask)cpumask_and (*mask, cpu_online_mask,cpu_node_mask (cpu));/* Update coregroup mask with all the CPUs that are part of submask */ -or_cpumasks_related (cpu, cpu, submask_fn, cpu_coregroup_mask); +or_cpumasks_related (cpu, cpu, submask_fn, coregroup_map);/* Skip all CPUs already part of coregroup mask */ -cpumask_andnot (*mask, *mask,cpu_coregroup_mask (cpu)); +cpumask_andnot (*mask, *mask,coregroup_map (cpu));for_each_cpu (i, *mask) {/* Skip all CPUs not part of this coregroup */ if (coregroup_id ==cpu_to_coregroup_id (i)) { -or_cpumasks_related (cpu, i, submask_fn, cpu_coregroup_mask); +or_cpumasks_related (cpu, i, submask_fn, coregroup_map);cpumask_andnot (*mask, *mask,submask_fn (i)); }else { -cpumask_andnot (*mask, *mask,cpu_coregroup_mask (i)); +cpumask_andnot (*mask, *mask,coregroup_map (i)); } } }
@@ -1733,7 +1744,7 @@ static void __init build_sched_topology(void)if (has_coregroup_support ()) { powerpc_topology[i++] = -SDTL_INIT (tl_mc_mask, powerpc_shared_proc_flags,MC ); +SDTL_INIT (powerpc_tl_mc_mask, powerpc_shared_proc_flags,MC ); } powerpc_topology[i++] =SDTL_INIT (tl_pkg_mask, powerpc_shared_proc_flags,PKG );
Signature · 4 lines
2.43.0 Thanks, Yu
Shrikanth Hegde
reviewerRe: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Hi Chen, Prateek.
I got back to work today, sorry for delay.
I am trying to go through the mails.
Apologies in case i have missed any bits.
Quoted 15 lines · Chen Yu
Hi Prateek,
Quoted 12 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)
This seems wrong. there is no notion that coregroup_mask (MC domain) has to point at LLC domain.
For example, on Shared LPAR, there is no MC domain and LLC is at SMT core level. In that case coregroup_mask has point at SMT mask is wrong.
If we need a mask to point to the LLC mask which arch has to return, then we would need a new api say cpu_llc_mask ? that can point accordingly.
I don't like mixing MC domain and LLC into one bit.
Quoted 57 lines
Quoted 14 lines
Power anyways adds its own topology via
set_sched_topology()so thedefault_topologyfromkernel/sched/topology.cremains unused....
Quoted 3 lines
Shouldnt cache-aware scheduling be worried about cpuset partitions too. If a cpuset has subset of LLC cores, then we should Scheduler assume it can control complete LLC?
Well, the scheduling takes care of partitions and the cache aware scheduling bits take care of looking at the full system perspective for stats aggregation and pointing to a particular LLc.
Quoted 14 lines
We don't compare
llc_idacross cpusets so we keeping one uniquellc_idper H/W LLC instance is feasible and it enables us to keepllc_idspace limited for optimizing cache-aware scheduling.Now if we have threads of same process across partitions, we'll still aggregate the utilization numbers across the full LLC but the load balancers at individual partitions will make a call on the aggregation.
Signature · 2 lines
Thanks and Regards, PrateekI suppose what you suggested looks like below:
powerpc/smp: make
cpu_coregroup_mask()return the LLCOn pSeries shared
LPARs(or coregroup_enabled is false on Power9 and earlier)the hemisphere map is not allocated, sobuild_sched_domains()dereferences a NULL cpumask and crashes.The generic scheduler expects
cpu_coregroup_mask()to span the LLC. On powerpc the LLC is the L2. Returncpu_l2_cache_mask()instead of the hemisphere map. Use acoregroup_map()helper for the in-file hemisphere users, and apowerpc_tl_mc_mask()wrapper for the MC sched-domain level.Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Suggested-by K Prateek Nayak <[email protected]>--- arch/powerpc/kernel/smp.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)arch/powerpc/kernel/smp.c +0
-0@@ -1040,11 +1040,22 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ }#endif
arch/powerpc/kernel/smp.c static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ · line 1051
Quoted 10 lines
arch/powerpc/kernel/smp.c +7
-1+static inline struct cpumask *coregroup_map (int cpu) +{ +return per_cpu (cpu_coregroup_map, cpu); +} +struct cpumask *cpu_coregroup_mask (int cpu) { -return per_cpu (cpu_coregroup_map, cpu); +return cpu_l2_cache_mask (cpu); +}
This looks wrong to me too. In different hardware topologies there maybe distinction between coregroup and l2 mask.
Let me go through the code and see if there is better way.
Quoted 63 lines
arch/powerpc/kernel/smp.c +13
-8+ +static const struct cpumask * +powerpc_tl_mc_mask (struct sched_domain_topology_level *tl,int cpu) +{ +return coregroup_map (cpu); }static bool has_coregroup_support (void ) {if (is_shared_processor ())@@ -1155,7 +1166,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)cpumask_set_cpu (boot_cpuid,cpu_core_mask (boot_cpuid));if (has_coregroup_support ()) -cpumask_set_cpu (boot_cpuid,cpu_coregroup_mask (boot_cpuid)); +cpumask_set_cpu (boot_cpuid,coregroup_map (boot_cpuid));init_big_cores ();if (has_big_cores) {@@ -1520,8 +1531,8 @@ static void remove_cpu_from_masks(int cpu)set_cpus_unrelated (cpu, i, cpu_core_mask);if (has_coregroup_support ()) { -for_each_cpu (i,cpu_coregroup_mask (cpu)) -set_cpus_unrelated (cpu, i, cpu_coregroup_mask); +for_each_cpu (i,coregroup_map (cpu)) +set_cpus_unrelated (cpu, i, coregroup_map); } }#endif @@ -1553,7 +1564,7 @@ static void update_coregroup_mask(int cpu, cpumask_var_t *mask)if (!*mask) {/* Assume only siblings are part of this CPU's coregroup */ for_each_cpu (i,submask_fn (cpu)) -set_cpus_related (cpu, i, cpu_coregroup_mask); +set_cpus_related (cpu, i, coregroup_map);return ; }@@ -1561,18 +1572,18 @@ static void update_coregroup_mask(int cpu, cpumask_var_t *mask)cpumask_and (*mask, cpu_online_mask,cpu_node_mask (cpu));/* Update coregroup mask with all the CPUs that are part of submask */ -or_cpumasks_related (cpu, cpu, submask_fn, cpu_coregroup_mask); +or_cpumasks_related (cpu, cpu, submask_fn, coregroup_map);/* Skip all CPUs already part of coregroup mask */ -cpumask_andnot (*mask, *mask,cpu_coregroup_mask (cpu)); +cpumask_andnot (*mask, *mask,coregroup_map (cpu));for_each_cpu (i, *mask) {/* Skip all CPUs not part of this coregroup */ if (coregroup_id ==cpu_to_coregroup_id (i)) { -or_cpumasks_related (cpu, i, submask_fn, cpu_coregroup_mask); +or_cpumasks_related (cpu, i, submask_fn, coregroup_map);cpumask_andnot (*mask, *mask,submask_fn (i)); }else { -cpumask_andnot (*mask, *mask,cpu_coregroup_mask (i)); +cpumask_andnot (*mask, *mask,coregroup_map (i)); } } }
arch/powerpc/kernel/smp.c static void __init build_sched_topology(void) · line 1736
Quoted 4 lines
arch/powerpc/kernel/smp.c +0
-1@@ -1733,7 +1744,7 @@ static void __init build_sched_topology(void)if (has_coregroup_support ()) { powerpc_topology[i++] = -SDTL_INIT (tl_mc_mask, powerpc_shared_proc_flags,MC );
I would prefer not do this rename. having tl_mc_mask helps to find the usage across the codebase.
Quoted 4 lines
arch/powerpc/kernel/smp.c +1
-0+SDTL_INIT (powerpc_tl_mc_mask, powerpc_shared_proc_flags,MC ); } powerpc_topology[i++] =SDTL_INIT (tl_pkg_mask, powerpc_shared_proc_flags,PKG );
Re: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Hi Shrikanth,
Quoted 6 lines · Shrikanth Hegde
Hi Chen, Prateek.
I got back to work today, sorry for delay.
I am trying to go through the mails.
Apologies in case i have missed any bits.
Thanks for taking a look at this!
Quoted 17 lines · Chen Yu
Quoted 15 lines
Hi Prateek,
Quoted 12 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)
Quoted 6 lines
This seems wrong. there is no notion that
coregroup_mask(MC domain) has to point at LLC domain.For example, on Shared LPAR, there is no MC domain and LLC is at SMT core level. In that case
coregroup_maskhas point at SMT mask is wrong.
On Shared LPAR, highest_flag_domain(SD_SHARE_LLC) selected the SMT domain(L2 shared)prior to commit b5ea300a17e3. Prateek suggested changing cpu_coregroup_mask() to use cpu_l2_cache_mask(), which makes the LLC mask cover the same range. sd_llc, size and grouping remain unchanged. Only sd_llc_id becomes contiguous, which aligns with the intent of this commit.
But yes, the naming is confusing. cpu_coregroup_mask suggests a "group of cores", but after the change, it only covers threads within a single SMT core.
Quoted 3 lines
If we need a mask to point to the LLC mask which arch has to return, then we would need a new api say
cpu_llc_mask? that can point accordingly.
Do you mean something like this?
https://lore.kernel.org/lkml/[email protected]/
Quoted 2 lines
I don't like mixing MC domain and LLC into one bit.
[ ... ]
Quoted 11 lines
Quoted 5 lines
struct cpumask *cpu_coregroup_mask(int cpu)
{
- returnper_cpu(cpu_coregroup_map, cpu);
+ returncpu_l2_cache_mask(cpu);
+}This looks wrong to me too. In different hardware topologies there maybe distinction between coregroup and l2 mask.
Let me go through the code and see if there is better way.
Sure, please go ahead - I'm on board with the direction you settle on.
thanks,
Chenyu
Shrikanth Hegde
reviewerRe: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Hi Chen, Prateek.
Quoted 43 lines · Yu C
Hi Shrikanth,
Quoted 6 lines · Shrikanth Hegde
Hi Chen, Prateek.
I got back to work today, sorry for delay.
I am trying to go through the mails.
Apologies in case i have missed any bits.Thanks for taking a look at this!
Quoted 17 lines · Chen Yu
Quoted 15 lines
Hi Prateek,
Quoted 12 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)Quoted 6 lines
This seems wrong. there is no notion that
coregroup_mask(MC domain) has to point at LLC domain.For example, on Shared LPAR, there is no MC domain and LLC is at SMT core level. In that case
coregroup_maskhas point at SMT mask is wrong.On Shared LPAR,
highest_flag_domain(SD_SHARE_LLC)selected the SMT domain(L2 shared)prior to commitb5ea300a17e3. Prateek suggested changingcpu_coregroup_mask()to usecpu_l2_cache_mask(), which makes the LLC mask cover the same range.sd_llc, size and grouping remain unchanged. Onlysd_llc_idbecomes contiguous, which aligns with the intent of this commit.
Quoted 4 lines
But yes, the naming is confusing.
cpu_coregroup_masksuggests a "group of cores", but after the change, it only covers threads within a single SMT core.
Yes. Though it might achieve the same effect, keeping it explicit may help in maintaining it better.
On PowerPC, there are these subtleties of Shared LPAR where MC domain
per se doesn't exit etc, and on power9 and earlier has different topologies. Maybe one could figure it all out and simplifies them into a few masks. But yes, it is slightly different as of today.
Quoted 6 lines
Quoted 3 lines
If we need a mask to point to the LLC mask which arch has to return, then we would need a new api say
cpu_llc_mask? that can point accordingly.Do you mean something like this?
https://lore.kernel.org/lkml/8d14c844-b4a8-4af6- [email protected]/
Yes. This is something i prefer, but not to make it point to l2 mask always. See below diff which now make it boot on Shared Processor LPAR where i see panic without it.
Need to add proper comments where appropriate.
arch/powerpc/include/asm/topology.h +3 -0
@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask +struct cpumask *cpu_coregroup_mask (int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu);
arch/powerpc/kernel/smp.c +7 -0
@@ -1101,6 +1101,13 @@ const struct cpumask *cpu_die_mask(int cpu) }EXPORT_SYMBOL_GPL (cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ +if (has_coregroup_support ()) +return cpu_coregroup_mask (cpu); +return cpu_smallcore_mask (cpu); +} +int cpu_die_id (int cpu) {if (has_coregroup_support ())
kernel/sched/topology.c +4 -0
@@ -2063,7 +2063,11 @@ const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu return cpu_coregroup_mask(cpu); } +#ifndef arch_llc_mask#define llc_mask (cpu) cpu_coregroup_mask(cpu) +#else +#define llc_mask (cpu) arch_llc_mask(cpu) +#endif #else #define llc_mask (cpu) cpumask_of(cpu)
(One more subtlety; crash would be seen only with NR_CPUS=8192 as CPUMASK_OFFSTACK=y, but that's a different concern altogether.)
Quoted 24 lines
Quoted 3 lines
I don't like mixing MC domain and LLC into one bit.
[ ... ]
Quoted 11 lines
Quoted 5 lines
struct cpumask *cpu_coregroup_mask(int cpu)
{
- returnper_cpu(cpu_coregroup_map, cpu);
+ returncpu_l2_cache_mask(cpu);
+}This looks wrong to me too. In different hardware topologies there maybe distinction between coregroup and l2 mask.
Let me go through the code and see if there is better way.
Sure, please go ahead - I'm on board with the direction you settle on.
thanks,
Chenyu
Shrikanth Hegde
reviewerRe: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Quoted 89 lines · Shrikanth Hegde
Hi Chen, Prateek.
Quoted 43 lines · Yu C
Hi Shrikanth,
Quoted 6 lines · Shrikanth Hegde
Hi Chen, Prateek.
I got back to work today, sorry for delay.
I am trying to go through the mails.
Apologies in case i have missed any bits.Thanks for taking a look at this!
Quoted 17 lines · Chen Yu
Quoted 15 lines
Hi Prateek,
Quoted 12 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)Quoted 6 lines
This seems wrong. there is no notion that
coregroup_mask(MC domain) has to point at LLC domain.For example, on Shared LPAR, there is no MC domain and LLC is at SMT core level. In that case
coregroup_maskhas point at SMT mask is wrong.On Shared LPAR,
highest_flag_domain(SD_SHARE_LLC)selected the SMT domain(L2 shared)prior to commitb5ea300a17e3. Prateek suggested changingcpu_coregroup_mask()to usecpu_l2_cache_mask(), which makes the LLC mask cover the same range.sd_llc, size and grouping remain unchanged. Onlysd_llc_idbecomes contiguous, which aligns with the intent of this commit.Quoted 4 lines
But yes, the naming is confusing.
cpu_coregroup_masksuggests a "group of cores", but after the change, it only covers threads within a single SMT core.Yes. Though it might achieve the same effect, keeping it explicit may help in maintaining it better.
On PowerPC, there are these subtleties of Shared LPAR where MC domain
per se doesn't exit etc, and on power9 and earlier has different topologies. Maybe one could figure it all out and simplifies them into a few masks. But yes, it is slightly different as of today.Quoted 6 lines
Quoted 3 lines
If we need a mask to point to the LLC mask which arch has to return, then we would need a new api say
cpu_llc_mask? that can point accordingly.Do you mean something like this?
https://lore.kernel.org/lkml/8d14c844-b4a8-4af6- [email protected]/Yes. This is something i prefer, but not to make it point to l2 mask always. See below diff which now make it boot on Shared Processor LPAR where i see panic without it.
Need to add proper comments where appropriate.
arch/powerpc/include/asm/topology.h +3
-0@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu) #ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask + struct cpumask *cpu_coregroup_mask(int cpu); const struct cpumask *cpu_die_mask(int cpu); int cpu_die_id(int cpu);arch/powerpc/kernel/smp.c +0
-0
arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1108
Quoted 8 lines
arch/powerpc/kernel/smp.c +5
-0@@ -1101,6 +1101,13 @@ const struct cpumask *cpu_die_mask(int cpu) } EXPORT_SYMBOL_GPL(cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ + if (has_coregroup_support()) + return cpu_coregroup_mask(cpu); + return cpu_smallcore_mask(cpu);
This function body needs change, since LLC is not at MC. and I didn't account for power9.
Rest of the structure is what i would prefer the direction to go. This will help future architectures too to account for their specific needs.
What do you think?
Quoted 51 lines
arch/powerpc/kernel/smp.c +2
-0+} + int cpu_die_id(int cpu) { if (has_coregroup_support())kernel/sched/topology.c +0
-0@@ -2063,7 +2063,11 @@ const struct cpumask *tl_mc_mask(struct
sched_domain_topology_level*tl, int cpu
returncpu_coregroup_mask(cpu);
}kernel/sched/topology.c +4
-0+#ifndef arch_llc_mask #define llc_mask(cpu) cpu_coregroup_mask(cpu) +#else +#define llc_mask (cpu) arch_llc_mask(cpu) +#endif #else #define llc_mask(cpu) cpumask_of(cpu)(One more subtlety; crash would be seen only with NR_CPUS=8192 as CPUMASK_OFFSTACK=y, but that's a different concern altogether.)
Quoted 24 lines
Quoted 3 lines
I don't like mixing MC domain and LLC into one bit.
[ ... ]
Quoted 11 lines
Quoted 5 lines
struct cpumask *cpu_coregroup_mask(int cpu)
{
- returnper_cpu(cpu_coregroup_map, cpu);
+ returncpu_l2_cache_mask(cpu);
+}This looks wrong to me too. In different hardware topologies there maybe distinction between coregroup and l2 mask.
Let me go through the code and see if there is better way.
Sure, please go ahead - I'm on board with the direction you settle on.
thanks,
Chenyu
Re: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Quoted 3 lines · Shrikanth Hegde
On 5/27/26 11:37 PM, Shrikanth Hegde wrote:
[ ... ]
Quoted 32 lines
Quoted 19 lines
arch/powerpc/include/asm/topology.h +3
-0@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu) #ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask + struct cpumask *cpu_coregroup_mask(int cpu); const struct cpumask *cpu_die_mask(int cpu); int cpu_die_id(int cpu);arch/powerpc/kernel/smp.c +0
-0arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1108
Quoted 8 lines
arch/powerpc/kernel/smp.c +5
-0@@ -1101,6 +1101,13 @@ const struct cpumask *cpu_die_mask(int cpu) } EXPORT_SYMBOL_GPL(cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ + if (has_coregroup_support()) + return cpu_coregroup_mask(cpu); + return cpu_smallcore_mask(cpu);This function body needs change, since LLC is not at MC. and I didn't account for power9.
Quoted 6 lines
Rest of the structure is what i would prefer the direction to go. This will help future architectures too to account for their specific needs.
What do you think?
Yes this direction look good to me. Regarding the arch_llc_mask(), how about the following per Srikar's description
const struct cpumask *arch_llc_mask(int cpu)
{
/* Power9, CACHE domain is the LLC*/ if (shared_caches)
return cpu_l2_cache_mask(cpu);
/* P7, P8, P10, P11, SMT domain is the LLC*/ return cpu_smt_mask(cpu);
}thanks,
Chenyu
Shrikanth Hegde
reviewerRe: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
Hi Chenyu.
Quoted 8 lines
Yes this direction look good to me. Regarding the
arch_llc_mask(), how about the following per Srikar's descriptionconst struct cpumask *arch_llc_mask(int cpu)
{
/* Power9, CACHE domain is the LLC*/ if (shared_caches) returncpu_l2_cache_mask(cpu);
Quoted 7 lines
/* P7, P8, P10, P11, SMT domain is the LLC*/ return
cpu_smt_mask(cpu);
}thanks,
Chenyu
Yes. this is what i was thinking too. I have the patch, let me send it across shortly. It is fixing the boot panic for me in SPLPAR. Hopefully it should work for others too.
I will send it as reply to main thread so one doesn't miss it out.
Re: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
In reply to Chen, Yu CQuoted 50 lines · Chen, Yu C
Quoted 3 lines · Shrikanth Hegde
On 5/27/26 11:37 PM, Shrikanth Hegde wrote:
[ ... ]
Quoted 33 lines
Quoted 20 lines
arch/powerpc/ renamed from arch/powerpc/include/asm/topology.h +0
-0
include/asm/topology.h
index66ed5fe1b718..bd1db3b1dbb0100644arch/powerpc/include/asm/topology.h +3
-0@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu) #ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask + struct cpumask *cpu_coregroup_mask(int cpu); const struct cpumask *cpu_die_mask(int cpu); int cpu_die_id(int cpu);arch/powerpc/kernel/smp.c +0
-0arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1108
Quoted 8 lines
arch/powerpc/kernel/smp.c +5
-0@@ -1101,6 +1101,13 @@ const struct cpumask *cpu_die_mask(int cpu) } EXPORT_SYMBOL_GPL(cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ + if (has_coregroup_support()) + return cpu_coregroup_mask(cpu); + return cpu_smallcore_mask(cpu);This function body needs change, since LLC is not at MC. and I didn't account for power9.
Quoted 6 lines
Rest of the structure is what i would prefer the direction to go. This will help future architectures too to account for their specific needs.
What do you think?
Yes this direction look good to me. Regarding the
arch_llc_mask(), how about the following per Srikar's description
Quoted 6 lines
const struct cpumask *arch_llc_mask(int cpu)
{ /* Power9, CACHE domain is the LLC*/ if (shared_caches) return cpu_l2_cache_mask(cpu); /* P7, P8, P10, P11, SMT domain is the LLC*/ return cpu_smt_mask(cpu);
On P7, P8, P10, P11, cpu_l2_cache_mask should be same as cpu_smt_mask so I dont see a point of checking if(shared caches)
We can as well return
#define arch_llc_mask cpu_l2_cache_mask
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Re: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
In reply to Shrikanth Hegdearch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1110
Quoted 11 lines · Shrikanth Hegde
Hi Chen, Prateek.
EXPORT_SYMBOL_GPL(cpu_die_mask);arch/powerpc/kernel/smp.c +7
-0+const struct cpumask *arch_llc_mask (int cpu) +{ +if (has_coregroup_support ()) +return cpu_coregroup_mask (cpu); +return cpu_smallcore_mask (cpu); +} +
This is not correct. why should we again send coregroup for llc.
Quoted 12 lines
int
cpu_die_id(int cpu)
{
if (has_coregroup_support())kernel/sched/topology.c +0
-0@@ -2063,7 +2063,11 @@ const struct cpumask *tl_mc_mask(struct
sched_domain_topology_level*tl, int cpureturn cpu_coregroup_mask(cpu);}
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
K Prateek Nayak
reviewerRe: [BUG] sched/cache: "Make LLC id continuous" causes NULL cpumask
In reply to Shrikanth HegdeHello Shrikanth,
Quoted 19 lines · Shrikanth Hegde
Hi Chen, Prateek.
I got back to work today, sorry for delay.
I am trying to go through the mails.
Apologies in case i have missed any bits.Quoted 12 lines · Chen Yu
Hi Prateek,
Quoted 9 lines · K Prateek Nayak
Hello Srikar,
Quoted 1 line · Srikar Dronamraju
L2 Cache reported here is for SMT8 Core aka CACHE domain.
Apart for the scheduler, nothing in tree currently cares about
cpu_coregroup_mask()except fordrivers/base/arch_topology.cbut Power doesn't selectGENERIC_ARCH_TOPOLOGY.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Why can't Power have an internal mask for MC domain (
tl_mc_mask) and the scheduler can usecpu_coregroup_mask()for the actual LLc? (The L2 mask in this case.)This seems wrong. there is no notion that
coregroup_mask(MC domain) has to point at LLC domain.
It seems that only PowerPC is special at that. Only 3 architectures override the default topology via set_sched_topology() - x86, and s390 both still have SD_SHARE_LLC set for their MC domain, as is the case with default_topology[] in topology.c with cpu_core_flags().
Quoted 2 lines
For example, on Shared LPAR, there is no MC domain and LLC is at SMT core level. In that case
coregroup_maskhas point at SMT mask is wrong.
That is equivalent of MC degenerating onto the core domain right? cpu_coregroup_mask() pointing to a core shouldn't be problematic in that case.
Quoted 4 lines
If we need a mask to point to the LLC mask which arch has to return, then we would need a new api say
cpu_llc_mask? that can point accordingly.I don't like mixing MC domain and LLC into one bit.
The SCHED_CACHE bits assume cpu_coregroup_mask() points to the sd_llc domain and uses the sched_cpu_activate() path to assign the llc_id independent of partitions and sched domain bits.
That assumption holds true for everything except powerpc. Is there anything aside from the scheduler bits that use the cpu_coregroup_mask()? We can always keep a big fat comment on top that reads it points to the sd_llc domain and it may not be the MC domain on power.
Quoted 1 line
Quoted 1 line
I suppose what you suggested looks like below:
Hello Chenyu! Yes, this was pretty much what I had in mind! Thank you for the patch.
Quoted 40 lines
Quoted 26 lines
powerpc/smp: make
cpu_coregroup_mask()return the LLCOn pSeries shared
LPARs(or coregroup_enabled is false on Power9 and earlier)the hemisphere map is not allocated, sobuild_sched_domains()dereferences a NULL cpumask and crashes.The generic scheduler expects
cpu_coregroup_mask()to span the LLC. On powerpc the LLC is the L2. Returncpu_l2_cache_mask()instead of the hemisphere map. Use acoregroup_map()helper for the in-file hemisphere users, and apowerpc_tl_mc_mask()wrapper for the MC sched-domain level.Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Suggested-by K Prateek Nayak <[email protected]>---
arch/powerpc/kernel/smp.c| 35 +++++++++++++++++++++++------------1 file changed, 23 insertions(+), 12 deletions(-)arch/powerpc/kernel/smp.c +0
-0@@ -1040,11 +1040,22 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endifarch/powerpc/kernel/smp.c static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ · line 1050
Quoted 10 lines
arch/powerpc/kernel/smp.c +6
-1+static inline struct cpumask *coregroup_map(int cpu) +{ + return per_cpu(cpu_coregroup_map, cpu); +} + struct cpumask *cpu_coregroup_mask(int cpu) { - return per_cpu(cpu_coregroup_map, cpu); + return cpu_l2_cache_mask(cpu); +}This looks wrong to me too. In different hardware topologies there maybe distinction between coregroup and l2 mask.
Quoted 1 line
Let me go through the code and see if there is better way.
The other option was to add an arch_llc_mask macro that can be optionally defined on the arch/ side if the cpu_coregroup_mask() doesn't point to the LLC
https://lore.kernel.org/lkml/[email protected]/
Signature · 2 lines
Thanks and Regards, Prateek
Quoted 12 lines · Yu C
Hi Venkat,
Quoted 9 lines · Srikar Dronamraju
Quoted 7 lines · Chen, Yu C
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
This issue is seen on P11 as well.
[ 0.006697] smp: Brought up 1 node, 16 CPUs
[ 0.006702] Big cores detected but using small core scheduling
[ 0.006752] BUG: Kernel NULL pointer dereference on read at 0x00000000
[ 0.006755] Faulting instruction address: 0xc000000020adbb6c
[ 0.006759] Oops: Kernel access of bad area, sig: 7 [#1]
[ 0.006762] LE PAGE_SIZE=4K MMU=Radix SMP NR_CPUS=8192 NUMA pSeries
[ 0.006767] Modules linked in:
[ 0.006772] CPU: 4 UID: 0 PID: 1 Comm: swapper/4 Not tainted 7.1.0-rc5-next-20260525 #1 PREEMPT(lazy)
[ 0.006777] Hardware name: IBM,9080-HEX Power11 (architected) 0x820200 0xf000007 of:IBM,FW1110.01 (NH1110_069) hv:phyp pSeries
[ 0.006781] NIP: c000000020adbb6c LR: c0000000202e5a58 CTR: 0000000000000000
[ 0.006784] REGS: c0000000283d7890 TRAP: 0300 Not tainted (7.1.0-rc5-next-20260525)
[ 0.006788] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002242 XER: 20040003
[ 0.006796] CFAR: c0000000202e5a54 DAR: 0000000000000000 DSISR: 00080000 IRQMASK: 0
[ 0.006796] GPR00: 0000000000000000 c0000000283d7b50 c000000021abf100 0000000000000010
[ 0.006796] GPR04: 0000000000000010 0000000000000030 0000000000000000 c000000028365500
[ 0.006796] GPR08: 0000000000000000 c000000022213598 000000003b77d000 0000000000000000
[ 0.006796] GPR12: c00000002005d8f0 c000000000008000 c0000000283cb578 c0000000283cb400
[ 0.006796] GPR16: c0000000283c9000 c000000022218b20 c0000000222330e8 00000000ffffffff
[ 0.006796] GPR20: fffffffffffffff6 0000000000000000 c000000022da36e0 0000000000000000
[ 0.006796] GPR24: 0000000000000000 0000000000000000 c0000000283c9178 c0000000227b5f00
[ 0.006796] GPR28: c00000002831c1e8 c000000022db5980 0000000000000000 0000000000000000
[ 0.006835] NIP [c000000020adbb6c] _find_first_bit+0xc/0xc0
[ 0.006842] LR [c0000000202e5a58] build_sched_domains+0x7d8/0xb40
[ 0.006847] Call Trace:
[ 0.006849] [c0000000283d7b50] [c0000000202e5408] build_sched_domains+0x188/0xb40 (unreliable)
[ 0.006854] [c0000000283d7c90] [c000000022034380] sched_init_domains+0x118/0x168
[ 0.006860] [c0000000283d7ce0] [c000000022032b14] sched_init_smp+0xa8/0x158
[ 0.006865] [c0000000283d7d30] [c000000022005674] kernel_init_freeable+0x1ac/0x294
[ 0.006870] [c0000000283d7dd0] [c000000020011718] kernel_init+0x2c/0x1c4
[ 0.006874] [c0000000283d7e30] [c00000002000debc] ret_from_kernel_user_thread+0x14/0x1c
[ 0.006878] ---- interrupt: 0 at 0x0
[ 0.006881] Code: eb610038 7fc3f378 eb810040 eba10048 38210060 ebc1fff0 ebe1fff8 7c0803a6 4e800020 7c681b78 7c832379 4d820020 <e9280000> 38e3ffff 39400000 78e7d7e2 [ 0.006895] ---[ end trace 0000000000000000 ]---
[ 0.006898]
Regards,
Venkat.
Quoted 104 lines
Quoted 12 lines
Quoted 11 lines
It seems that cpumask_first(llc_mask(i)) is accessing NULL
cpu_coregroup_mask():
has_coregroup_support()is false, thuscpu_coregroup_mapis never allocated insmp_prepare_cpus().
This machine is a "shared system" VM. We should probably let the LLC id generation fall back to using L2 id ifcpu_coregroup_maskis unavailable (which restores the behavior before this patch). I'm wondering if the following change would help(need IBM friends' help on this):Quoted 5 lines
Power9 and below systems, dont have coregroup.
Its not because of shared LPAR. But its true for dedicated LPARs too. Only Power10 and above systems have hemisphere where we add MC/coregroup support.OK, thanks for the correction. Are you saying
coregroup_enabledis false on Power9 and older hardware, and set to true on Power10? Power10 has a corresponding device-tree property, which is parsed to enable hemisphere support infind_possible_nodes(). This is whyhas_coregroup_support()returns true for Power10.Quoted 22 lines
Quoted 22 lines
arch/powerpc/kernel/smp.c +0
-5@@ -1042,11 +1042,6 @@ static const struct cpumask *tl_smallcore_smt_mask(struct sched_domain_topology_ } #endif -struct cpumask *cpu_coregroup_mask(int cpu) -{ - return per_cpu(cpu_coregroup_map, cpu); -} - static bool has_coregroup_support(void) {/* Coregroup identification not available on shared systems */
arch/powerpc/kernel/smp.c +0
-0@@ -1056,6 +1051,14 @@ static bool has_coregroup_support(void) return coregroup_enabled; }Quoted 12 lines
arch/powerpc/kernel/smp.c static bool has_coregroup_support(void) · line 1061
Quoted 8 lines
arch/powerpc/kernel/smp.c +8
-0+struct cpumask *cpu_coregroup_mask (int cpu) +{ + if (!has_coregroup_support()) + return cpu_l2_cache_mask(cpu); + + return per_cpu(cpu_coregroup_map, cpu); +} +While this is a work-around for the problem in Power9 It will hurt Power10 and Power11 systems.
As has been alluded by Prateek, MC is not LLC on Power.Could you please elaborate on the cache topology? Specifically, could you clarify what the LLC is for Power9 and Power10 respectively? Is it always the L2 cache?
I have checked the IBM documentation available at:
https://hc32.hotchips.org/assets/program/conference/day1/HotChips2020_Server_Processors_IBM_Starke_POWER10_v33.pdfAccording to the document, a hemisphere corresponds to a 64MB L3 cache shared by 8 cores. Since the MC domain spans a single hemisphere, I wonder why the
SD_SHARE_LLCflag is not enabled for the MC domain?Quoted 9 lines
So by using
llc_maskascpu_coregroup_mask()we run the trouble of assuming MC to be similar to LLC. So it will impact Power 10/11 Systems.In commit
b5ea300a17e3sched/cache: Make LLC id continuous, we define #definellc_mask(cpu)cpu_coregroup_mask(cpu)defining it
llc_masktocpu_coregroup_maskmeans MC should be LLC. This is not true for some architectures atleast on Power.OK.
Quoted 9 lines
So shouldn't it be using
#definellc_mask(cpu)per_cpu(sd_llc, cpu)This should work for systems where LLC is sub-coregroup, coregroup (or super
coregroup: Lets say some archs want LLC at PKG and cluster at coregroup).if we do that, I dont think we even need the else case where we say #define
llc_mask(cpu)cpumask_of(cpu)I suppose you are referring to
sched_domain_span(per_cpu(sd_llc, cpu)).Indeed, deriving the LLC from the
SD_SHARE_LLClevel offers better scalability. However, this approach would involve scheduler domains, which can be truncated by cpuset partitions - a scenario we prefer to avoid.thanks,
Chenyu
Shrikanth Hegde
reviewerQuoted 54 lines · Venkat Rao Bagalkote
Quoted 12 lines · Yu C
Hi Venkat,
Quoted 9 lines · Srikar Dronamraju
Quoted 7 lines · Chen, Yu C
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
This issue is seen on P11 as well.
[ 0.006697] smp: Brought up 1 node, 16 CPUs
[ 0.006702] Big cores detected but using small core scheduling
[ 0.006752] BUG: Kernel NULL pointer dereference on read at0x00000000
[ 0.006755] Faulting instruction address:0xc000000020adbb6c
[ 0.006759] Oops: Kernel access of bad area, sig: 7 [#1]
[ 0.006762] LE PAGE_SIZE=4K MMU=Radix SMP NR_CPUS=8192 NUMA pSeries
[ 0.006767] Modules linked in:
[ 0.006772] CPU: 4 UID: 0 PID: 1 Comm: swapper/4 Not tainted 7.1.0- rc5-next-20260525 #1 PREEMPT(lazy)
[ 0.006777] Hardware name: IBM,9080-HEX Power11 (architected)0x8202000xf000007of:IBM,FW1110.01 (NH1110_069) hv:phyp pSeries
[ 0.006781] NIP:c000000020adbb6cLR:c0000000202e5a58CTR: 0000000000000000
[ 0.006784] REGS:c0000000283d7890TRAP: 0300 Not tainted (7.1.0- rc5-next-20260525)
[ 0.006788] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002242 XER: 20040003
[ 0.006796] CFAR:c0000000202e5a54DAR: 0000000000000000 DSISR: 00080000 IRQMASK: 0
[ 0.006796] GPR00: 0000000000000000c0000000283d7b50c000000021abf1000000000000000010
[ 0.006796] GPR04: 0000000000000010 0000000000000030 0000000000000000c000000028365500
[ 0.006796] GPR08: 0000000000000000c000000022213598000000003b77d0000000000000000000
[ 0.006796] GPR12:c00000002005d8f0c000000000008000c0000000283cb578c0000000283cb400
[ 0.006796] GPR16:c0000000283c9000c000000022218b20c0000000222330e800000000ffffffff
[ 0.006796] GPR20:fffffffffffffff60000000000000000c000000022da36e00000000000000000
[ 0.006796] GPR24: 0000000000000000 0000000000000000c0000000283c9178c0000000227b5f00
[ 0.006796] GPR28:c00000002831c1e8c000000022db59800000000000000000 0000000000000000
[ 0.006835] NIP [c000000020adbb6c]_find_first_bit+0xc/0xc0
[ 0.006842] LR [c0000000202e5a58]build_sched_domains+0x7d8/0xb40
[ 0.006847] Call Trace:
[ 0.006849] [c0000000283d7b50] [c0000000202e5408]build_sched_domains+0x188/0xb40(unreliable)
[ 0.006854] [c0000000283d7c90] [c000000022034380]sched_init_domains+0x118/0x168
[ 0.006860] [c0000000283d7ce0] [c000000022032b14]sched_init_smp+0xa8/0x158
[ 0.006865] [c0000000283d7d30] [c000000022005674]kernel_init_freeable+0x1ac/0x294
[ 0.006870] [c0000000283d7dd0] [c000000020011718]kernel_init+0x2c/0x1c4
[ 0.006874] [c0000000283d7e30] [c00000002000debc]ret_from_kernel_user_thread+0x14/0x1c
[ 0.006878] ---- interrupt: 0 at0x0
[ 0.006881] Code:eb6100387fc3f378eb810040eba1004838210060ebc1fff0ebe1fff87c0803a64e8000207c681b787c8323794d820020<e9280000>38e3ffff3940000078e7d7e2[ 0.006895] ---[ end trace 0000000000000000 ]---
[ 0.006898]
Quoted 4 lines
Regards,
Venkat.
Venkat,
Was it on P11 on Shared LPAR?
Quoted 20 lines · Shrikanth Hegde
Quoted 19 lines · Venkat Rao Bagalkote
Quoted 12 lines · Yu C
Hi Venkat,
Quoted 9 lines · Srikar Dronamraju
Quoted 7 lines · Chen, Yu C
Hi Venkat,
Quoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
This issue is seen on P11 as well.
Quoted 8 lines
Quoted 4 lines
Regards,
Venkat.
Venkat,
Was it on P11 on Shared LPAR?
I also thought the same.
But I checked with Venkat, he said it was on a dedicated LPAR. My multiple tries on dedicated, didnt reproduce the problem.
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Ritesh Harjani (IBM)
reviewerQuoted 18 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
[ 0.039029] NIP [
c000000000e58504]_find_first_bit+0x44/0x130[ 0.039043] LR [c000000000e58500]_find_first_bit+0x40/0x130[ 0.039054] Call Trace:
[ 0.039060] [c0000000090e7b80] [c00000000416af20]schedutil_gov+0x0/0xa0(unreliable)
[ 0.039076] [c0000000090e7bc0] [c00000000038b3b8]build_sched_domains+0xad8/0xe50
[ 0.039089] [c0000000090e7ce0] [c000000003045d78]sched_init_smp+0xa8/0x164
[ 0.039102] [c0000000090e7d30] [c00000000300f374]kernel_init_freeable+0x250/0x370 [ 0.039117] [c0000000090e7de0] [c000000000011f90] kernel_init+0x34/0x1e4
Quoted 9 lines
[ 0.039129] [
c0000000090e7e50] [c00000000000debc]ret_from_kernel_user_thread+0x14/0x1c
[ 0.039142] ---- interrupt: 0 at0x0
[ 0.039150] Code: 418200907c0802a6393cfffffbe100387c7f1b78fba10028fbc100303bc00000793dd7e2f80100504bae6e9d60000000 <e93f0000>2c290000408200bc283c0040
[ 0.039196] ---[ end trace 0000000000000000 ]---
Well, I am hitting this on 7.1.0-rc5-next-20260526-00010-gbfac43765a97 with Qemu Pseries TCG power10/11.
[ 0.342868][ T1] smp: Bringing up secondary CPUs ...
[ 0.342868][ T1] smp: Bringing up secondary CPUs ...
[ 0.525419][ T1] smp: Brought up 1 node, 4 CPUs
[ 0.525419][ T1] smp: Brought up 1 node, 4 CPUs
[ 0.527992][ T1] numa: Node 0 CPUs: 0-3
[ 0.527992][ T1] numa: Node 0 CPUs: 0-3
[ 0.552787][ T1] BUG: Kernel NULL pointer dereference on read at 0x00000000
[ 0.552787][ T1] BUG: Kernel NULL pointer dereference on read at 0x00000000
[ 0.557446][ T1] Faulting instruction address: 0xc000000000fe3f1c
[ 0.557446][ T1] Faulting instruction address: 0xc000000000fe3f1c
cpu 0x0: Vector: 300 (Data Access) at [c000000006607800]
pc: c000000000fe3f1c: _find_first_bit+0xc/0xc0
lr: c00000000027b7d8: build_sched_domains+0xbb4/0x1938
sp: c000000006607ac0 msr: 8000000002009033
dar: 0
dsisr: 80000
current = 0xc000000006f9fb00
paca = 0xc000000005670000 irqmask: 0x03 irq_happened: 0x09
pid = 1, comm = swapper/0
Linux version 7.1.0-rc5-next-20260526-00010-gbfac43765a97-dirty (powerpc64le-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #19 SMP PREEMPT Thu May 28 12:29:51 IST 2026 enter ? for help
[link register ] c00000000027b7d8 build_sched_domains+0xbb4/0x1938
[c000000006607ac0] c00000000027b0a8 build_sched_domains+0x484/0x1938 (unreliable)
[c000000006607c20] c000000004053180 sched_init_domains+0x114/0x1cc
[c000000006607c70] c0000000040515e0 sched_init_smp+0x5c/0x17c
[c000000006607cc0] c000000004012888 kernel_init_freeable+0x258/0x790
[c000000006607dc0] c000000000011f3c kernel_init+0x34/0x268
[c000000006607e30] c00000000000debc ret_from_kernel_user_thread+0x14/0x1c
---- Exception: 0 at 0000000000000000
-ritesh
Quoted 30 lines · Ritesh Harjani
Quoted 18 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
[ 0.039029] NIP [
c000000000e58504]_find_first_bit+0x44/0x130[ 0.039043] LR [c000000000e58500]_find_first_bit+0x40/0x130[ 0.039054] Call Trace:
[ 0.039060] [c0000000090e7b80] [c00000000416af20]schedutil_gov+0x0/0xa0(unreliable)
[ 0.039076] [c0000000090e7bc0] [c00000000038b3b8]build_sched_domains+0xad8/0xe50
[ 0.039089] [c0000000090e7ce0] [c000000003045d78]sched_init_smp+0xa8/0x164
[ 0.039102] [c0000000090e7d30] [c00000000300f374]kernel_init_freeable+0x250/0x370 [ 0.039117] [c0000000090e7de0] [c000000000011f90] kernel_init+0x34/0x1e4Quoted 9 lines
[ 0.039129] [
c0000000090e7e50] [c00000000000debc]ret_from_kernel_user_thread+0x14/0x1c
[ 0.039142] ---- interrupt: 0 at0x0
[ 0.039150] Code: 418200907c0802a6393cfffffbe100387c7f1b78fba10028fbc100303bc00000793dd7e2f80100504bae6e9d60000000 <e93f0000>2c290000408200bc283c0040
[ 0.039196] ---[ end trace 0000000000000000 ]---
Quoted 3 lines
Well, I am hitting this on 7.1.0-rc5-next-20260526-00010-gbfac43765a97 with Qemu Pseries TCG power10/11.
Qemu Pseries guest would be a shared lpar. So thats expected to be similar to P9. We would not have a coregroup_map allocated.
Quoted 34 lines
[ 0.342868][ T1] smp: Bringing up secondary CPUs ... [ 0.342868][ T1] smp: Bringing up secondary CPUs ... [ 0.525419][ T1] smp: Brought up 1 node, 4 CPUs [ 0.525419][ T1] smp: Brought up 1 node, 4 CPUs [ 0.527992][ T1] numa: Node 0 CPUs: 0-3 [ 0.527992][ T1] numa: Node 0 CPUs: 0-3 [ 0.552787][ T1] BUG: Kernel NULL pointer dereference on read at 0x00000000 [ 0.552787][ T1] BUG: Kernel NULL pointer dereference on read at 0x00000000 [ 0.557446][ T1] Faulting instruction address: 0xc000000000fe3f1c [ 0.557446][ T1] Faulting instruction address: 0xc000000000fe3f1c cpu 0x0: Vector: 300 (Data Access) at [c000000006607800] pc: c000000000fe3f1c: _find_first_bit+0xc/0xc0 lr: c00000000027b7d8: build_sched_domains+0xbb4/0x1938 sp: c000000006607ac0msr: 8000000002009033
dar: 0
dsisr: 80000
current =0xc000000006f9fb00
paca =0xc000000005670000irqmask:0x03irq_happened:0x09
pid = 1, comm = swapper/0
Linux version 7.1.0-rc5-next-20260526-00010-gbfac43765a97-dirty (powerpc64le-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #19 SMP PREEMPT Thu May 28 12:29:51 IST 2026 enter ? for help
[link register ]c00000000027b7d8build_sched_domains+0xbb4/0x1938
[c000000006607ac0]c00000000027b0a8build_sched_domains+0x484/0x1938(unreliable)
[c000000006607c20]c000000004053180sched_init_domains+0x114/0x1cc
[c000000006607c70]c0000000040515e0sched_init_smp+0x5c/0x17c
[c000000006607cc0]c000000004012888kernel_init_freeable+0x258/0x790
[c000000006607dc0]c000000000011f3ckernel_init+0x34/0x268
[c000000006607e30]c00000000000debcret_from_kernel_user_thread+0x14/0x1c
---- Exception: 0 at 0000000000000000-ritesh
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Shrikanth Hegde
reviewerQuoted 4 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Hi Venkat, Ritesh,
Could you please try the below diff and see if it helps. This helps to fix boot problem for SPLPAR for me.
Hi Chenyu,
Let me know if I have to send the patch. Or
if you want to add more comments or change it feel free to pick it up and send it. Either way is fine. Let me know.
Hi Prateek, Srikar,
I hope the below diff makes sense. Please check.
nit: llc_mask is still under CONFIG_SCHED_MC, for ppc it is set to true always for SMP systems, and for others it is LLC domain. So not a concern i guess.
---
From 10e9413cef063446d67dc02c2b44e1ea582e5d53 Mon Sep 17 00:00:00 2001
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 06:16:44 -0400
Subject: [PATCH] topology: Provide arch_llc_mask for cache aware scheduling
Venkat Reported a boot kernel panic next-20260522. Git bisect pointed to b5ea300a17e3 ("sched/cache: Make LLC id continuous")
Stacktrace points to llc_mask being null.
NIP [c000000000e58504] _find_first_bit+0x44/0x130
LR [c000000000e58500] _find_first_bit+0x40/0x130
Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1c
On powerpc, cpu_coregroup_mask is available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn;t supported. In such cases llc_mask was being referrenced when it was null leading to panic.
on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
--- arch/powerpc/include/asm/topology.h | 3 +++ arch/powerpc/kernel/smp.c | 10 ++++++++++ kernel/sched/topology.c | 9 +++++++++ 3 files changed, 22 insertions(+)
arch/powerpc/include/asm/topology.h +3 -0
@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask +struct cpumask *cpu_coregroup_mask (int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu);
arch/powerpc/kernel/smp.c +10 -0
@@ -1101,6 +1101,16 @@ const struct cpumask *cpu_die_mask(int cpu) }EXPORT_SYMBOL_GPL (cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ +/* Power9, CACHE domain is the LLC*/ +if (shared_caches) +return cpu_l2_cache_mask (cpu); + +/* For others, SMT domain is the LLC*/ +return cpu_smt_mask (cpu); +} +int cpu_die_id (int cpu) {if (has_coregroup_support ())
kernel/sched/topology.c +9 -0
@@ -2063,7 +2063,16 @@ const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu return cpu_coregroup_mask(cpu); } +/* +* Majority of architectures have LLC at MC domain level with exception +* such as powerpc. Provide a way for arch to specify where its LLC is +* if it falls in exception category +*/ +# ifndef arch_llc_mask#define llc_mask (cpu) cpu_coregroup_mask(cpu) +# else +#define llc_mask (cpu) arch_llc_mask(cpu) +# endif #else #define llc_mask (cpu) cpumask_of(cpu)
Signature · 1 line
2.47.3
Chen, Yu C
Reviewed-byHi Shrikanth,
Quoted 29 lines · Shrikanth Hegde
From
10e9413cef063446d67dc02c2b44e1ea582e5d53Mon Sep 17 00:00:00 2001
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 06:16:44 -0400
Subject: [PATCH] topology: Providearch_llc_maskfor cache aware schedulingVenkat Reported a boot kernel panic next-20260522. Git bisect pointed to
b5ea300a17e3("sched/cache: Make LLC id continuous")Stacktrace points to
llc_maskbeing null.NIP [
c000000000e58504]_find_first_bit+0x44/0x130
LR [c000000000e58500]_find_first_bit+0x40/0x130Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1cOn powerpc,
cpu_coregroup_maskis available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn;t supported. In such casesllc_maskwas being referrenced when it was null leading to panic.on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
Quoted 5 lines
Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Closes https://lore.kernel.org/ all/[email protected]/Suggested-by Chen, Yu C <[email protected]>Signed-off-by Shrikanth Hegde <[email protected]>
It looks good to me. Let's see if this resolves the issue for Venkat and Ritesh. Feel free to send the formal version :)
thanks,
Chenyu
Quoted 55 lines · Shrikanth Hegde
Quoted 5 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Hi Venkat, Ritesh,
Could you please try the below diff and see if it helps. This helps to fix boot problem for SPLPAR for me.Hi Chenyu,
Let me know if I have to send the patch. Or
if you want to add more comments or change it feel free to pick it up and send it. Either way is fine. Let me know.Hi Prateek, Srikar,
I hope the below diff makes sense. Please check.nit:
llc_maskis still underCONFIG_SCHED_MC, for ppc it is set to true always for SMP systems, and for others it is LLC domain. So not a concern i guess.
---From
10e9413cef063446d67dc02c2b44e1ea582e5d53Mon Sep 17 00:00:00 2001
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 06:16:44 -0400
Subject: [PATCH] topology: Providearch_llc_maskfor cache aware schedulingVenkat Reported a boot kernel panic next-20260522. Git bisect pointed to
b5ea300a17e3("sched/cache: Make LLC id continuous")Stacktrace points to
llc_maskbeing null.NIP [
c000000000e58504]_find_first_bit+0x44/0x130
LR [c000000000e58500]_find_first_bit+0x40/0x130Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1cOn powerpc,
cpu_coregroup_maskis available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn;t supported. In such casesllc_maskwas being referrenced when it was null leading to panic.on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Suggested-by Chen, Yu C <[email protected]>Signed-off-by Shrikanth Hegde <[email protected]>
Quoted 6 lines
--- arch/powerpc/include/asm/topology.h | 3 +++ arch/powerpc/kernel/smp.c | 10 ++++++++++ kernel/sched/topology.c | 9 +++++++++ 3 files changed, 22 insertions(+)
I had to apply this change manually - as it wasn't cleanly applicable for me on linux-next. But since the changes were straight forward so it wasn't a problem.
With this change I don't see the panic anymore, which I was observing earlier.
Thanks for the quick fix. Feel free to add:
Quoted 82 lines · Shrikanth Hegde
Quoted 5 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Hi Venkat, Ritesh,
Could you please try the below diff and see if it helps. This helps to fix boot problem for SPLPAR for me.Hi Chenyu,
Let me know if I have to send the patch. Or
if you want to add more comments or change it feel free to pick it up and send it. Either way is fine. Let me know.Hi Prateek, Srikar,
I hope the below diff makes sense. Please check.nit:
llc_maskis still underCONFIG_SCHED_MC, for ppc it is set to true always for SMP systems, and for others it is LLC domain. So not a concern i guess.
---From
10e9413cef063446d67dc02c2b44e1ea582e5d53Mon Sep 17 00:00:00 2001
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 06:16:44 -0400
Subject: [PATCH] topology: Providearch_llc_maskfor cache aware schedulingVenkat Reported a boot kernel panic next-20260522. Git bisect pointed to
b5ea300a17e3("sched/cache: Make LLC id continuous")Stacktrace points to
llc_maskbeing null.NIP [
c000000000e58504]_find_first_bit+0x44/0x130
LR [c000000000e58500]_find_first_bit+0x40/0x130Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1cOn powerpc,
cpu_coregroup_maskis available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn;t supported. In such casesllc_maskwas being referrenced when it was null leading to panic.on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Suggested-by Chen, Yu C <[email protected]>Signed-off-by Shrikanth Hegde <[email protected]>--- arch/powerpc/include/asm/topology.h | 3 +++ arch/powerpc/kernel/smp.c | 10 ++++++++++ kernel/sched/topology.c | 9 +++++++++ 3 files changed, 22 insertions(+)arch/powerpc/include/asm/topology.h +3
-0@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask +struct cpumask *cpu_coregroup_mask (int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu);arch/powerpc/kernel/smp.c +0
-0@@ -1101,6 +1101,16 @@ const struct cpumask *cpu_die_mask(int cpu) }
arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1111
Quoted 10 lines
arch/powerpc/kernel/smp.c +9
-0EXPORT_SYMBOL_GPL (cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ +/* Power9, CACHE domain is the LLC*/ +if (shared_caches) +return cpu_l2_cache_mask (cpu); + +/* For others, SMT domain is the LLC*/ +return cpu_smt_mask (cpu); +}
Why dont we do
#define arch_llc_mask cpu_l2_cache_mask
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Shrikanth Hegde
reviewerQuoted 89 lines · Srikar Dronamraju
Quoted 87 lines · Shrikanth Hegde
Quoted 5 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Hi Venkat, Ritesh,
Could you please try the below diff and see if it helps. This helps to fix boot problem for SPLPAR for me.Hi Chenyu,
Let me know if I have to send the patch. Or
if you want to add more comments or change it feel free to pick it up and send it. Either way is fine. Let me know.Hi Prateek, Srikar,
I hope the below diff makes sense. Please check.nit:
llc_maskis still underCONFIG_SCHED_MC, for ppc it is set to true always for SMP systems, and for others it is LLC domain. So not a concern i guess.
---From
10e9413cef063446d67dc02c2b44e1ea582e5d53Mon Sep 17 00:00:00 2001
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 06:16:44 -0400
Subject: [PATCH] topology: Providearch_llc_maskfor cache aware schedulingVenkat Reported a boot kernel panic next-20260522. Git bisect pointed to
b5ea300a17e3("sched/cache: Make LLC id continuous")Stacktrace points to
llc_maskbeing null.NIP [
c000000000e58504]_find_first_bit+0x44/0x130
LR [c000000000e58500]_find_first_bit+0x40/0x130Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1cOn powerpc,
cpu_coregroup_maskis available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn;t supported. In such casesllc_maskwas being referrenced when it was null leading to panic.on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Suggested-by Chen, Yu C <[email protected]>Signed-off-by Shrikanth Hegde <[email protected]>--- arch/powerpc/include/asm/topology.h | 3 +++ arch/powerpc/kernel/smp.c | 10 ++++++++++ kernel/sched/topology.c | 9 +++++++++ 3 files changed, 22 insertions(+)arch/powerpc/include/asm/topology.h +3
-0@@ -131,6 +131,9 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_SMP #include <asm/cputable.h> +const struct cpumask *arch_llc_mask (int cpu); +#define arch_llc_mask arch_llc_mask +struct cpumask *cpu_coregroup_mask (int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu);arch/powerpc/kernel/smp.c +4
-0@@ -1101,6 +1101,16 @@ const struct cpumask *cpu_die_mask(int cpu) }EXPORT_SYMBOL_GPL (cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ +/* Power9, CACHE domain is the LLC*/ +if (shared_caches)
Quoted 9 lines
arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1112
Quoted 5 lines
arch/powerpc/kernel/smp.c +5
-0+return cpu_l2_cache_mask (cpu); + +/* For others, SMT domain is the LLC*/ +return cpu_smt_mask (cpu); +}Why dont we do
#definearch_llc_maskcpu_l2_cache_mask
I would prefer to keep the abstraction. This leaves room for implementation details.
Quoted 20 lines · Shrikanth Hegde
Quoted 10 lines
Quoted 10 lines
index
3467f86fd78f..cc8e87d6cae9100644arch/powerpc/kernel/smp.c +4
-0@@ -1101,6 +1101,16 @@ const struct cpumask *cpu_die_mask(int cpu) }EXPORT_SYMBOL_GPL (cpu_die_mask); +const struct cpumask *arch_llc_mask (int cpu) +{ +/* Power9, CACHE domain is the LLC*/ +if (shared_caches)Quoted 9 lines
arch/powerpc/kernel/smp.c const struct cpumask *cpu_die_mask(int cpu) · line 1112
Quoted 5 lines
arch/powerpc/kernel/smp.c +5
-0+return cpu_l2_cache_mask (cpu); + +/* For others, SMT domain is the LLC*/ +return cpu_smt_mask (cpu); +}Why dont we do
#definearch_llc_maskcpu_l2_cache_mask
Quoted 3 lines
I would prefer to keep the abstraction. This leaves room for implementation details.
We could always do that whenever we need it.
But doing it now will confuse the reader. Why keep if and else when both are returning the same.
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Hello. Sorry for too many mails.
Quoted 5 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Based on srikar's suggestion to keep the below,
#define arch_llc_mask(cpu) cpu_l2_cache_mask(cpu)
which makes it pretty much what chenyu had here
https://lore.kernel.org/all/[email protected]/
I added the changelog and comments. removed the changes in !CONFIG_MC case since powerpc defines it always. I have changed the chenyu tag to Co-developed-by: instead.
I have carried the tested-by and reviewed-by tags since patch is still more or less the same.
This is based on tip/master at5c89783224e9 Merge branch into tip/master: 'x86/tdx' I am planning to send it based on tip tree. Let me know if has to be against a any different tree.
Please let me know if there are any concerns. verified below too fixes the panic seen in shared LPAR.
============================================
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 23:23:43 -0400
Subject: [PATCH] sched/topology: Provide arch_llc_mask for cache aware scheduling
Venkat Reported a boot kernel panic next-20260522. Git bisect pointed to b5ea300a17e3 ("sched/cache: Make LLC id continuous")
Stacktrace points to llc_mask being null.
NIP [c000000000e58504] _find_first_bit+0x44/0x130
LR [c000000000e58500] _find_first_bit+0x40/0x130
Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1c
On powerpc, cpu_coregroup_mask is available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn't supported. In such cases llc_mask was being referenced when it was null leading to panic.
on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
--- arch/powerpc/include/asm/topology.h | 6 ++++++ kernel/sched/topology.c | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/topology.h +6 -0
@@ -135,6 +135,12 @@ struct cpumask *cpu_coregroup_mask(int cpu);const struct cpumask *cpu_die_mask (int cpu);int cpu_die_id (int cpu); +/* Points to where the LLC is. On power9 this will point at CACHE +* domain, On others it will point to SMT domain. In all cases +* cpu_l2_cache_mask points to where LLC is. +*/ +#define arch_llc_mask (cpu) cpu_l2_cache_mask(cpu) +#ifdef CONFIG_PPC64 #include <asm/smp.h>
kernel/sched/topology.c +11 -2
@@ -2063,12 +2063,21 @@ const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu return cpu_coregroup_mask(cpu); } -#define llc_mask (cpu) cpu_coregroup_mask(cpu) +/* +* Majority of architectures have LLC at MC domain level with exception +* such as powerpc. Provide a way for arch to specify where its LLC is +* if it falls in exception category +*/ +# ifndef arch_llc_mask +#define arch_llc_mask (cpu) cpu_coregroup_mask(cpu) +# endif #else -#define llc_mask (cpu) cpumask_of(cpu) +#define arch_llc_mask (cpu) cpumask_of(cpu)#endif +#define llc_mask (cpu) arch_llc_mask(cpu) +const struct cpumask *tl_pkg_mask (struct sched_domain_topology_level *tl,int cpu) {return cpu_node_mask (cpu);
Signature · 1 line
2.47.3
Venkat Rao Bagalkote
Tested-byQuoted 58 lines · Shrikanth Hegde
Hello. Sorry for too many mails.
Quoted 5 lines · Venkat Rao Bagalkote
Greetings!!!
I am seeing an early boot kernel panic due to NULL pointer dereference on a POWER9 (pSeries) system when testing linux-next (next-20260522).
Based on srikar's suggestion to keep the below, #define arch_llc_mask(cpu)
cpu_l2_cache_mask(cpu)which makes it pretty much what chenyu had here
https://lore.kernel.org/all/[email protected]/I added the changelog and comments. removed the changes in !CONFIG_MC case since powerpc defines it always. I have changed the chenyu tag to Co-developed-by: instead.
I have carried the tested-by and reviewed-by tags since patch is still more or less the same.
This is based on tip/master at
5c89783224e9 Merge branch into tip/master: 'x86/tdx' I am planning to send it based on tip tree. Let me know if has to be against a any different tree.Please let me know if there are any concerns. verified below too fixes the panic seen in shared LPAR.
============================================
From: Shrikanth Hegde <[email protected]>
Date: Thu, 28 May 2026 23:23:43 -0400
Subject: [PATCH] sched/topology: Providearch_llc_maskfor cache aware schedulingVenkat Reported a boot kernel panic next-20260522. Git bisect pointed to
b5ea300a17e3("sched/cache: Make LLC id continuous")Stacktrace points to
llc_maskbeing null.NIP [
c000000000e58504]_find_first_bit+0x44/0x130
LR [c000000000e58500]_find_first_bit+0x40/0x130Call Trace: build_sched_domains+0xad8/0xe50 sched_init_smp+0xa8/0x164 kernel_init_freeable+0x250/0x370 ret_from_kernel_user_thread+0x14/0x1cOn powerpc,
cpu_coregroup_maskis available only when the underlying hardware support coregroup. In shared LPAR, QEMU guest or power9 etc coregroup isn't supported. In such casesllc_maskwas being referenced when it was null leading to panic.on powerpc, LLC is at SMT core level. So assumption that coregroup(MC) domain point to LLC is wrong. Provide a way for archs to say where its LLC is if it not at MC domain.
Quoted 8 lines
Fixes b5ea300a17e3 ("sched/cache: Make LLC id continuous")Reported-by Venkat Rao Bagalkote <[email protected]>Reviewed-by Chen Yu <[email protected]>Tested-by Ritesh Harjani (IBM) <[email protected]>Co-developed-by Chen, Yu C <[email protected]>Signed-off-by Shrikanth Hegde <[email protected]>---
Tested this fix, by applying on top of commit b5ea300a17e37eada7a98561fbd34a3054578713 and on P9, its booting fine. Please add the below tag.
Regards,
Venkat.
Quoted 50 lines
arch/powerpc/include/asm/topology.h | 6 ++++++ kernel/sched/topology.c | 13 +++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)arch/powerpc/include/asm/topology.h +6
-0@@ -135,6 +135,12 @@ struct cpumask *cpu_coregroup_mask(int cpu); const struct cpumask *cpu_die_mask(int cpu); int cpu_die_id(int cpu); +/* Points to where the LLC is. On power9 this will point at CACHE +* domain, On others it will point to SMT domain. In all cases +* cpu_l2_cache_mask points to where LLC is. +*/ +#define arch_llc_mask (cpu) cpu_l2_cache_mask(cpu) + #ifdef CONFIG_PPC64 #include <asm/smp.h>kernel/sched/topology.c +0
-0@@ -2063,12 +2063,21 @@ const struct cpumask *tl_mc_mask(struct
sched_domain_topology_level*tl, int cpu
returncpu_coregroup_mask(cpu);
}kernel/sched/topology.c +8
-1-#define llc_mask (cpu) cpu_coregroup_mask(cpu) +/* +* Majority of architectures have LLC at MC domain level with exception +* such as powerpc. Provide a way for arch to specify where its LLC is +* if it falls in exception category +*/ +# ifndef arch_llc_mask +#define arch_llc_mask (cpu) cpu_coregroup_mask(cpu) +# endif #else
kernel/sched/topology.c +1
-1-#define llc_mask (cpu) cpumask_of(cpu) +#define arch_llc_mask (cpu) cpumask_of(cpu)#endif
kernel/sched/topology.c +2
-0+#define llc_mask (cpu) arch_llc_mask(cpu) +const struct cpumask *tl_pkg_mask(struct
sched_domain_topology_level*tl, int cpu) {
returncpu_node_mask(cpu);