Coregroup support on Powerpc
v5 cover Coregroup support on Powerpc
Changelog v4->v5:
v4: http://lore.kernel.org/lkml/[email protected]/t/#u
Changelog v4 ->v5:
powerpc/smp: Optimize start_secondary
Retain cache domain, no need for generalization
(Michael Ellerman, Peter Zijlstra, Valentin Schneider, Gautham R. Shenoy)
powerpc/numa: Detect support for coregroup
Updated commit msg with current abstract nature of the coregroups
(Michael Ellerman)
powerpc/smp: Allocate cpumask only after searching thread group
Updated commit msg on why cpumask need not be freed.
(Michael Ellerman)
powerpc/smp: Create coregroup domain
Updated commit msg to specify actual implementation of cpu_to_coregroup_id is in a subsequent patch (Michael Ellerman)
Changelog v3 ->v4:
v3: https://lore.kernel.org/lkml/[email protected]/t/#u
powerpc/smp: Create coregroup domain
if coregroup_support doesn't exist, update MC mask to the next smaller domain mask.
Changelog v2 -> v3:
v2: https://lore.kernel.org/linuxppc-dev/[email protected]/t/#u
powerpc/smp: Cache node for reuse
Removed node caching part. Rewrote the Commit msg (Michael Ellerman) Renamed to powerpc/smp: Fix a warning under !NEED_MULTIPLE_NODES
powerpc/smp: Enable small core scheduling sooner
Rewrote changelog (Gautham)
Renamed to powerpc/smp: Move topology fixups into a new function
powerpc/smp: Create coregroup domain
Add optimization for mask updation under coregroup_support
Changelog v1 -> v2:
v1: https://lore.kernel.org/linuxppc-dev/[email protected]/t/#u
powerpc/smp: Merge Power9 topology with Power topology
Replaced a reference to cpu_smt_mask with per_cpu(cpu_sibling_map, cpu) since cpu_smt_mask is only defined under CONFIG_SCHED_SMT
powerpc/smp: Enable small core scheduling sooner
Restored the previous info msg (Jordan)
Moved big core topology fixup to fixup_topology (Gautham)
powerpc/smp: Dont assume l2-cache to be superset of sibling
Set cpumask after verifying l2-cache. (Gautham)
powerpc/smp: Generalize 2nd sched domain
Moved shared_cache topology fixup to fixup_topology (Gautham)
Powerpc/numa: Detect support for coregroup
Explained Coregroup in commit msg (Michael Ellerman)
Powerpc/smp: Create coregroup domain
Moved coregroup topology fixup to fixup_topology (Gautham)
powerpc/smp: Implement cpu_to_coregroup_id
Move coregroup_enabled before getting associativity (Gautham)
powerpc/smp: Provide an ability to disable coregroup
Patch dropped (Michael Ellerman)
Cleanup of existing powerpc topologies and add coregroup support on Powerpc. Coregroup is a group of (subset of) cores of a DIE that share a resource.
Patch 7 of this patch series: "Powerpc/numa: Detect support for coregroup" depends on
https://lore.kernel.org/linuxppc-dev/[email protected]/t/#u
However it should be easy to rebase the patch without the above patch.
This patch series is based on top of current powerpc/next tree + the above patch.
Summary of some of the testing done with coregroup patchset.
It includes ebizzy, schbench, perf bench sched pipe and topology verification. One the left side are results from powerpc/next tree and on the right are the results with the patchset applied. Topological verification clearly shows that there is no change in topology with and without the patches on all the 3 class of systems that were tested.
On PowerPc/Next On Powerpc/next + Coregroup Support v5 patchset
Power 9 PowerNV (2 Node/ 160 Cpu System)
---------------------------------
ebizzy (Throughput of 100 iterations of 30 seconds higher throughput is better)
N Min Max Median Avg Stddev N Min Max Median Avg Stddev
100 993884 1276090 1173476 1165914 54867.201 100 910470 1279820 1171095 1162091 67363.28
schbench (latency hence lower is better)
Latency percentiles (usec) Latency percentiles (usec)
50.0th: 455 50.0th: 454
75.0th: 533 75.0th: 543
90.0th: 683 90.0th: 701
95.0th: 743 95.0th: 737
*99.0th: 815 *99.0th: 805
99.5th: 839 99.5th: 835
99.9th: 913 99.9th: 893
min=0, max=1011 min=0, max=2833perf bench sched pipe (lesser time and higher ops/sec is better)
# Running 'sched/pipe' benchmark: # Running 'sched/pipe' benchmark:
# Executed 1000000 pipe operations between two processes # Executed 1000000 pipe operations between two processes
Total time: 6.083 [sec] Total time: 6.303 [sec]
6.083576 usecs/op 6.303318 usecs/op
164377 ops/sec 158646 ops/sec
Power 9 LPAR (2 Node/ 128 Cpu System)
---------------------------------
ebizzy (Throughput of 100 iterations of 30 seconds higher throughput is better)
N Min Max Median Avg Stddev N Min Max Median Avg Stddev
100 1058029 1295393 1200414 1188306.7 56786.538 100 943264 1287619 1180522 1168473.2 64469.955
schbench (latency hence lower is better)
Latency percentiles (usec) Latency percentiles (usec)
50.0000th: 34 50.0000th: 39
75.0000th: 46 75.0000th: 52
90.0000th: 53 90.0000th: 68
95.0000th: 56 95.0000th: 77
*99.0000th: 61 *99.0000th: 89
99.5000th: 63 99.5000th: 94
99.9000th: 81 99.9000th: 169
min=0, max=8405 min=0, max=23674perf bench sched pipe (lesser time and higher ops/sec is better)
# Running 'sched/pipe' benchmark: # Running 'sched/pipe' benchmark:
# Executed 1000000 pipe operations between two processes # Executed 1000000 pipe operations between two processes
Total time: 8.768 [sec] Total time: 5.217 [sec]
8.768400 usecs/op 5.217625 usecs/op
114045 ops/sec 191658 ops/sec
Power 8 LPAR (8 Node/ 256 Cpu System)
---------------------------------
ebizzy (Throughput of 100 iterations of 30 seconds higher throughput is better)
N Min Max Median Avg Stddev N Min Max Median Avg Stddev
100 1267615 1965234 1707423 1689137.6 144363.29 100 1175357 1924262 1691104 1664792.1 145876.4
schbench (latency hence lower is better)
Latency percentiles (usec) Latency percentiles (usec)
50.0th: 37 50.0th: 36
75.0th: 51 75.0th: 48
90.0th: 59 90.0th: 55
95.0th: 63 95.0th: 59
*99.0th: 71 *99.0th: 67
99.5th: 75 99.5th: 72
99.9th: 105 99.9th: 170
min=0, max=18560 min=0, max=27031perf bench sched pipe (lesser time and higher ops/sec is better)
# Running 'sched/pipe' benchmark: # Running 'sched/pipe' benchmark:
# Executed 1000000 pipe operations between two processes # Executed 1000000 pipe operations between two processes
Total time: 6.013 [sec] Total time: 5.930 [sec]
6.013963 usecs/op 5.930724 usecs/op
166279 ops/sec 168613 ops/sec
Topology verification on Power9
Power9/ PowerNV / SMT4
tail -f /proc/cpuinfo
---------------------
cpu : POWER9, altivec supported
clock : 3600.000000MHz
revision : 2.2 (pvr 004e 1202)
timebase : 512000000
platform : PowerNV
model : 9006-22P
machine : PowerNV 9006-22P
firmware : OPAL
MMU : Radix
On PowerPc/Next On Powerpc/next + Coregroup Support v5 patchset lscpu lscpu ------ ------ Architecture: ppc64le Architecture: ppc64le Byte Order: Little Endian Byte Order: Little Endian CPU(s): 160 CPU(s): 160 On-line CPU(s) list: 0-159 On-line CPU(s) list: 0-159 Thread(s) per core: 4 Thread(s) per core: 4 Core(s) per socket: 20 Core(s) per socket: 20 Socket(s): 2 Socket(s): 2 NUMA node(s): 2 NUMA node(s): 2 Model: 2.2 (pvr 004e 1202) Model: 2.2 (pvr 004e 1202) Model name: POWER9, altivec supported Model name: POWER9, altivec supported CPU max MHz: 3800.0000 CPU max MHz: 3800.0000 CPU min MHz: 2166.0000 CPU min MHz: 2166.0000 L1d cache: 32K L1d cache: 32K L1i cache: 32K L1i cache: 32K L2 cache: 512K L2 cache: 512K L3 cache: 10240K L3 cache: 10240K NUMA node0 CPU(s): 0-79 NUMA node0 CPU(s): 0-79 NUMA node8 CPU(s): 80-159 NUMA node8 CPU(s): 80-159
grep . /proc/sys/kernel/sched_domain/cpu0/domain*/name grep . /proc/sys/kernel/sched_domain/cpu0/domain*/name ----------------------------------------------------- ----------------------------------------------------- /proc/sys/kernel/sched_domain/cpu0/domain0/name:SMT /proc/sys/kernel/sched_domain/cpu0/domain0/name:SMT /proc/sys/kernel/sched_domain/cpu0/domain1/name:CACHE /proc/sys/kernel/sched_domain/cpu0/domain1/name:CACHE /proc/sys/kernel/sched_domain/cpu0/domain2/name:DIE /proc/sys/kernel/sched_domain/cpu0/domain2/name:DIE /proc/sys/kernel/sched_domain/cpu0/domain3/name:NUMA /proc/sys/kernel/sched_domain/cpu0/domain3/name:NUMA
grep . /proc/sys/kernel/sched_domain/cpu0/domain*/flags grep . /proc/sys/kernel/sched_domain/cpu0/domain*/flags ------------------------------------------------------ ------------------------------------------------------ /proc/sys/kernel/sched_domain/cpu0/domain0/flags:2391 /proc/sys/kernel/sched_domain/cpu0/domain0/flags:2391 /proc/sys/kernel/sched_domain/cpu0/domain1/flags:2327 /proc/sys/kernel/sched_domain/cpu0/domain1/flags:2327 /proc/sys/kernel/sched_domain/cpu0/domain2/flags:2071 /proc/sys/kernel/sched_domain/cpu0/domain2/flags:2071 /proc/sys/kernel/sched_domain/cpu0/domain3/flags:12801 /proc/sys/kernel/sched_domain/cpu0/domain3/flags:12801
On PowerPc/Next
head /proc/schedstat
--------------------
version 15
timestamp 4295043536
cpu0 0 0 0 0 0 0 9597119314 2408913694 11897
domain0 00000000,00000000,00000000,00000000,0000000f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 00000000,00000000,0000ffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain3 ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu1 0 0 0 0 0 0 4941435230 11106132 1583
domain0 00000000,00000000,00000000,00000000,0000000f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
On Powerpc/next + Coregroup Support v5 patchset
head /proc/schedstat
--------------------
version 15
timestamp 4296311826
cpu0 0 0 0 0 0 0 3353674045024 3781680865826 297483
domain0 00000000,00000000,00000000,00000000,0000000f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 00000000,00000000,0000ffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain3 ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu1 0 0 0 0 0 0 3337873293332 4231590033856 229090
domain0 00000000,00000000,00000000,00000000,0000000f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Post sudo ppc64_cpu --smt=1 Post sudo ppc64_cpu --smt=1 --------------------- --------------------- grep . /proc/sys/kernel/sched_domain/cpu0/domain*/name grep . /proc/sys/kernel/sched_domain/cpu0/domain*/name ----------------------------------------------------- ----------------------------------------------------- /proc/sys/kernel/sched_domain/cpu0/domain0/name:CACHE /proc/sys/kernel/sched_domain/cpu0/domain0/name:CACHE /proc/sys/kernel/sched_domain/cpu0/domain1/name:DIE /proc/sys/kernel/sched_domain/cpu0/domain1/name:DIE /proc/sys/kernel/sched_domain/cpu0/domain2/name:NUMA /proc/sys/kernel/sched_domain/cpu0/domain2/name:NUMA
grep . /proc/sys/kernel/sched_domain/cpu0/domain*/flags grep . /proc/sys/kernel/sched_domain/cpu0/domain*/flags ------------------------------------------------------ ------------------------------------------------------ /proc/sys/kernel/sched_domain/cpu0/domain0/flags:2327 /proc/sys/kernel/sched_domain/cpu0/domain0/flags:2327 /proc/sys/kernel/sched_domain/cpu0/domain1/flags:2071 /proc/sys/kernel/sched_domain/cpu0/domain1/flags:2071 /proc/sys/kernel/sched_domain/cpu0/domain2/flags:12801 /proc/sys/kernel/sched_domain/cpu0/domain2/flags:12801
On Powerpc/next
head /proc/schedstat
--------------------
version 15
timestamp 4295046242
cpu0 0 0 0 0 0 0 10978610020 2658997390 13068
domain0 00000000,00000000,00000000,00000000,00000011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00001111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 91111111,11111111,11111111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu4 0 0 0 0 0 0 5408663896 95701034 7697
domain0 00000000,00000000,00000000,00000000,00000011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00001111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 91111111,11111111,11111111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
On Powerpc/next + Coregroup Support v5 patchset
head /proc/schedstat
--------------------
version 15
timestamp 4296314905
cpu0 0 0 0 0 0 0 3355392013536 3781975150576 298723
domain0 00000000,00000000,00000000,00000000,00000011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00001111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 91111111,11111111,11111111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu4 0 0 0 0 0 0 3351637920996 4427329763050 256776
domain0 00000000,00000000,00000000,00000000,00000011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00001111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 91111111,11111111,11111111,11111111,11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Similar verification was done on Power 8 (8 Node 256 CPU LPAR) and Power 9 (2 node 128 Cpu LPAR) and they showed the topology before and after the patch to be identical. If Interested, I could provide the same.
On Power 9 (with device-tree enablement to show coregroups). (hunks for mimicing a coregroup was posted at
https://lore.kernel.org/linuxppc-dev/[email protected]/t/#m2cb09bb11c7a93257d6123d1d27edb8212f8af21)
-----------------------------------------------------------
$ tail /proc/cpuinfo processor : 127 cpu : POWER9 (architected), altivec supported clock : 3000.000000MHz revision : 2.2 (pvr 004e 0202)
timebase : 512000000
platform : pSeries
model : IBM,9008-22L
machine : CHRP IBM,9008-22L
MMU : Hash
Before patchset
--------------
$ cat /proc/sys/kernel/sched_domain/cpu0/domain*/name SMT CACHE DIE NUMA
$ head /proc/schedstat version 15 timestamp 4318242208 cpu0 0 0 0 0 0 0 28077107004 4773387362 78205 domain0 00000000,00000000,00000000,00000055 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 00000000,00000000,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain3 ffffffff,ffffffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu1 0 0 0 0 0 0 24177439200 413887604 75393 domain0 00000000,00000000,00000000,000000aa 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
After patchset
--------------
$ cat /proc/sys/kernel/sched_domain/cpu0/domain*/name SMT CACHE MC DIE NUMA
$ head /proc/schedstat version 15 timestamp 4318242208 cpu0 0 0 0 0 0 0 28077107004 4773387362 78205 domain0 00000000,00000000,00000000,00000055 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain1 00000000,00000000,00000000,000000ff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain2 00000000,00000000,00000000,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain3 00000000,00000000,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 domain4 ffffffff,ffffffff,ffffffff,ffffffff 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cpu1 0 0 0 0 0 0 24177439200 413887604 75393 domain0 00000000,00000000,00000000,000000aa 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Srikar Dronamraju (10):
powerpc/smp: Fix a warning under !NEED_MULTIPLE_NODES powerpc/smp: Merge Power9 topology with Power topology powerpc/smp: Move powerpc_topology above
powerpc/smp: Move topology fixups into a new function powerpc/smp: Dont assume l2-cache to be superset of sibling powerpc/smp: Optimize start_secondary
powerpc/numa: Detect support for coregroup powerpc/smp: Allocate cpumask only after searching thread group powerpc/smp: Create coregroup domain
powerpc/smp: Implement cpu_to_coregroup_id
arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/include/asm/topology.h | 10 ++ arch/powerpc/kernel/smp.c | 235 +++++++++++++++++----------- arch/powerpc/mm/numa.c | 59 +++++-- 4 files changed, 198 insertions(+), 107 deletions(-)
Signature · 1 line
2.18.2
PATCH v5 1/10 powerpc/smp: Fix a warning under !NEED_MULTIPLE_NODES
Fix a build warning in a non CONFIG_NEED_MULTIPLE_NODES "error: _numa_cpu_lookup_table_ undeclared"
---
Changelog v2 -> v3:
Removed node caching part. Rewrote the Commit msg (Michael Ellerman) Renamed to powerpc/smp: Fix a warning under !NEED_MULTIPLE_NODES
arch/powerpc/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kernel/smp.c +2 -0
@@ -860,6 +860,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) GFP_KERNEL, cpu_to_node(cpu));zalloc_cpumask_var_node (&per_cpu (cpu_core_map, cpu),GFP_KERNEL ,cpu_to_node (cpu)); +#ifdef CONFIG_NEED_MULTIPLE_NODES /* * numa_node_id() works after this. */
@@ -868,6 +869,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)set_cpu_numa_mem (cpu, local_memory_node(numa_cpu_lookup_table[cpu])); } +#endif }/* Init the cpumasks so the boot CPU is related to itself */
Signature · 1 line
2.18.2
PATCH v5 2/10 powerpc/smp: Merge Power9 topology with Power topology
In reply to Srikar DronamrajuA new sched_domain_topology_level was added just for Power9. However the same can be achieved by merging powerpc_topology with power9_topology and makes the code more simpler especially when adding a new sched domain.
---
Changelog v1 -> v2:
Replaced a reference to cpu_smt_mask with per_cpu(cpu_sibling_map, cpu) since cpu_smt_mask is only defined under CONFIG_SCHED_SMT
arch/powerpc/kernel/smp.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
arch/powerpc/kernel/smp.c +3 -22
@@ -1313,7 +1313,7 @@ int setup_profiling_timer(unsigned int multiplier) }#ifdef CONFIG_SCHED_SMT -/* cpumask of CPUs with asymetric SMT dependancy */ +/* cpumask of CPUs with asymmetric SMT dependency */ static int powerpc_smt_flags (void ) {int flags =SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ;
@@ -1326,14 +1326,6 @@ static int powerpc_smt_flags(void) }#endif -static struct sched_domain_topology_level powerpc_topology[] = { -#ifdef CONFIG_SCHED_SMT - { cpu_smt_mask, powerpc_smt_flags,SD_INIT_NAME (SMT ) }, -#endif - { cpu_cpu_mask,SD_INIT_NAME (DIE ) }, - {NULL , }, -}; -/* * P9 has a slightly odd architecture where pairs of cores share an L2 cache. * This topology makes it *much* cheaper to migrate tasks between adjacent cores
@@ -1361,7 +1353,7 @@ static const struct cpumask *smallcore_smt_mask(int cpu) }#endif -static struct sched_domain_topology_level power9_topology[] = { +static struct sched_domain_topology_level powerpc_topology[] = { #ifdef CONFIG_SCHED_SMT { cpu_smt_mask, powerpc_smt_flags,SD_INIT_NAME (SMT ) }, #endif
@@ -1386,21 +1378,10 @@ void __init smp_cpus_done(unsigned int max_cpus)#ifdef CONFIG_SCHED_SMT if (has_big_cores) {pr_info ("Big cores detected but using small core scheduling\n" ); - power9_topology[0 ].mask = smallcore_smt_mask; powerpc_topology[0 ].mask = smallcore_smt_mask; }#endif -/* -* If any CPU detects that it's sharing a cache with another CPU then -* use the deeper topology that is aware of this sharing. -*/ -if (shared_caches) { -pr_info ("Using shared cache scheduler topology\n" ); -set_sched_topology (power9_topology); - }else { -pr_info ("Using standard scheduler topology\n" ); -set_sched_topology (powerpc_topology); - } +set_sched_topology (powerpc_topology); }#ifdef CONFIG_HOTPLUG_CPU
Signature · 1 line
2.18.2
PATCH v5 3/10 powerpc/smp: Move powerpc_topology above
In reply to Srikar DronamrajuJust moving the powerpc_topology description above.
This will help in using functions in this file and avoid declarations.
No other functional changes
--- arch/powerpc/kernel/smp.c | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-)
arch/powerpc/kernel/smp.c +52 -52
@@ -818,6 +818,58 @@ static int init_cpu_l1_cache_map(int cpu)return err; } +static bool shared_caches; + +#ifdef CONFIG_SCHED_SMT +/* cpumask of CPUs with asymmetric SMT dependency */ +static int powerpc_smt_flags (void ) +{ +int flags =SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ; + +if (cpu_has_feature (CPU_FTR_ASYM_SMT )) { +printk_once (KERN_INFO "Enabling Asymmetric SMT scheduling\n" ); + flags |=SD_ASYM_PACKING ; + } +return flags; +} +#endif + +/* +* P9 has a slightly odd architecture where pairs of cores share an L2 cache. +* This topology makes it *much* cheaper to migrate tasks between adjacent cores +* since the migrated task remains cache hot. We want to take advantage of this +* at the scheduler level so an extra topology level is required. +*/ +static int powerpc_shared_cache_flags (void ) +{ +return SD_SHARE_PKG_RESOURCES ; +} + +/* +* We can't just pass cpu_l2_cache_mask() directly because +* returns a non-const pointer and the compiler barfs on that. +*/ +static const struct cpumask *shared_cache_mask (int cpu) +{ +return cpu_l2_cache_mask (cpu); +} + +#ifdef CONFIG_SCHED_SMT +static const struct cpumask *smallcore_smt_mask (int cpu) +{ +return cpu_smallcore_mask (cpu); +} +#endif + +static struct sched_domain_topology_level powerpc_topology[] = { +#ifdef CONFIG_SCHED_SMT + { cpu_smt_mask, powerpc_smt_flags,SD_INIT_NAME (SMT ) }, +#endif + { shared_cache_mask, powerpc_shared_cache_flags,SD_INIT_NAME (CACHE ) }, + { cpu_cpu_mask,SD_INIT_NAME (DIE ) }, + {NULL , }, +}; +static int init_big_cores (void ) {int cpu;
@@ -1247,8 +1299,6 @@ static void add_cpu_to_masks(int cpu)set_cpus_related (cpu, i, cpu_core_mask); } -static bool shared_caches; -/* Activate a secondary processor. */ void start_secondary (void *unused) {
@@ -1312,56 +1362,6 @@ int setup_profiling_timer(unsigned int multiplier)return 0 ; } -#ifdef CONFIG_SCHED_SMT -/* cpumask of CPUs with asymmetric SMT dependency */ -static int powerpc_smt_flags (void ) -{ -int flags =SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ; - -if (cpu_has_feature (CPU_FTR_ASYM_SMT )) { -printk_once (KERN_INFO "Enabling Asymmetric SMT scheduling\n" ); - flags |=SD_ASYM_PACKING ; - } -return flags; -} -#endif - -/* -* P9 has a slightly odd architecture where pairs of cores share an L2 cache. -* This topology makes it *much* cheaper to migrate tasks between adjacent cores -* since the migrated task remains cache hot. We want to take advantage of this -* at the scheduler level so an extra topology level is required. -*/ -static int powerpc_shared_cache_flags (void ) -{ -return SD_SHARE_PKG_RESOURCES ; -} - -/* -* We can't just pass cpu_l2_cache_mask() directly because -* returns a non-const pointer and the compiler barfs on that. -*/ -static const struct cpumask *shared_cache_mask (int cpu) -{ -return cpu_l2_cache_mask (cpu); -} - -#ifdef CONFIG_SCHED_SMT -static const struct cpumask *smallcore_smt_mask (int cpu) -{ -return cpu_smallcore_mask (cpu); -} -#endif - -static struct sched_domain_topology_level powerpc_topology[] = { -#ifdef CONFIG_SCHED_SMT - { cpu_smt_mask, powerpc_smt_flags,SD_INIT_NAME (SMT ) }, -#endif - { shared_cache_mask, powerpc_shared_cache_flags,SD_INIT_NAME (CACHE ) }, - { cpu_cpu_mask,SD_INIT_NAME (DIE ) }, - {NULL , }, -}; -void __init smp_cpus_done (unsigned int max_cpus) {/*
Signature · 1 line
2.18.2
PATCH v5 4/10 powerpc/smp: Move topology fixups into a new function
In reply to Srikar DronamrajuMove topology fixup based on the platform attributes into its own function which is called just before set_sched_topology.
---
Changelog v2 -> v3:
Rewrote changelog (Gautham)
Renamed to powerpc/smp: Move topology fixups into a new function
arch/powerpc/kernel/smp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/powerpc/kernel/smp.c +11 -6
@@ -1362,6 +1362,16 @@ int setup_profiling_timer(unsigned int multiplier)return 0 ; } +static void fixup_topology (void ) +{ +#ifdef CONFIG_SCHED_SMT +if (has_big_cores) { +pr_info ("Big cores detected but using small core scheduling\n" ); + powerpc_topology[0 ].mask = smallcore_smt_mask; + } +#endif +} +void __init smp_cpus_done (unsigned int max_cpus) {/*
@@ -1375,12 +1385,7 @@ void __init smp_cpus_done(unsigned int max_cpus)dump_numa_cpu_topology (); -#ifdef CONFIG_SCHED_SMT -if (has_big_cores) { -pr_info ("Big cores detected but using small core scheduling\n" ); - powerpc_topology[0 ].mask = smallcore_smt_mask; - } -#endif +fixup_topology ();set_sched_topology (powerpc_topology); }
Signature · 1 line
2.18.2
PATCH v5 5/10 powerpc/smp: Dont assume l2-cache to be superset of sibling
In reply to Srikar DronamrajuCurrent code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of cpu_sibling_mask.
Lets stop that assumption. cpu_l2_cache_mask is a superset of cpu_sibling_mask if and only if shared_caches is set.
---
Changelog v1 -> v2:
Set cpumask after verifying l2-cache. (Gautham)
arch/powerpc/kernel/smp.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
arch/powerpc/kernel/smp.c +15 -13
@@ -1188,6 +1188,7 @@ static bool update_mask_by_l2(int cpu, struct cpumask *(*mask_fn)(int))if (!l2_cache)return false; +cpumask_set_cpu (cpu,mask_fn (cpu));for_each_cpu (i, cpu_online_mask) {/* * when updating the marks the current CPU has not been marked
@@ -1270,29 +1271,30 @@ static void add_cpu_to_masks(int cpu)* add it to it's own thread sibling mask. */ cpumask_set_cpu (cpu,cpu_sibling_mask (cpu)); +cpumask_set_cpu (cpu,cpu_core_mask (cpu));for (i = first_thread; i < first_thread + threads_per_core; i++)if (cpu_online (i))set_cpus_related (i, cpu, cpu_sibling_mask);add_cpu_to_smallcore_masks (cpu); -/* -* Copy the thread sibling mask into the cache sibling mask -* and mark any CPUs that share an L2 with this CPU. -*/ -for_each_cpu (i,cpu_sibling_mask (cpu)) -set_cpus_related (cpu, i, cpu_l2_cache_mask);update_mask_by_l2 (cpu, cpu_l2_cache_mask); -/* -* Copy the cache sibling mask into core sibling mask and mark -* any CPUs on the same chip as this CPU. -*/ -for_each_cpu (i,cpu_l2_cache_mask (cpu)) -set_cpus_related (cpu, i, cpu_core_mask); +if (pkg_id ==-1 ) { +struct cpumask *(*mask)(int ) = cpu_sibling_mask; + +/* +* Copy the sibling mask into core sibling mask and +* mark any CPUs on the same chip as this CPU. +*/ +if (shared_caches) + mask = cpu_l2_cache_mask; + +for_each_cpu (i,mask (cpu)) +set_cpus_related (cpu, i, cpu_core_mask); -if (pkg_id ==-1 )return ; + }for_each_cpu (i, cpu_online_mask)if (get_physical_package_id (i) == pkg_id)
Signature · 1 line
2.18.2
Michael Ellerman
reviewerRe: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
Quoted 5 lines · Srikar Dronamraju
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of
cpu_sibling_mask.Lets stop that assumption.
cpu_l2_cache_maskis a superset ofcpu_sibling_maskif and only ifshared_cachesis set.
I'm seeing oopses with this:
[ 0.117392][ T1] smp: Bringing up secondary CPUs ... [ 0.156515][ T1] smp: Brought up 2 nodes, 2 CPUs [ 0.158265][ T1] numa: Node 0 CPUs: 0 [ 0.158520][ T1] numa: Node 1 CPUs: 1 [ 0.167453][ T1] BUG: Unable to handle kernel data access on read at 0x8000000041228298 [ 0.167992][ T1] Faulting instruction address: 0xc00000000018c128 [ 0.168817][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.168964][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries [ 0.169417][ T1] Modules linked in: [ 0.170047][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #209 [ 0.170305][ T1] NIP: c00000000018c128 LR: c00000000018c0cc CTR: c00000000004dce0 [ 0.170498][ T1] REGS: c00000007e343880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.170602][ T1] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00000000 [ 0.170985][ T1] CFAR: c00000000018c288 IRQMASK: 0 [ 0.170985][ T1] GPR00: 0000000000000000 c00000007e343b10 c00000000173e400 0000000000004000 [ 0.170985][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000800 0000000000000000 [ 0.170985][ T1] GPR08: 0000000000000000 c00000000122c298 c00000003fffc000 c00000007fd05ce8 [ 0.170985][ T1] GPR12: c00000007e0119f8 c000000001930000 00000000ffff8ade 0000000000000000 [ 0.170985][ T1] GPR16: c00000007e3c0640 0000000000000917 c00000007e3c0658 0000000000000008 [ 0.170985][ T1] GPR20: c0000000015d0bb8 00000000ffff8ade c000000000f57400 c000000001817c28 [ 0.170985][ T1] GPR24: c00000000176dc80 c00000007e3c0890 c00000007e3cfe00 0000000000000000 [ 0.170985][ T1] GPR28: c000000001772310 c00000007e011900 c00000007e3c0800 0000000000000001 [ 0.172750][ T1] NIP [c00000000018c128] build_sched_domains+0x808/0x14b0 [ 0.172900][ T1] LR [c00000000018c0cc] build_sched_domains+0x7ac/0x14b0 [ 0.173186][ T1] Call Trace: [ 0.173484][ T1] [c00000007e343b10] [c00000000018bfe8] build_sched_domains+0x6c8/0x14b0 (unreliable) [ 0.173821][ T1] [c00000007e343c50] [c00000000018dcdc] sched_init_domains+0xec/0x130 [ 0.174037][ T1] [c00000007e343ca0] [c0000000010d59d8] sched_init_smp+0x50/0xc4 [ 0.174207][ T1] [c00000007e343cd0] [c0000000010b45c4] kernel_init_freeable+0x1b4/0x378 [ 0.174378][ T1] [c00000007e343db0] [c0000000000129fc] kernel_init+0x24/0x158 [ 0.174740][ T1] [c00000007e343e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.175050][ T1] Instruction dump: [ 0.175626][ T1] 554905ee 71480040 7d2907b4 4182016c 2c290000 3920006e 913e002c 41820034 [ 0.175841][ T1] 7c6307b4 e9300020 78631f24 7d58182a <7d2a482a> f93e0080 7d404828 314a0001 [ 0.178340][ T1] ---[ end trace 6876b88dd1d4b3bb ]--- [ 0.178512][ T1] [ 1.180458][ T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
That's qemu:
qemu-system-ppc64 -nographic -vga none -M pseries -cpu POWER8 \
-kernel build~/vmlinux \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1 \
-smp 2,sockets=2,maxcpus=2 \
On mambo I get:
[ 0.005069][ T1] smp: Bringing up secondary CPUs ... [ 0.011656][ T1] smp: Brought up 2 nodes, 8 CPUs [ 0.011682][ T1] numa: Node 0 CPUs: 0-3 [ 0.011709][ T1] numa: Node 1 CPUs: 4-7 [ 0.012015][ T1] BUG: arch topology borken [ 0.012040][ T1] the SMT domain not a subset of the CACHE domain [ 0.012107][ T1] BUG: Unable to handle kernel data access on read at 0x80000001012e7398 [ 0.012142][ T1] Faulting instruction address: 0xc0000000001aa4f0 [ 0.012174][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.012206][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV [ 0.012236][ T1] Modules linked in: [ 0.012264][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #1 [ 0.012304][ T1] NIP: c0000000001aa4f0 LR: c0000000001aa498 CTR: 0000000000000000 [ 0.012341][ T1] REGS: c0000000ef583880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.012379][ T1] MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00040000 [ 0.012439][ T1] CFAR: c0000000000101b0 IRQMASK: 0 [ 0.012439][ T1] GPR00: 0000000000000000 c0000000ef583b10 c0000000017fd000 0000000000004000 [ 0.012439][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000000 0000000000000000 [ 0.012439][ T1] GPR08: 0000000000000000 c0000000012eb398 c0000000ffffc000 0000000000000000 [ 0.012439][ T1] GPR12: 0000000000000020 c0000000019f0000 00000000ffff8ad1 0000000000000000 [ 0.012439][ T1] GPR16: c0000000ef068658 c0000000018d7ba8 0000000000000008 c000000001690bb8 [ 0.012439][ T1] GPR20: c00000000182dc80 c0000000ef06be90 00000000ffff8ad1 c000000001014aa8 [ 0.012439][ T1] GPR24: 0000000000000917 c0000000ef068e00 0000000000000000 c0000000ef06be00 [ 0.012439][ T1] GPR28: 0000000000000001 c0000000ef068640 c0000000ef4a1800 c000000001832310 [ 0.012774][ T1] NIP [c0000000001aa4f0] build_sched_domains+0x5c0/0x14f0 [ 0.012812][ T1] LR [c0000000001aa498] build_sched_domains+0x568/0x14f0 [ 0.012842][ T1] Call Trace: [ 0.012872][ T1] [c0000000ef583b10] [c0000000001aa3b4] build_sched_domains+0x484/0x14f0 (unreliable) [ 0.012922][ T1] [c0000000ef583c50] [c0000000001ac3d8] sched_init_domains+0xd8/0x120 [ 0.012966][ T1] [c0000000ef583ca0] [c0000000011962d0] sched_init_smp+0x50/0xc4 [ 0.013008][ T1] [c0000000ef583cd0] [c00000000117451c] kernel_init_freeable+0x1b4/0x378 [ 0.013051][ T1] [c0000000ef583db0] [c000000000012994] kernel_init+0x2c/0x158 [ 0.013092][ T1] [c0000000ef583e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.013128][ T1] Instruction dump: [ 0.013151][ T1] e93b003a 712a0040 552a05ee 418203c4 2c2a0000 3920006e 913b002c 41820034 [ 0.013206][ T1] 7c6307b4 e93d0020 78631f24 7d54182a <7d2a482a> f93b0080 7d404828 314a0001 [ 0.013267][ T1] ---[ end trace 1bf5f6f38a9fd096 ]---
Did I miss a lead-up patch?
See here for what I have applied:
https://github.com/linuxppc/linux/commits/next-test
cheers
Re: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
Quoted 49 lines · Michael Ellerman
Quoted 5 lines · Srikar Dronamraju
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of
cpu_sibling_mask.Lets stop that assumption.
cpu_l2_cache_maskis a superset ofcpu_sibling_maskif and only ifshared_cachesis set.I'm seeing oopses with this:
[ 0.117392][ T1] smp: Bringing up secondary CPUs ... [ 0.156515][ T1] smp: Brought up 2 nodes, 2 CPUs [ 0.158265][ T1] numa: Node 0 CPUs: 0 [ 0.158520][ T1] numa: Node 1 CPUs: 1 [ 0.167453][ T1] BUG: Unable to handle kernel data access on read at 0x8000000041228298 [ 0.167992][ T1] Faulting instruction address: 0xc00000000018c128 [ 0.168817][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.168964][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries [ 0.169417][ T1] Modules linked in: [ 0.170047][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #209 [ 0.170305][ T1] NIP: c00000000018c128 LR: c00000000018c0cc CTR: c00000000004dce0 [ 0.170498][ T1] REGS: c00000007e343880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.170602][ T1] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00000000 [ 0.170985][ T1] CFAR: c00000000018c288 IRQMASK: 0 [ 0.170985][ T1] GPR00: 0000000000000000 c00000007e343b10 c00000000173e400 0000000000004000 [ 0.170985][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000800 0000000000000000 [ 0.170985][ T1] GPR08: 0000000000000000 c00000000122c298 c00000003fffc000 c00000007fd05ce8 [ 0.170985][ T1] GPR12: c00000007e0119f8 c000000001930000 00000000ffff8ade 0000000000000000 [ 0.170985][ T1] GPR16: c00000007e3c0640 0000000000000917 c00000007e3c0658 0000000000000008 [ 0.170985][ T1] GPR20: c0000000015d0bb8 00000000ffff8ade c000000000f57400 c000000001817c28 [ 0.170985][ T1] GPR24: c00000000176dc80 c00000007e3c0890 c00000007e3cfe00 0000000000000000 [ 0.170985][ T1] GPR28: c000000001772310 c00000007e011900 c00000007e3c0800 0000000000000001 [ 0.172750][ T1] NIP [c00000000018c128] build_sched_domains+0x808/0x14b0 [ 0.172900][ T1] LR [c00000000018c0cc] build_sched_domains+0x7ac/0x14b0 [ 0.173186][ T1] Call Trace: [ 0.173484][ T1] [c00000007e343b10] [c00000000018bfe8] build_sched_domains+0x6c8/0x14b0 (unreliable) [ 0.173821][ T1] [c00000007e343c50] [c00000000018dcdc] sched_init_domains+0xec/0x130 [ 0.174037][ T1] [c00000007e343ca0] [c0000000010d59d8] sched_init_smp+0x50/0xc4 [ 0.174207][ T1] [c00000007e343cd0] [c0000000010b45c4] kernel_init_freeable+0x1b4/0x378 [ 0.174378][ T1] [c00000007e343db0] [c0000000000129fc] kernel_init+0x24/0x158 [ 0.174740][ T1] [c00000007e343e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.175050][ T1] Instruction dump: [ 0.175626][ T1] 554905ee 71480040 7d2907b4 4182016c 2c290000 3920006e 913e002c 41820034 [ 0.175841][ T1] 7c6307b4 e9300020 78631f24 7d58182a <7d2a482a> f93e0080 7d404828 314a0001 [ 0.178340][ T1] ---[ end trace 6876b88dd1d4b3bb ]--- [ 0.178512][ T1] [ 1.180458][ T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000bThat's qemu:
Quoted 9 lines
qemu-system-ppc64 -nographic -vga none -M pseries -cpu POWER8 \
-kernel build~/vmlinux \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1 \
-smp 2,sockets=2,maxcpus=2 \
Thanks Michael for the report and also for identifying the patch and also giving an easy reproducer. That made my task easy. (My only problem was all my PowerKVM hosts had a old compiler that refuse to compile never kernels.)
So in this setup, CPU doesn't have a l2-cache. And in that scenario, we miss updating the l2-cache domain. Actually the initial patch had this exact code. However it was my mistake. I should have reassessed it before making changes suggested by Gautham.
Patch below. Do let me know if you want me to send the patch separately.
Quoted 32 lines
On mambo I get:
[ 0.005069][ T1] smp: Bringing up secondary CPUs ... [ 0.011656][ T1] smp: Brought up 2 nodes, 8 CPUs [ 0.011682][ T1] numa: Node 0 CPUs: 0-3 [ 0.011709][ T1] numa: Node 1 CPUs: 4-7 [ 0.012015][ T1] BUG: arch topology borken [ 0.012040][ T1] the SMT domain not a subset of the CACHE domain [ 0.012107][ T1] BUG: Unable to handle kernel data access on read at 0x80000001012e7398 [ 0.012142][ T1] Faulting instruction address: 0xc0000000001aa4f0 [ 0.012174][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.012206][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV [ 0.012236][ T1] Modules linked in: [ 0.012264][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #1 [ 0.012304][ T1] NIP: c0000000001aa4f0 LR: c0000000001aa498 CTR: 0000000000000000 [ 0.012341][ T1] REGS: c0000000ef583880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.012379][ T1] MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00040000 [ 0.012439][ T1] CFAR: c0000000000101b0 IRQMASK: 0 [ 0.012439][ T1] GPR00: 0000000000000000 c0000000ef583b10 c0000000017fd000 0000000000004000 [ 0.012439][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000000 0000000000000000 [ 0.012439][ T1] GPR08: 0000000000000000 c0000000012eb398 c0000000ffffc000 0000000000000000 [ 0.012439][ T1] GPR12: 0000000000000020 c0000000019f0000 00000000ffff8ad1 0000000000000000 [ 0.012439][ T1] GPR16: c0000000ef068658 c0000000018d7ba8 0000000000000008 c000000001690bb8 [ 0.012439][ T1] GPR20: c00000000182dc80 c0000000ef06be90 00000000ffff8ad1 c000000001014aa8 [ 0.012439][ T1] GPR24: 0000000000000917 c0000000ef068e00 0000000000000000 c0000000ef06be00 [ 0.012439][ T1] GPR28: 0000000000000001 c0000000ef068640 c0000000ef4a1800 c000000001832310 [ 0.012774][ T1] NIP [c0000000001aa4f0] build_sched_domains+0x5c0/0x14f0 [ 0.012812][ T1] LR [c0000000001aa498] build_sched_domains+0x568/0x14f0 [ 0.012842][ T1] Call Trace: [ 0.012872][ T1] [c0000000ef583b10] [c0000000001aa3b4] build_sched_domains+0x484/0x14f0 (unreliable) [ 0.012922][ T1] [c0000000ef583c50] [c0000000001ac3d8] sched_init_domains+0xd8/0x120
Quoted 9 lines
[ 0.012966][ T1] [c0000000ef583ca0] [c0000000011962d0] sched_init_smp+0x50/0xc4 [ 0.013008][ T1] [c0000000ef583cd0] [c00000000117451c] kernel_init_freeable+0x1b4/0x378 [ 0.013051][ T1] [c0000000ef583db0] [c000000000012994] kernel_init+0x2c/0x158 [ 0.013092][ T1] [c0000000ef583e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.013128][ T1] Instruction dump: [ 0.013151][ T1] e93b003a 712a0040 552a05ee 418203c4 2c2a0000 3920006e 913b002c 41820034 [ 0.013206][ T1] 7c6307b4 e93d0020 78631f24 7d54182a <7d2a482a> f93b0080 7d404828 314a0001 [ 0.013267][ T1] ---[ end trace 1bf5f6f38a9fd096 ]---
I haven't tried Mambo. But the problem report looks similar.
Quoted 3 lines
Did I miss a lead-up patch?
No
Signature · 42 lines
Thanks and Regards Srikar Dronamraju ------------------------->8--------------------------------------------8<------------ From b25d47b01b7195b1df19083a4043fa6a87a901a3 Mon Sep 17 00:00:00 2001 From: Srikar Dronamraju <[email protected]> Date: Thu, 9 Jul 2020 13:33:38 +0530 Subject: [PATCH v5.1 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of cpu_sibling_mask. Lets stop that assumption. cpu_l2_cache_mask is a superset of cpu_sibling_mask if and only if shared_caches is set. Cc: linuxppc-dev <[email protected]> Cc: LKML <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Anton Blanchard <[email protected]> Cc: Oliver O'Halloran <[email protected]> Cc: Nathan Lynch <[email protected]> Cc: Michael Neuling <[email protected]> Cc: Gautham R Shenoy <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Jordan Niethe <[email protected]> Cc: Vaidyanathan Srinivasan <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Signed-off-by: Srikar Dronamraju <[email protected]> --- Changelog v1 -> v2: Set cpumask after verifying l2-cache. (Gautham) Changelog v5 -> v5.1: Set cpumask before verifying l2-cache. (Michael Ellerman) arch/powerpc/kernel/smp.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
arch/powerpc/kernel/smp.c +15 -13
@@ -1185,6 +1185,7 @@ static bool update_mask_by_l2(int cpu, struct cpumask *(*mask_fn)(int))struct device_node *l2_cache, *np;int i; +cpumask_set_cpu (cpu,mask_fn (cpu)); l2_cache =cpu_to_l2cache (cpu);if (!l2_cache)return false;
@@ -1271,29 +1272,30 @@ static void add_cpu_to_masks(int cpu)* add it to it's own thread sibling mask. */ cpumask_set_cpu (cpu,cpu_sibling_mask (cpu)); +cpumask_set_cpu (cpu,cpu_core_mask (cpu));for (i = first_thread; i < first_thread + threads_per_core; i++)if (cpu_online (i))set_cpus_related (i, cpu, cpu_sibling_mask);add_cpu_to_smallcore_masks (cpu); -/* -* Copy the thread sibling mask into the cache sibling mask -* and mark any CPUs that share an L2 with this CPU. -*/ -for_each_cpu (i,cpu_sibling_mask (cpu)) -set_cpus_related (cpu, i, cpu_l2_cache_mask);update_mask_by_l2 (cpu, cpu_l2_cache_mask); -/* -* Copy the cache sibling mask into core sibling mask and mark -* any CPUs on the same chip as this CPU. -*/ -for_each_cpu (i,cpu_l2_cache_mask (cpu)) -set_cpus_related (cpu, i, cpu_core_mask); +if (pkg_id ==-1 ) { +struct cpumask *(*mask)(int ) = cpu_sibling_mask; + +/* +* Copy the sibling mask into core sibling mask and +* mark any CPUs on the same chip as this CPU. +*/ +if (shared_caches) + mask = cpu_l2_cache_mask; + +for_each_cpu (i,mask (cpu)) +set_cpus_related (cpu, i, cpu_core_mask); -if (pkg_id ==-1 )return ; + }for_each_cpu (i, cpu_online_mask)if (get_physical_package_id (i) == pkg_id)
Signature · 1 line
2.17.1
Michael Ellerman
reviewerRe: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
Quoted 113 lines · Srikar Dronamraju
Quoted 49 lines · Michael Ellerman
Quoted 5 lines · Srikar Dronamraju
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of
cpu_sibling_mask.Lets stop that assumption.
cpu_l2_cache_maskis a superset ofcpu_sibling_maskif and only ifshared_cachesis set.I'm seeing oopses with this:
[ 0.117392][ T1] smp: Bringing up secondary CPUs ... [ 0.156515][ T1] smp: Brought up 2 nodes, 2 CPUs [ 0.158265][ T1] numa: Node 0 CPUs: 0 [ 0.158520][ T1] numa: Node 1 CPUs: 1 [ 0.167453][ T1] BUG: Unable to handle kernel data access on read at 0x8000000041228298 [ 0.167992][ T1] Faulting instruction address: 0xc00000000018c128 [ 0.168817][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.168964][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries [ 0.169417][ T1] Modules linked in: [ 0.170047][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #209 [ 0.170305][ T1] NIP: c00000000018c128 LR: c00000000018c0cc CTR: c00000000004dce0 [ 0.170498][ T1] REGS: c00000007e343880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.170602][ T1] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00000000 [ 0.170985][ T1] CFAR: c00000000018c288 IRQMASK: 0 [ 0.170985][ T1] GPR00: 0000000000000000 c00000007e343b10 c00000000173e400 0000000000004000 [ 0.170985][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000800 0000000000000000 [ 0.170985][ T1] GPR08: 0000000000000000 c00000000122c298 c00000003fffc000 c00000007fd05ce8 [ 0.170985][ T1] GPR12: c00000007e0119f8 c000000001930000 00000000ffff8ade 0000000000000000 [ 0.170985][ T1] GPR16: c00000007e3c0640 0000000000000917 c00000007e3c0658 0000000000000008 [ 0.170985][ T1] GPR20: c0000000015d0bb8 00000000ffff8ade c000000000f57400 c000000001817c28 [ 0.170985][ T1] GPR24: c00000000176dc80 c00000007e3c0890 c00000007e3cfe00 0000000000000000 [ 0.170985][ T1] GPR28: c000000001772310 c00000007e011900 c00000007e3c0800 0000000000000001 [ 0.172750][ T1] NIP [c00000000018c128] build_sched_domains+0x808/0x14b0 [ 0.172900][ T1] LR [c00000000018c0cc] build_sched_domains+0x7ac/0x14b0 [ 0.173186][ T1] Call Trace: [ 0.173484][ T1] [c00000007e343b10] [c00000000018bfe8] build_sched_domains+0x6c8/0x14b0 (unreliable) [ 0.173821][ T1] [c00000007e343c50] [c00000000018dcdc] sched_init_domains+0xec/0x130 [ 0.174037][ T1] [c00000007e343ca0] [c0000000010d59d8] sched_init_smp+0x50/0xc4 [ 0.174207][ T1] [c00000007e343cd0] [c0000000010b45c4] kernel_init_freeable+0x1b4/0x378 [ 0.174378][ T1] [c00000007e343db0] [c0000000000129fc] kernel_init+0x24/0x158 [ 0.174740][ T1] [c00000007e343e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.175050][ T1] Instruction dump: [ 0.175626][ T1] 554905ee 71480040 7d2907b4 4182016c 2c290000 3920006e 913e002c 41820034 [ 0.175841][ T1] 7c6307b4 e9300020 78631f24 7d58182a <7d2a482a> f93e0080 7d404828 314a0001 [ 0.178340][ T1] ---[ end trace 6876b88dd1d4b3bb ]--- [ 0.178512][ T1] [ 1.180458][ T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000bThat's qemu:
Quoted 9 lines
qemu-system-ppc64 -nographic -vga none -M pseries -cpu POWER8 \
-kernel build~/vmlinux \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1 \
-smp 2,sockets=2,maxcpus=2 \Thanks Michael for the report and also for identifying the patch and also giving an easy reproducer. That made my task easy. (My only problem was all my PowerKVM hosts had a old compiler that refuse to compile never kernels.)
So in this setup, CPU doesn't have a l2-cache. And in that scenario, we miss updating the l2-cache domain. Actually the initial patch had this exact code. However it was my mistake. I should have reassessed it before making changes suggested by Gautham.
Patch below. Do let me know if you want me to send the patch separately.
Quoted 31 lines
On mambo I get:
[ 0.005069][ T1] smp: Bringing up secondary CPUs ... [ 0.011656][ T1] smp: Brought up 2 nodes, 8 CPUs [ 0.011682][ T1] numa: Node 0 CPUs: 0-3 [ 0.011709][ T1] numa: Node 1 CPUs: 4-7 [ 0.012015][ T1] BUG: arch topology borken [ 0.012040][ T1] the SMT domain not a subset of the CACHE domain [ 0.012107][ T1] BUG: Unable to handle kernel data access on read at 0x80000001012e7398 [ 0.012142][ T1] Faulting instruction address: 0xc0000000001aa4f0 [ 0.012174][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.012206][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV [ 0.012236][ T1] Modules linked in: [ 0.012264][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #1 [ 0.012304][ T1] NIP: c0000000001aa4f0 LR: c0000000001aa498 CTR: 0000000000000000 [ 0.012341][ T1] REGS: c0000000ef583880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.012379][ T1] MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00040000 [ 0.012439][ T1] CFAR: c0000000000101b0 IRQMASK: 0 [ 0.012439][ T1] GPR00: 0000000000000000 c0000000ef583b10 c0000000017fd000 0000000000004000 [ 0.012439][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000000 0000000000000000 [ 0.012439][ T1] GPR08: 0000000000000000 c0000000012eb398 c0000000ffffc000 0000000000000000 [ 0.012439][ T1] GPR12: 0000000000000020 c0000000019f0000 00000000ffff8ad1 0000000000000000 [ 0.012439][ T1] GPR16: c0000000ef068658 c0000000018d7ba8 0000000000000008 c000000001690bb8 [ 0.012439][ T1] GPR20: c00000000182dc80 c0000000ef06be90 00000000ffff8ad1 c000000001014aa8 [ 0.012439][ T1] GPR24: 0000000000000917 c0000000ef068e00 0000000000000000 c0000000ef06be00 [ 0.012439][ T1] GPR28: 0000000000000001 c0000000ef068640 c0000000ef4a1800 c000000001832310 [ 0.012774][ T1] NIP [c0000000001aa4f0] build_sched_domains+0x5c0/0x14f0 [ 0.012812][ T1] LR [c0000000001aa498] build_sched_domains+0x568/0x14f0 [ 0.012842][ T1] Call Trace: [ 0.012872][ T1] [c0000000ef583b10] [c0000000001aa3b4] build_sched_domains+0x484/0x14f0 (unreliable) [ 0.012922][ T1] [c0000000ef583c50] [c0000000001ac3d8] sched_init_domains+0xd8/0x120Quoted 9 lines
[ 0.012966][ T1] [c0000000ef583ca0] [c0000000011962d0] sched_init_smp+0x50/0xc4 [ 0.013008][ T1] [c0000000ef583cd0] [c00000000117451c] kernel_init_freeable+0x1b4/0x378 [ 0.013051][ T1] [c0000000ef583db0] [c000000000012994] kernel_init+0x2c/0x158 [ 0.013092][ T1] [c0000000ef583e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.013128][ T1] Instruction dump: [ 0.013151][ T1] e93b003a 712a0040 552a05ee 418203c4 2c2a0000 3920006e 913b002c 41820034 [ 0.013206][ T1] 7c6307b4 e93d0020 78631f24 7d54182a <7d2a482a> f93b0080 7d404828 314a0001 [ 0.013267][ T1] ---[ end trace 1bf5f6f38a9fd096 ]---
Quoted 1 line
I haven't tried Mambo. But the problem report looks similar.
The patch fixes qemu, and I don't see the crash on mambo, but I still see:
[ 0.010536] smp: Bringing up secondary CPUs ... [ 0.019189] smp: Brought up 2 nodes, 8 CPUs [ 0.019210] numa: Node 0 CPUs: 0-3 [ 0.019235] numa: Node 1 CPUs: 4-7 [ 0.023669] BUG: arch topology borken [ 0.023690] the SMT domain not a subset of the CACHE domain [ 0.023726] BUG: arch topology borken [ 0.023747] the CACHE domain not a subset of the MC domain [ 0.023808] BUG: arch topology borken [ 0.023829] the SMT domain not a subset of the CACHE domain [ 0.023865] BUG: arch topology borken [ 0.023887] the CACHE domain not a subset of the MC domain [ 0.023948] BUG: arch topology borken [ 0.023969] the SMT domain not a subset of the CACHE domain [ 0.024005] BUG: arch topology borken [ 0.024026] the CACHE domain not a subset of the MC domain [ 0.024087] BUG: arch topology borken [ 0.024108] the SMT domain not a subset of the CACHE domain [ 0.024144] BUG: arch topology borken [ 0.024165] the CACHE domain not a subset of the MC domain [ 0.024227] BUG: arch topology borken [ 0.024248] the SMT domain not a subset of the CACHE domain [ 0.024284] BUG: arch topology borken [ 0.024305] the CACHE domain not a subset of the MC domain [ 0.024366] BUG: arch topology borken [ 0.024387] the SMT domain not a subset of the CACHE domain [ 0.024423] BUG: arch topology borken [ 0.024444] the CACHE domain not a subset of the MC domain [ 0.024505] BUG: arch topology borken [ 0.024527] the SMT domain not a subset of the CACHE domain [ 0.024563] BUG: arch topology borken [ 0.024584] the CACHE domain not a subset of the MC domain [ 0.024645] BUG: arch topology borken [ 0.024666] the SMT domain not a subset of the CACHE domain [ 0.024702] BUG: arch topology borken [ 0.024723] the CACHE domain not a subset of the MC domain
That's the p9 mambo model, using skiboot.tcl from skiboot, with CPUS=2, THREADS=4 and MAMBO_NUMA=1.
Node layout is:
[ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x00000000ffffffff] [ 0.000000] node 1: [mem 0x0000200000000000-0x00002000ffffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ffffffff] [ 0.000000] On node 0 totalpages: 65536 [ 0.000000] Initmem setup node 1 [mem 0x0000200000000000-0x00002000ffffffff] [ 0.000000] On node 1 totalpages: 65536
There aren't any l2-cache properties in the device-tree under cpus.
I'll try and have a closer look tonight.
cheers
Re: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
Quoted 29 lines · Michael Ellerman
Quoted 11 lines · Srikar Dronamraju
Quoted 9 lines · Michael Ellerman
Quoted 5 lines · Srikar Dronamraju
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of
cpu_sibling_mask.Lets stop that assumption.
cpu_l2_cache_maskis a superset ofcpu_sibling_maskif and only ifshared_cachesis set.I'm seeing oopses with this:
The patch fixes qemu, and I don't see the crash on mambo, but I still see:
[ 0.010536] smp: Bringing up secondary CPUs ... [ 0.019189] smp: Brought up 2 nodes, 8 CPUs [ 0.019210] numa: Node 0 CPUs: 0-3 [ 0.019235] numa: Node 1 CPUs: 4-7 [ 0.024444] the CACHE domain not a subset of the MC domain [ 0.024505] BUG: arch topology borken [ 0.024527] the SMT domain not a subset of the CACHE domain [ 0.024563] BUG: arch topology borken [ 0.024584] the CACHE domain not a subset of the MC domain [ 0.024645] BUG: arch topology borken [ 0.024666] the SMT domain not a subset of the CACHE domain [ 0.024702] BUG: arch topology borken [ 0.024723] the CACHE domain not a subset of the MC domain
Quoted 3 lines
That's the p9 mambo model, using skiboot.tcl from skiboot, with CPUS=2, THREADS=4 and MAMBO_NUMA=1.
I was able to reproduce with
qemu-system-ppc64 -nographic -vga none -M pseries -cpu POWER8 \
-kernel build~/vmlinux \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1 \
-smp 8,threads=4,sockets=2,maxcpus=8 \
If the CPU doesn't have a l2-cache element, then CPU not only has to set itself in the cpu_l2_cache but also the siblings. Otherwise it will so happen that the Siblings will have 4 Cpus set, and the Cache domain will have just one cpu set, leading to this BUG message.
Patch follows this mail.
Quoted 16 lines
Node layout is:
[ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x00000000ffffffff] [ 0.000000] node 1: [mem 0x0000200000000000-0x00002000ffffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ffffffff] [ 0.000000] On node 0 totalpages: 65536 [ 0.000000] Initmem setup node 1 [mem 0x0000200000000000-0x00002000ffffffff] [ 0.000000] On node 1 totalpages: 65536There aren't any l2-cache properties in the device-tree under cpus.
I'll try and have a closer look tonight.
cheers
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Srikar Dronamraju
Reviewed-by Gautham R. ShenoyRe: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
In reply to Michael EllermanFix to make it work where CPUs dont have a l2-cache element.
------------>8-----------------------------------------8<---------------------
From b25d47b01b7195b1df19083a4043fa6a87a901a3 Mon Sep 17 00:00:00 2001
From: Srikar Dronamraju <[email protected]>
Date: Thu, 9 Jul 2020 13:33:38 +0530
Subject: [PATCH v5.2 05/10] powerpc/smp: Dont assume l2-cache to be superset of
sibling
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of cpu_sibling_mask.
Lets stop that assumption. cpu_l2_cache_mask is a superset of cpu_sibling_mask if and only if shared_caches is set.
---
Changelog v1 -> v2:
Set cpumask after verifying l2-cache. (Gautham)
Changelog v5 -> v5.2:
If cpu has no l2-cache set cpumask as per its
sibling mask. (Michael Ellerman)
arch/powerpc/kernel/smp.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
arch/powerpc/kernel/smp.c +29 -14
@@ -1186,9 +1186,23 @@ static bool update_mask_by_l2(int cpu, struct cpumask *(*mask_fn)(int))int i; l2_cache =cpu_to_l2cache (cpu); -if (!l2_cache) +if (!l2_cache) { +struct cpumask *(*sibling_mask)(int ) = cpu_sibling_mask; + +/* +* If no l2cache for this CPU, assume all siblings to share +* cache with this CPU. +*/ +if (has_big_cores) + sibling_mask = cpu_smallcore_mask; + +for_each_cpu (i,sibling_mask (cpu)) +set_cpus_related (cpu, i, cpu_l2_cache_mask); +return false; + } +cpumask_set_cpu (cpu,mask_fn (cpu));for_each_cpu (i, cpu_online_mask) {/* * when updating the marks the current CPU has not been marked
@@ -1271,29 +1285,30 @@ static void add_cpu_to_masks(int cpu)* add it to it's own thread sibling mask. */ cpumask_set_cpu (cpu,cpu_sibling_mask (cpu)); +cpumask_set_cpu (cpu,cpu_core_mask (cpu));for (i = first_thread; i < first_thread + threads_per_core; i++)if (cpu_online (i))set_cpus_related (i, cpu, cpu_sibling_mask);add_cpu_to_smallcore_masks (cpu); -/* -* Copy the thread sibling mask into the cache sibling mask -* and mark any CPUs that share an L2 with this CPU. -*/ -for_each_cpu (i,cpu_sibling_mask (cpu)) -set_cpus_related (cpu, i, cpu_l2_cache_mask);update_mask_by_l2 (cpu, cpu_l2_cache_mask); -/* -* Copy the cache sibling mask into core sibling mask and mark -* any CPUs on the same chip as this CPU. -*/ -for_each_cpu (i,cpu_l2_cache_mask (cpu)) -set_cpus_related (cpu, i, cpu_core_mask); +if (pkg_id ==-1 ) { +struct cpumask *(*mask)(int ) = cpu_sibling_mask; + +/* +* Copy the sibling mask into core sibling mask and +* mark any CPUs on the same chip as this CPU. +*/ +if (shared_caches) + mask = cpu_l2_cache_mask; + +for_each_cpu (i,mask (cpu)) +set_cpus_related (cpu, i, cpu_core_mask); -if (pkg_id ==-1 )return ; + }for_each_cpu (i, cpu_online_mask)if (get_physical_package_id (i) == pkg_id)
Signature · 1 line
2.17.1
Re: [PATCH v5 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling
In reply to Michael EllermanQuoted 49 lines · Michael Ellerman
Quoted 5 lines · Srikar Dronamraju
Current code assumes that cpumask of cpus sharing a l2-cache mask will always be a superset of
cpu_sibling_mask.Lets stop that assumption.
cpu_l2_cache_maskis a superset ofcpu_sibling_maskif and only ifshared_cachesis set.I'm seeing oopses with this:
[ 0.117392][ T1] smp: Bringing up secondary CPUs ... [ 0.156515][ T1] smp: Brought up 2 nodes, 2 CPUs [ 0.158265][ T1] numa: Node 0 CPUs: 0 [ 0.158520][ T1] numa: Node 1 CPUs: 1 [ 0.167453][ T1] BUG: Unable to handle kernel data access on read at 0x8000000041228298 [ 0.167992][ T1] Faulting instruction address: 0xc00000000018c128 [ 0.168817][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.168964][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries [ 0.169417][ T1] Modules linked in: [ 0.170047][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #209 [ 0.170305][ T1] NIP: c00000000018c128 LR: c00000000018c0cc CTR: c00000000004dce0 [ 0.170498][ T1] REGS: c00000007e343880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.170602][ T1] MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00000000 [ 0.170985][ T1] CFAR: c00000000018c288 IRQMASK: 0 [ 0.170985][ T1] GPR00: 0000000000000000 c00000007e343b10 c00000000173e400 0000000000004000 [ 0.170985][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000800 0000000000000000 [ 0.170985][ T1] GPR08: 0000000000000000 c00000000122c298 c00000003fffc000 c00000007fd05ce8 [ 0.170985][ T1] GPR12: c00000007e0119f8 c000000001930000 00000000ffff8ade 0000000000000000 [ 0.170985][ T1] GPR16: c00000007e3c0640 0000000000000917 c00000007e3c0658 0000000000000008 [ 0.170985][ T1] GPR20: c0000000015d0bb8 00000000ffff8ade c000000000f57400 c000000001817c28 [ 0.170985][ T1] GPR24: c00000000176dc80 c00000007e3c0890 c00000007e3cfe00 0000000000000000 [ 0.170985][ T1] GPR28: c000000001772310 c00000007e011900 c00000007e3c0800 0000000000000001 [ 0.172750][ T1] NIP [c00000000018c128] build_sched_domains+0x808/0x14b0 [ 0.172900][ T1] LR [c00000000018c0cc] build_sched_domains+0x7ac/0x14b0 [ 0.173186][ T1] Call Trace: [ 0.173484][ T1] [c00000007e343b10] [c00000000018bfe8] build_sched_domains+0x6c8/0x14b0 (unreliable) [ 0.173821][ T1] [c00000007e343c50] [c00000000018dcdc] sched_init_domains+0xec/0x130 [ 0.174037][ T1] [c00000007e343ca0] [c0000000010d59d8] sched_init_smp+0x50/0xc4 [ 0.174207][ T1] [c00000007e343cd0] [c0000000010b45c4] kernel_init_freeable+0x1b4/0x378 [ 0.174378][ T1] [c00000007e343db0] [c0000000000129fc] kernel_init+0x24/0x158 [ 0.174740][ T1] [c00000007e343e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.175050][ T1] Instruction dump: [ 0.175626][ T1] 554905ee 71480040 7d2907b4 4182016c 2c290000 3920006e 913e002c 41820034 [ 0.175841][ T1] 7c6307b4 e9300020 78631f24 7d58182a <7d2a482a> f93e0080 7d404828 314a0001 [ 0.178340][ T1] ---[ end trace 6876b88dd1d4b3bb ]--- [ 0.178512][ T1] [ 1.180458][ T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000bThat's qemu:
Quoted 8 lines
qemu-system-ppc64 -nographic -vga none -M pseries -cpu POWER8 \
-kernel build~/vmlinux \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1 \
-smp 2,sockets=2,maxcpus=2 \
PowerKVM guest vCPUs does not yet have L2 and L3 cache elements I had this bug raised some time ago, probably related?
https://bugs.launchpad.net/qemu/+bug/1774605
Regards,
-Satheesh.
Quoted 49 lines
On mambo I get:
[ 0.005069][ T1] smp: Bringing up secondary CPUs ... [ 0.011656][ T1] smp: Brought up 2 nodes, 8 CPUs [ 0.011682][ T1] numa: Node 0 CPUs: 0-3 [ 0.011709][ T1] numa: Node 1 CPUs: 4-7 [ 0.012015][ T1] BUG: arch topology borken [ 0.012040][ T1] the SMT domain not a subset of the CACHE domain [ 0.012107][ T1] BUG: Unable to handle kernel data access on read at 0x80000001012e7398 [ 0.012142][ T1] Faulting instruction address: 0xc0000000001aa4f0 [ 0.012174][ T1] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.012206][ T1] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV [ 0.012236][ T1] Modules linked in: [ 0.012264][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc2-00095-g7430ad5aa700 #1 [ 0.012304][ T1] NIP: c0000000001aa4f0 LR: c0000000001aa498 CTR: 0000000000000000 [ 0.012341][ T1] REGS: c0000000ef583880 TRAP: 0380 Not tainted (5.9.0-rc2-00095-g7430ad5aa700) [ 0.012379][ T1] MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 44002222 XER: 00040000 [ 0.012439][ T1] CFAR: c0000000000101b0 IRQMASK: 0 [ 0.012439][ T1] GPR00: 0000000000000000 c0000000ef583b10 c0000000017fd000 0000000000004000 [ 0.012439][ T1] GPR04: 0000000000000000 0000000000000800 0000000000000000 0000000000000000 [ 0.012439][ T1] GPR08: 0000000000000000 c0000000012eb398 c0000000ffffc000 0000000000000000 [ 0.012439][ T1] GPR12: 0000000000000020 c0000000019f0000 00000000ffff8ad1 0000000000000000 [ 0.012439][ T1] GPR16: c0000000ef068658 c0000000018d7ba8 0000000000000008 c000000001690bb8 [ 0.012439][ T1] GPR20: c00000000182dc80 c0000000ef06be90 00000000ffff8ad1 c000000001014aa8 [ 0.012439][ T1] GPR24: 0000000000000917 c0000000ef068e00 0000000000000000 c0000000ef06be00 [ 0.012439][ T1] GPR28: 0000000000000001 c0000000ef068640 c0000000ef4a1800 c000000001832310 [ 0.012774][ T1] NIP [c0000000001aa4f0] build_sched_domains+0x5c0/0x14f0 [ 0.012812][ T1] LR [c0000000001aa498] build_sched_domains+0x568/0x14f0 [ 0.012842][ T1] Call Trace: [ 0.012872][ T1] [c0000000ef583b10] [c0000000001aa3b4] build_sched_domains+0x484/0x14f0 (unreliable) [ 0.012922][ T1] [c0000000ef583c50] [c0000000001ac3d8] sched_init_domains+0xd8/0x120 [ 0.012966][ T1] [c0000000ef583ca0] [c0000000011962d0] sched_init_smp+0x50/0xc4 [ 0.013008][ T1] [c0000000ef583cd0] [c00000000117451c] kernel_init_freeable+0x1b4/0x378 [ 0.013051][ T1] [c0000000ef583db0] [c000000000012994] kernel_init+0x2c/0x158 [ 0.013092][ T1] [c0000000ef583e20] [c00000000000d9d0] ret_from_kernel_thread+0x5c/0x6c [ 0.013128][ T1] Instruction dump: [ 0.013151][ T1] e93b003a 712a0040 552a05ee 418203c4 2c2a0000 3920006e 913b002c 41820034 [ 0.013206][ T1] 7c6307b4 e93d0020 78631f24 7d54182a <7d2a482a> f93b0080 7d404828 314a0001 [ 0.013267][ T1] ---[ end trace 1bf5f6f38a9fd096 ]---Did I miss a lead-up patch?
See here for what I have applied:
https://github.com/linuxppc/linux/commits/next-testcheers
PATCH v5 6/10 powerpc/smp: Optimize start_secondary
In reply to Srikar DronamrajuIn start_secondary, even if shared_cache was already set, system does a redundant match for cpumask. This redundant check can be removed by checking if shared_cache is already set.
While here, localize the sibling_mask variable to within the if condition.
---
Changelog v4 ->v5:
Retain cache domain, no need for generalization
(Michael Ellerman, Peter Zijlstra, Valentin Schneider, Gautham R. Shenoy)
Changelog v1 -> v2:
Moved shared_cache topology fixup to fixup_topology (Gautham)
arch/powerpc/kernel/smp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/powerpc/kernel/smp.c +11 -6
@@ -851,7 +851,7 @@ static int powerpc_shared_cache_flags(void)*/ static const struct cpumask *shared_cache_mask (int cpu) { -return cpu_l2_cache_mask (cpu); +return per_cpu (cpu_l2_cache_map, cpu); }#ifdef CONFIG_SCHED_SMT
@@ -1305,7 +1305,6 @@ static void add_cpu_to_masks(int cpu)void start_secondary (void *unused) {unsigned int cpu =smp_processor_id (); -struct cpumask *(*sibling_mask)(int ) = cpu_sibling_mask;mmgrab (&init_mm); current->active_mm = &init_mm;
@@ -1331,14 +1330,20 @@ void start_secondary(void *unused)/* Update topology CPU masks */ add_cpu_to_masks (cpu); -if (has_big_cores) - sibling_mask = cpu_smallcore_mask;/* * Check for any shared caches. Note that this must be done on a * per-core basis because one core in the pair might be disabled. */ -if (!cpumask_equal (cpu_l2_cache_mask (cpu),sibling_mask (cpu))) - shared_caches = true; +if (!shared_caches) { +struct cpumask *(*sibling_mask)(int ) = cpu_sibling_mask; +struct cpumask *mask =cpu_l2_cache_mask (cpu); + +if (has_big_cores) + sibling_mask = cpu_smallcore_mask; + +if (cpumask_weight (mask) >cpumask_weight (sibling_mask (cpu))) + shared_caches = true; + }set_numa_node (numa_cpu_lookup_table[cpu]);set_numa_mem (local_memory_node (numa_cpu_lookup_table[cpu]));
Signature · 1 line
2.18.2
Re: [PATCH v5 06/10] powerpc/smp: Optimize start_secondary
Hi Srikar,
Quoted 7 lines · Srikar Dronamraju
In
start_secondary, even ifshared_cachewas already set, system does a redundant match for cpumask. This redundant check can be removed by checking ifshared_cacheis already set.While here, localize the
sibling_maskvariable to within the if condition.
Quoted 15 lines
Cc linuxppc-dev <[email protected]>Cc LKML <[email protected]>Cc Michael Ellerman <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Anton Blanchard <[email protected]>Cc Oliver O'Halloran <[email protected]>Cc Nathan Lynch <[email protected]>Cc Michael Neuling <[email protected]>Cc Gautham R Shenoy <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Valentin Schneider <[email protected]>Cc Jordan Niethe <[email protected]>Cc Vaidyanathan Srinivasan <[email protected]>Signed-off-by Srikar Dronamraju <[email protected]>
The change looks good to me.
Quoted 61 lines
---
Changelog v4 ->v5:
Retain cache domain, no need for generalization
(Michael Ellerman, Peter Zijlstra, Valentin Schneider, Gautham R. Shenoy)Changelog v1 -> v2:
Movedshared_cachetopology fixup tofixup_topology(Gautham)arch/powerpc/kernel/smp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)arch/powerpc/kernel/smp.c +11
-6@@ -851,7 +851,7 @@ static int powerpc_shared_cache_flags(void)*/ static const struct cpumask *shared_cache_mask (int cpu) { -return cpu_l2_cache_mask (cpu); +return per_cpu (cpu_l2_cache_map, cpu); }#ifdef CONFIG_SCHED_SMT @@ -1305,7 +1305,6 @@ static void add_cpu_to_masks(int cpu)void start_secondary (void *unused) {unsigned int cpu =smp_processor_id (); -struct cpumask *(*sibling_mask)(int ) = cpu_sibling_mask;mmgrab (&init_mm); current->active_mm = &init_mm;@@ -1331,14 +1330,20 @@ void start_secondary(void *unused)/* Update topology CPU masks */ add_cpu_to_masks (cpu); -if (has_big_cores) - sibling_mask = cpu_smallcore_mask;/* * Check for any shared caches. Note that this must be done on a * per-core basis because one core in the pair might be disabled. */ -if (!cpumask_equal (cpu_l2_cache_mask (cpu),sibling_mask (cpu))) - shared_caches = true; +if (!shared_caches) { +struct cpumask *(*sibling_mask)(int ) = cpu_sibling_mask; +struct cpumask *mask =cpu_l2_cache_mask (cpu); + +if (has_big_cores) + sibling_mask = cpu_smallcore_mask; + +if (cpumask_weight (mask) >cpumask_weight (sibling_mask (cpu))) + shared_caches = true; + }set_numa_node (numa_cpu_lookup_table[cpu]);set_numa_mem (local_memory_node (numa_cpu_lookup_table[cpu]));Signature · 1 line
2.18.2
PATCH v5 7/10 powerpc/numa: Detect support for coregroup
In reply to Srikar DronamrajuAdd support for grouping cores based on the device-tree classification.
- The last domain in the associativity domains always refers to the core.
- If primary reference domain happens to be the penultimate domain in the associativity domains device-tree property, then there are no coregroups. However if its not a penultimate domain, then there are coregroups. There can be more than one coregroup. For now we would be interested in the last or the smallest coregroups, i.e one sub-group per DIE.
Currently there are no firmwares that are exposing this grouping. Hence allow the basis for grouping to be abstract. Once the firmware starts using this grouping, code would be added to detect the type of grouping and adjust the sd domain flags accordingly.
---
Changelog v4->v5:
Updated commit msg with current abstract nature of the coregroups
(Michael Ellerman)
Changelog v1 -> v2:
Explained Coregroup in commit msg (Michael Ellerman)
arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/kernel/smp.c | 1 + arch/powerpc/mm/numa.c | 34 +++++++++++++++++++++------------- 3 files changed, 23 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/smp.h +1 -0
@@ -28,6 +28,7 @@extern int boot_cpuid;extern int spinning_secondaries;extern u32 *cpu_to_phys_id; +extern bool coregroup_enabled;extern void cpu_die (void );extern int cpu_to_chip_id (int cpu);
arch/powerpc/kernel/smp.c +1 -0
@@ -74,6 +74,7 @@ static DEFINE_PER_CPU(int, cpu_state) = { 0 };struct task_struct *secondary_current;bool has_big_cores; +bool coregroup_enabled;DEFINE_PER_CPU (cpumask_var_t, cpu_sibling_map);DEFINE_PER_CPU (cpumask_var_t, cpu_smallcore_map);
arch/powerpc/mm/numa.c +21 -13
@@ -886,7 +886,9 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)static void __init find_possible_nodes (void ) {struct device_node *rtas; -u32 numnodes, i; +const __be32 *domains; +int prop_length, max_nodes; +u32 i;if (!numa_enabled)return ;
@@ -895,25 +897,31 @@ static void __init find_possible_nodes(void)if (!rtas)return ; -if (of_property_read_u32_index (rtas,"ibm,current-associativity-domains" , - min_common_depth, &numnodes)) { -/* -* ibm,current-associativity-domains is a fairly recent -* property. If it doesn't exist, then fallback on -* ibm,max-associativity-domains. Current denotes what the -* platform can support compared to max which denotes what the -* Hypervisor can support. -*/ -if (of_property_read_u32_index (rtas,"ibm,max-associativity-domains" , - min_common_depth, &numnodes)) +/* +* ibm,current-associativity-domains is a fairly recent property. If +* it doesn't exist, then fallback on ibm,max-associativity-domains. +* Current denotes what the platform can support compared to max +* which denotes what the Hypervisor can support. +*/ + domains =of_get_property (rtas,"ibm,current-associativity-domains" , + &prop_length); +if (!domains) { + domains =of_get_property (rtas,"ibm,max-associativity-domains" , + &prop_length); +if (!domains) goto out; } -for (i =0 ; i < numnodes; i++) { + max_nodes =of_read_number (&domains[min_common_depth],1 ); +for (i =0 ; i < max_nodes; i++) {if (!node_possible (i))node_set (i, node_possible_map); } + prop_length /=sizeof (int ); +if (prop_length > min_common_depth +2 ) + coregroup_enabled =1 ; + out:of_node_put (rtas); }
Signature · 1 line
2.18.2
PATCH v5 8/10 powerpc/smp: Allocate cpumask only after searching thread group
In reply to Srikar DronamrajuIf allocated earlier and the search fails, then cpu_l1_cache_map cpumask is unnecessarily cleared. However cpu_l1_cache_map can be allocated / cleared after we search thread group.
Please note CONFIG_CPUMASK_OFFSTACK is not set on Powerpc. Hence cpumask allocated by zalloc_cpumask_var_node is never freed.
---
Changelog v4 ->v5:
Updated commit msg on why cpumask need not be freed.
(Michael Ellerman)
arch/powerpc/kernel/smp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/kernel/smp.c +3 -4
@@ -789,10 +789,6 @@ static int init_cpu_l1_cache_map(int cpu)if (err) goto out; -zalloc_cpumask_var_node (&per_cpu (cpu_l1_cache_map, cpu), -GFP_KERNEL , -cpu_to_node (cpu)); - cpu_group_start =get_cpu_thread_group_start (cpu, &tg);if (unlikely (cpu_group_start ==-1 )) {
@@ -801,6 +797,9 @@ static int init_cpu_l1_cache_map(int cpu) goto out; } +zalloc_cpumask_var_node (&per_cpu (cpu_l1_cache_map, cpu), +GFP_KERNEL ,cpu_to_node (cpu)); +for (i = first_thread; i < first_thread + threads_per_core; i++) {int i_group_start =get_cpu_thread_group_start (i, &tg);
Signature · 1 line
2.18.2
PATCH v5 9/10 powerpc/smp: Create coregroup domain
In reply to Srikar DronamrajuAdd percpu coregroup maps and masks to create coregroup domain. If a coregroup doesn't exist, the coregroup domain will be degenerated in favour of SMT/CACHE domain. Do note this patch is only creating stubs for cpu_to_coregroup_id. The actual cpu_to_coregroup_id implementation would be in a subsequent patch.
---
Changelog v4 ->v5:
Updated commit msg to specify actual implementation of cpu_to_coregroup_id is in a subsequent patch (Michael Ellerman)
Changelog v3 ->v4:
if coregroup_support doesn't exist, update MC mask to the next smaller domain mask.
Changelog v2 -> v3:
Add optimization for mask updation under coregroup_support
Changelog v1 -> v2:
Moved coregroup topology fixup to fixup_topology (Gautham)
arch/powerpc/include/asm/topology.h | 10 ++++++ arch/powerpc/kernel/smp.c | 54 ++++++++++++++++++++++++++++- arch/powerpc/mm/numa.c | 5 +++ 3 files changed, 68 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/topology.h +10 -0
@@ -88,12 +88,22 @@ static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR )extern int find_and_online_cpu_nid (int cpu); +extern int cpu_to_coregroup_id (int cpu);#else static inline int find_and_online_cpu_nid (int cpu) {return 0 ; } +static inline int cpu_to_coregroup_id (int cpu) +{ +#ifdef CONFIG_SMP +return cpu_to_core_id (cpu); +#else +return 0 ; +#endif +} +#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ #include <asm-generic/topology.h>
arch/powerpc/kernel/smp.c +53 -1
109 lines not on this page · raw message
arch/powerpc/mm/numa.c +5 -0
@@ -1216,6 +1216,11 @@ int find_and_online_cpu_nid(int cpu)return new_nid; } +int cpu_to_coregroup_id (int cpu) +{ +return cpu_to_core_id (cpu); +} +static int topology_update_init (void ) { topology_inited =1 ;
Signature · 1 line
2.18.2
PATCH v5 10/10 powerpc/smp: Implement cpu_to_coregroup_id
In reply to Srikar DronamrajuLookup the coregroup id from the associativity array.
If unable to detect the coregroup id, fallback on the core id. This way, ensure sched_domain degenerates and an extra sched domain is not created.
Ideally this function should have been implemented in arch/powerpc/kernel/smp.c. However if its implemented in mm/numa.c, we don't need to find the primary domain again.
If the device-tree mentions more than one coregroup, then kernel implements only the last or the smallest coregroup, which currently corresponds to the penultimate domain in the device-tree.
---
Changelog v1 -> v2:
Move coregroup_enabled before getting associativity (Gautham)
arch/powerpc/mm/numa.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/powerpc/mm/numa.c +20 -0
@@ -1218,6 +1218,26 @@ int find_and_online_cpu_nid(int cpu)int cpu_to_coregroup_id (int cpu) { +__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 }; +int index; + +if (cpu <0 || cpu > nr_cpu_ids) +return -1 ; + +if (!coregroup_enabled) + goto out; + +if (!firmware_has_feature (FW_FEATURE_VPHN )) + goto out; + +if (vphn_get_associativity (cpu, associativity)) + goto out; + + index =of_read_number (associativity,1 ); +if (index > min_common_depth +1 ) +return of_read_number (&associativity[index -1 ],1 ); + +out:return cpu_to_core_id (cpu); }
Signature · 1 line
2.18.2
Michael Ellerman
AppliedQuoted 10 lines · Srikar Dronamraju
Changelog
v4->v5:
v4: http://lore.kernel.org/lkml/[email protected]/t/#uChangelog v4 ->v5:
powerpc/smp: Optimizestart_secondary
Retain cache domain, no need for generalization
(Michael Ellerman, Peter Zijlstra, Valentin Schneider, Gautham R. Shenoy)[...]
Applied to powerpc/next.
[01/10] powerpc/smp: Fix a warning under !NEED_MULTIPLE_NODES
https://git.kernel.org/powerpc/c/d0fd24bbd27619d7b8d4da26a19a2027931ae9fc [02/10] powerpc/smp: Merge Power9 topology with Power topology https://git.kernel.org/powerpc/c/2ef0ca54d97f40f7621d595ac5479bd7fa076bfa [03/10] powerpc/smp: Move powerpc_topology above https://git.kernel.org/powerpc/c/5e93f16ae48b728775496429c6db53d0bf8cdd9b [04/10] powerpc/smp: Move topology fixups into a new function https://git.kernel.org/powerpc/c/3c6032a8fe99547d31b2b57715e303a67d1b0c66 [05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling https://git.kernel.org/powerpc/c/f6606cfdfbcda00ce8a6e63c8fc13c93e73ac059 [06/10] powerpc/smp: Optimize start_secondary https://git.kernel.org/powerpc/c/caa8e29da59926bef099b46ab6280333d583e944 [07/10] powerpc/numa: Detect support for coregroup https://git.kernel.org/powerpc/c/f9f130ff2ec93c5949576bbfb168cc9530c23649 [08/10] powerpc/smp: Allocate cpumask only after searching thread group https://git.kernel.org/powerpc/c/6e086302816b2ced602bc99641eb0189c05f018a [09/10] powerpc/smp: Create coregroup domain https://git.kernel.org/powerpc/c/72730bfc2a2b91a525f38dfc830f598bdb95f216 [10/10] powerpc/smp: Implement cpu_to_coregroup_id https://git.kernel.org/powerpc/c/fa35e868f9ddcbb7984fd5ab7f91aef924fa8543
cheers