Re: [RFC PATCH v3 07/13] s390/topology: Initialize sbm topology during topology_init_early()
From: Mete Durlu
Date: Wed Oct 07 2026 - 06:26:39 EST
On 01/10/2026 21:28, K Prateek Nayak wrote:
When the topology mode is TOPOLOGY_MODE_HW, topology_init_early()
already parses the set of socket present on the system.
Use the socket_info to configure the sparsebitmask (sbm) properties for
the system - namely the number of sockets and maximum threads in a
socket instance.
arch_sbm_cpu_instance_id() traverses all socket instances to find
a matching CPU which is not optimal but instance ID is only checked
when the CPU is coming online. Since this is a rare event, the
inefficiency is tolerable.
Signed-off-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
---
Build tested with LKP's s390 randconfig with QEMU cmdline:
qemu-system-s390x \
-cpu max \
-smp 2 \
-m 2048 \
-kernel ./arch/s390/boot/vmlinux \
-append "console=ttyAMA0 earlycon ignore_loglevel log_buf_len=10M print_fatal_signals=1 LOGLEVEL=8 sched_debug" \
-nographic
Note: Since ctop needs KVM acceleration to emulate TOPOLOGY_MODE_HW, the
actual spasemask setting is only build tested at the moment.
XXX: Any way around this using cross-compile and QEMU?
---
arch/s390/kernel/topology.c | 52 +++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 1377c6f3f670..80dc51f5ce6f 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -20,6 +20,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/cpu.h>
+#include <linux/sbm.h>
#include <linux/smp.h>
#include <linux/mm.h>
#include <linux/nodemask.h>
@@ -561,6 +562,55 @@ static int __init detect_polarization(union topology_entry *tle)
return tl_core->pp != POLARIZATION_HRZ;
}
topology_init_early() is called once during early boot and never again.
Considering that s390's topology can change during runtime this
implementation won't work as sbm won't be able to adapt.
On s390 max_threads_per_instance can change during runtime.
Like sashiko pointed out, this approach also does not consider
any newly added cpus.
IMHO, there is a slight redesign required so that smb_set_topology()
and smb_init() can be called each time a topology rebuild is necessary.