Skip to contentSkip to conversation

S390x: CPU Topology Information

PATCH Superseded Pierre Morel 1 participant 3 messages Oct 24, 2022

Subsystems (2)

v5 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

v5 cover S390x: CPU Topology Information

Hi,

new version of the series with corrections.

When facility 11 is available inside the S390x architecture, 2 new instructions are available: PTF and STSI with function code 15.

Let's check their availability in QEMU/KVM and their coherence with the CPU topology provided to the QEMU -smp parameter and as argument for the test.

To run these tests successfully you will Linux 6.0 and the following QEMU patches (or newer):

https://lore.kernel.org/all/[email protected]/#r

To start the test just do:

# ./run_tests.sh topology

or

# ./s390x-run s390x/topology.elf \
	-smp 5,sockets=4,cores=4,maxcpus=16 \
	-append "-mnest 2 -sockets 4 -cores 4"

Of course the declaration of the number of socket and core must be coherent in -smp and -append arguments.
The "mnest" argument represent the expected nesting level it will be 2 until books and drawer are added to the topology.

Regards,
Pierre

Pierre Morel (2):
s390x: topology: Check the Perform Topology Function
s390x: topology: Checking Configuration Topology Information

 lib/s390x/stsi.h    |  44 ++++++
 s390x/Makefile      |   1 +
 s390x/topology.c    | 366 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   4 +
 4 files changed, 415 insertions(+)
 create mode 100644 s390x/topology.c
Signature · 7 lines
2.31.1

Changelog:

From v4:

- Simplify the tests for socket and cores only.
#1 lore raw

PATCH v5 1/2 s390x: topology: Check the Perform Topology Function

We check the PTF instruction.

- We check polarization only for KVM.
- We do not expect KVM to support vertical polarization.
- We do not expect the Topology Change Report to be pending or not at the moment the first PTF instruction with PTF_CHECK function code is done as some code already did run a polarization change may have occur.

---
 s390x/Makefile      |   1 +
 s390x/topology.c    | 132 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   3 +
 3 files changed, 136 insertions(+)
 create mode 100644 s390x/topology.c
s390x/Makefile +1 -0
index bf1504f9..4b9a21a7 100644
@@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
 tests += $(TEST_DIR)/panic-loop-pgm.elf
 tests += $(TEST_DIR)/migration-sck.elf
 tests += $(TEST_DIR)/exittime.elf
+tests += $(TEST_DIR)/topology.elf
 
 pv-tests += $(TEST_DIR)/pv-diags.elf
 
s390x/topology.c new file +132 -0

132 lines not on this page · raw message

s390x/unittests.cfg +3 -0
index 3caf81ed..3530cc4c 100644
@@ -208,3 +208,6 @@ groups = migration
 [exittime]
 file = exittime.elf
 smp = 2
+
+[topology]
+file = topology.elf
Signature · 1 line
2.31.1
#2 lore raw

PATCH v5 2/2 s390x: topology: Checking Configuration Topology Information

In reply to Pierre Morel

STSI with function code 15 is used to store the CPU configuration topology.

We check :
- if the topology stored is coherent between the QEMU -smp parameters and kernel parameters.
- the number of CPUs
- the maximum number of CPUs
- the number of containers of each levels for every STSI(15.1.x) instruction allowed by the machine.

---
 lib/s390x/stsi.h    |  44 ++++++++
 s390x/topology.c    | 238 +++++++++++++++++++++++++++++++++++++++++++-
 s390x/unittests.cfg |   1 +
 3 files changed, 281 insertions(+), 2 deletions(-)
lib/s390x/stsi.h +44 -0
index bebc492d..8dbbfc29 100644
@@ -29,4 +29,48 @@ struct sysinfo_3_2_2 {
 	uint8_t ext_names[8][256];
 };
 
+struct topology_core {
+	uint8_t nl;
+	uint8_t reserved1[3];
+	uint8_t reserved4:5;
+	uint8_t d:1;
+	uint8_t pp:2;
+	uint8_t type;
+	uint16_t origin;
+	uint64_t mask;
+};
+
+struct topology_container {
+	uint8_t nl;
+	uint8_t reserved[6];
+	uint8_t id;
+};
+
+union topology_entry {
+	uint8_t nl;
+	struct topology_core cpu;
+	struct topology_container container;
+};
+
+#define CPU_TOPOLOGY_MAX_LEVEL 6
+struct sysinfo_15_1_x {
+	uint8_t reserved0[2];
+	uint16_t length;
+	uint8_t mag[CPU_TOPOLOGY_MAX_LEVEL];
+	uint8_t reserved0a;
+	uint8_t mnest;
+	uint8_t reserved0c[4];
+	union topology_entry tle[0];
+};
+
+static inline int cpus_in_tle_mask(uint64_t val)
+{
+	int i, n;
+
+	for (i = 0, n = 0; i < 64; i++, val >>= 1)
+		if (val & 0x01)
+			n++;
+	return n;
+}
+
 #endif  /* _S390X_STSI_H_ */
s390x/topology.c +236 -2

267 lines not on this page · raw message

s390x/unittests.cfg +1 -0
index 3530cc4c..6dadf23d 100644
@@ -211,3 +211,4 @@ smp = 2
 
 [topology]
 file = topology.elf
+extra_params=-smp 5,sockets=4,cores=4,maxcpus=16 -append '-mnest 2 -sockets 4 -cores 4'
Signature · 1 line
2.31.1