From: Mete Durlu <meted@linux.ibm.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Peter Zijlstra <peterz@infradead.org>,
Chen Yu <yu.c.chen@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-mips@vger.kernel.org, loongarch@lists.linux.dev,
driver-core@lists.linux.dev, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>
Subject: Re: [RFC PATCH v3 07/13] s390/topology: Initialize sbm topology during topology_init_early()
Date: Tue, 13 Oct 2026 12:14:15 +0200 [thread overview]
Message-ID: <4169abb8-6745-41a8-ab03-14f0ad08a118@linux.ibm.com> (raw)
In-Reply-To: <91a1bbf9-0409-408f-bedf-a5414be4d1a2@amd.com>
On 12/10/2026 04:20, K Prateek Nayak wrote:
> Hello Mete,
>
> On 10/7/2026 3:49 PM, Mete Durlu wrote:
>> 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@amd.com>
>>> ---
>>> 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.
>
> So based on my limited understanding, doesn't store_topology() populate
> the mask for the entire system on s390? Are you saying that can change
> or that stsi() may return a partial topology for only the online CPUs?
On s390 LPAR(logical partition) cpu topology can change during runtime.
Depending on the decisions made by the underlying hypervisor there
can be topology adjustments to find the optimal LPAR placement within
the physical machine.
To give a concrete example:
On an LPAR with 7 cores spanning 2 chips with the following topology;
CPU NODE DRAWER BOOK SOCKET CORE ONLINE ADDRESS
0 0 0 0 0 0 yes 0
1 0 0 0 0 0 yes 1
2 0 0 0 0 1 yes 2
3 0 0 0 0 1 yes 3
4 0 0 0 0 2 yes 4
5 0 0 0 0 2 yes 5
6 0 0 0 0 3 yes 6
7 0 0 0 0 3 yes 7
8 0 0 0 1 4 yes 8
9 0 0 0 1 4 yes 9
10 0 0 0 1 5 yes 10
11 0 0 0 1 5 yes 11
12 0 0 0 1 6 yes 12
13 0 0 0 1 6 yes 13
Initially max_threads_per_instance would be 8, right?
After a topology update from the hypervisor we can end up with
all cores placed in the same chip.
CPU NODE DRAWER BOOK SOCKET CORE ONLINE ADDRESS
0 0 0 0 0 0 yes 0
1 0 0 0 0 0 yes 1
2 0 0 0 0 1 yes 2
3 0 0 0 0 1 yes 3
4 0 0 0 0 2 yes 4
5 0 0 0 0 2 yes 5
6 0 0 0 0 3 yes 6
7 0 0 0 0 3 yes 7
8 0 0 0 0 4 yes 8
9 0 0 0 0 4 yes 9
10 0 0 0 0 5 yes 10
11 0 0 0 0 5 yes 11
12 0 0 0 0 6 yes 12
13 0 0 0 0 6 yes 13
According to the new topology max_threads_per_instance now
should be 14.
On top of that we support hotplugging in new CPUs which
means we can then get a new topology after adding a
completely new core. (QEMU supports feature [1])
CPU NODE DRAWER BOOK SOCKET CORE ONLINE ADDRESS
0 0 0 0 0 0 yes 0
1 0 0 0 0 0 yes 1
2 0 0 0 0 1 yes 2
3 0 0 0 0 1 yes 3
4 0 0 0 0 2 yes 4
5 0 0 0 0 2 yes 5
6 0 0 0 0 3 yes 6
7 0 0 0 0 3 yes 7
8 0 0 0 0 4 yes 8
9 0 0 0 0 4 yes 9
10 0 0 0 0 5 yes 10
11 0 0 0 0 5 yes 11
12 0 0 0 0 6 yes 12
13 0 0 0 0 6 yes 13
14 0 0 0 0 7 yes 14
15 0 0 0 0 7 yes 15
max_threads_per_instance should now be 16.
Considering these cases I asked for a redesign that
allows smb_set_topology() and smb_init() to be called
during topology_rebuild() operations.
Please correct me if I misunderstood a something
from your proposal.
[1] https://www.qemu.org/docs/master/system/s390x/cpu-topology.html
Thanks,
-Mete
next prev parent reply other threads:[~2026-10-13 10:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 19:28 [RFC PATCH v3 00/13] lib, sched: Introduce sparsebitmap (sbm) K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 01/13] lib/sbm: Introduce helpers for architectures to configure LLC properties K Prateek Nayak
2026-10-07 5:43 ` Shrikanth Hegde
2026-10-12 2:11 ` K Prateek Nayak
2026-10-12 22:22 ` Tim Chen
2026-10-01 19:28 ` [RFC PATCH v3 02/13] drivers/base/arch_topology: Add support for initializing sbm topology K Prateek Nayak
2026-10-12 23:41 ` Tim Chen
2026-10-01 19:28 ` [RFC PATCH v3 03/13] LoongArch: Initialize CPU _PXM relation for disabled CPUs from SRAT K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 04/13] LoongArch: Configure sbm topology during SMP preparation K Prateek Nayak
2026-10-07 3:51 ` [RFC PATCH v3.1 " K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 05/13] MIPS: Initialize sbm topology on multi-node systems K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 06/13] powerpc/setup: Initialize sbm topology based on coregroup / NUMA topology K Prateek Nayak
2026-10-07 14:43 ` Shrikanth Hegde
2026-10-12 2:29 ` K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 07/13] s390/topology: Initialize sbm topology during topology_init_early() K Prateek Nayak
2026-10-07 10:19 ` Mete Durlu
2026-10-12 2:20 ` K Prateek Nayak
2026-10-13 10:14 ` Mete Durlu [this message]
2026-10-01 19:28 ` [RFC PATCH v3 08/13] sparc64: Initialize sbm topology on multi-LLC system K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 09/13] x86/cpu/topology: Initialize sbm topology after topology parsing K Prateek Nayak
2026-10-03 8:27 ` Chen Yu
2026-10-04 6:17 ` K Prateek Nayak
2026-10-07 3:52 ` [RFC PATCH v3.1 " K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 10/13] lib/sbm: Dynamically allocate sbm index when CPU is activated K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 11/13] lib/sbm: Add helpers to allocate, set, clear, and traverse the bits on sbm K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 12/13] sched/fair: Allocate nohz.idle_cpus_mask during sched_init_smp() K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 13/13] sched/fair: Switch nohz.idle_cpus to use sbm K Prateek Nayak
2026-10-03 9:10 ` [RFC PATCH v3 00/13] lib, sched: Introduce sparsebitmap (sbm) Chen Yu
2026-10-04 6:13 ` K Prateek Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4169abb8-6745-41a8-ab03-14f0ad08a118@linux.ibm.com \
--to=meted@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=driver-core@lists.linux.dev \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®