Skip to contentSkip to conversation

S390x: CPU Topology Information

PATCH Superseded Pierre Morel 3 participants 16 messages Jun 27, 2023 – Jul 12, 2023

Subsystems (2)

v10 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

v10 cover S390x: CPU Topology Information

Hi,

new version of the kvm-unit-test s390x CPU topology series.

0. what is new in this new spin
-------------------------------

- the configuration tested in unittests.cfg is compatible with current QEMU. A later patch will be needed to use full topology when QEMU patches are mainline.
- one of the tested configuration using 248 processors will failed until SCLP bug is corrected
- use of -cpu max instead of z14

1. what is done
---------------

- First part is checking PTF errors, for KVM and LPAR

- Second part is checking PTF polarization change and STSI with the cpu topology including drawers and books. This tests are run for KVM only.

To run these tests under KVM successfully you need Linux 6.0 or newer.

Note that Fedora-35 already has the CPU Topology backport for Linux.

To start the test in KVM just do:

# ./run_tests.sh topology
for the topology ptf tests or for the topology stsi tests
# ./run_tests.sh topology-2

or something like:

# ./s390x-run s390x/topology.elf \
	-cpu max,ctop=on \
	-smp 5,sockets=4,cores=4,maxcpus=16 \
	-append '-sockets 4 -cores 4'

Of course the declaration of the number of drawers, books, socket and core must be coherent between -smp and -append arguments.

Regards,
Pierre

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

 lib/s390x/sclp.c    |   6 +
 lib/s390x/sclp.h    |   4 +-
 lib/s390x/stsi.h    |  36 ++++
 s390x/Makefile      |   1 +
 s390x/topology.c    | 516 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   7 +
 6 files changed, 569 insertions(+), 1 deletion(-)
 create mode 100644 s390x/topology.c
Signature · 63 lines
2.31.1

new in v10:

- unitests now compatible with current QEMU
  (Janosch)

- use of -cpu max instead of z14
  (Janosch, Thomas)

- colapse prefix_push and report_info
  (Nico)

new in v9:

- use report_fail instead of report(0,...
  (Nico)

- add 2 more configurations in unittests.cfg
  (Nico)

new in v8:

- define PTF_INVALID_FUNCTION
  (Claudio)

- test every single bits for specification in the ptf instruction
  (Claudio)

- test vertical polarization twice
  (Claudio)

- add an assert(read_info)
  (Nico)

- changed skips
  (Nico)


new in v7:

- better checks using device attributes on commandline
  (Pierre)
- use builtin to get the number of CPU in the TLE mask
  (Thomas)
- use Elvis (not dead)
  (Thomas)
- reset before tests
  (Nina)
- splitting test_ptf in small functions
  (Thomas)
- check every ptf function code for program check
  (Nina)
- Test made on LPAR
  (Janosch)
- use a single page for SYSIB
  (Thomas)
- abort on wrong parameter
  (Thomas)
- implement SYSIB check with a recursive funtion
  (Nina)
- diverse little changes (naming, clearer checks
  (Nina, Thomas)
#1 lore raw

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

We check that the PTF instruction is working correctly when the cpu topology facility is available.

For KVM only, we test changing of the polarity between horizontal and vertical and that a reset set the horizontal polarity.

---
 s390x/Makefile      |   1 +
 s390x/topology.c    | 190 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   3 +
 3 files changed, 194 insertions(+)
 create mode 100644 s390x/topology.c
s390x/Makefile +1 -0
index a80db53..fe77b07 100644
@@ -40,6 +40,7 @@ tests += $(TEST_DIR)/panic-loop-pgm.elf
 tests += $(TEST_DIR)/migration-sck.elf
 tests += $(TEST_DIR)/exittime.elf
 tests += $(TEST_DIR)/ex.elf
+tests += $(TEST_DIR)/topology.elf
 
 pv-tests += $(TEST_DIR)/pv-diags.elf
 
s390x/topology.c new file +190 -0

190 lines not on this page · raw message

s390x/unittests.cfg +3 -0
index b61faf0..fc3666b 100644
@@ -218,3 +218,6 @@ extra_params = -append '--parallel'
 
 [execute]
 file = ex.elf
+
+[topology]
+file = topology.elf
Signature · 1 line
2.31.1
#2 lore raw

Re: [kvm-unit-tests PATCH v10 1/2] s390x: topology: Check the Perform Topology Function

Quoting Pierre Morel (2023-06-27 10:21:54)
[...]

Quoted 6 lines
s390x/topology.c new file +0 -0
new file mode 100644
index 0000000..7e1bbf9
@@ -0,0 +1,190 @@

[...]

s390x/topology.c line 53

Quoted 7 lines
s390x/topology.c new file +7 -0
+static void check_privilege(int fc)
+{
+       unsigned long rc;
+       char buf[20];
+
+       snprintf(buf, sizeof(buf), "Privileged fc %d", fc);
+       report_prefix_push(buf);

We have report_prefix_pushf (note the f at the end!) for this.

I can fix that up when picking in case there's no new version, though.

#3 lore raw

Re: [kvm-unit-tests PATCH v10 1/2] s390x: topology: Check the Perform Topology Function

Quoted 18 lines · Nico Boehr

Quoting Pierre Morel (2023-06-27 10:21:54)
[...]

Quoted 6 lines
s390x/topology.c new file +0 -0
new file mode 100644
index 0000000..7e1bbf9
@@ -0,0 +1,190 @@

[...]

s390x/topology.c line 53

Quoted 7 lines
s390x/topology.c new file +7 -0
+static void check_privilege(int fc)
+{
+       unsigned long rc;
+       char buf[20];
+
+       snprintf(buf, sizeof(buf), "Privileged fc %d", fc);
+       report_prefix_push(buf);

We have report_prefix_pushf (note the f at the end!) for this.

Quoted 1 line

I can fix that up when picking in case there's no new version, though.

ohhh, perfect.

Yes please if you can, do it :)

Thanks

Pierre

Reviewed-by
#4 lore raw

Re: [kvm-unit-tests PATCH v10 1/2] s390x: topology: Check the Perform Topology Function

In reply to Nico Boehr
Quoted 19 lines · Nico Boehr

Quoting Pierre Morel (2023-06-27 10:21:54)
[...]

Quoted 6 lines
s390x/topology.c new file +0 -0
new file mode 100644
index 0000000..7e1bbf9
@@ -0,0 +1,190 @@

[...]

s390x/topology.c line 53

Quoted 7 lines
s390x/topology.c new file +7 -0
+static void check_privilege(int fc)
+{
+       unsigned long rc;
+       char buf[20];
+
+       snprintf(buf, sizeof(buf), "Privileged fc %d", fc);
+       report_prefix_push(buf);

We have report_prefix_pushf (note the f at the end!) for this.

Quoted 1 line

I can fix that up when picking in case there's no new version, though.

With that fixed:

#5 lore raw

Re: [kvm-unit-tests PATCH v10 1/2] s390x: topology: Check the Perform Topology Function

Quoted 20 lines · Thomas Huth
Quoted 19 lines · Nico Boehr

Quoting Pierre Morel (2023-06-27 10:21:54)
[...]

Quoted 6 lines
s390x/topology.c new file +0 -0
new file mode 100644
index 0000000..7e1bbf9
@@ -0,0 +1,190 @@

[...]

s390x/topology.c line 53

Quoted 7 lines
s390x/topology.c new file +7 -0
+static void check_privilege(int fc)
+{
+       unsigned long rc;
+       char buf[20];
+
+       snprintf(buf, sizeof(buf), "Privileged fc %d", fc);
+       report_prefix_push(buf);

We have report_prefix_pushf (note the f at the end!) for this.

Quoted 6 lines
Quoted 1 line

I can fix that up when picking in case there's no new version, though.

With that fixed:

Thanks both of you.

Regards,

Pierre

#6 lore raw

Re: [kvm-unit-tests PATCH v10 1/2] s390x: topology: Check the Perform Topology Function

In reply to Thomas Huth
Quoted 20 lines · Thomas Huth
Quoted 19 lines · Nico Boehr

Quoting Pierre Morel (2023-06-27 10:21:54)
[...]

Quoted 6 lines
s390x/topology.c new file +0 -0
new file mode 100644
index 0000000..7e1bbf9
@@ -0,0 +1,190 @@

[...]

s390x/topology.c line 53

Quoted 7 lines
s390x/topology.c new file +7 -0
+static void check_privilege(int fc)
+{
+       unsigned long rc;
+       char buf[20];
+
+       snprintf(buf, sizeof(buf), "Privileged fc %d", fc);
+       report_prefix_push(buf);

We have report_prefix_pushf (note the f at the end!) for this.

Quoted 6 lines
Quoted 1 line

I can fix that up when picking in case there's no new version, though.

With that fixed:

Thanks both of you.

Regards,

Pierre

#7 lore raw

PATCH v10 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 retrieve the maximum nested level with SCLP and use the topology tree provided by sockets and cores only to stay compatible with qemu topology before topology extension with drawers and books.
arguments.

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/sclp.c    |   6 +
 lib/s390x/sclp.h    |   4 +-
 lib/s390x/stsi.h    |  36 +++++
 s390x/topology.c    | 326 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   4 +
 5 files changed, 375 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +6 -0
index 56d5c90..2f902e3 100644
@@ -247,3 +247,9 @@ uint64_t get_max_ram_size(void)
 {
 	return max_ram_size;
 }
+
+uint64_t sclp_get_stsi_mnest(void)
+{
+	assert(read_info);
+	return read_info->stsi_parm;
+}
lib/s390x/sclp.h +3 -1
index 853529b..6a611bc 100644
@@ -150,7 +150,8 @@ typedef struct ReadInfo {
 	SCCBHeader h;
 	uint16_t rnmax;
 	uint8_t rnsize;
-	uint8_t  _reserved1[16 - 11];       /* 11-15 */
+	uint8_t  _reserved1[15 - 11];       /* 11-14 */
+	uint8_t stsi_parm;                  /* 15-15 */
 	uint16_t entries_cpu;               /* 16-17 */
 	uint16_t offset_cpu;                /* 18-19 */
 	uint8_t  _reserved2[24 - 20];       /* 20-23 */
@@ -341,5 +342,6 @@ int sclp_service_call(unsigned int command, void *sccb);
 void sclp_memory_setup(void);
 uint64_t get_ram_size(void);
 uint64_t get_max_ram_size(void);
+uint64_t sclp_get_stsi_mnest(void);
 
 #endif /* _S390X_SCLP_H_ */
lib/s390x/stsi.h +36 -0
index bebc492..1351a6f 100644
@@ -29,4 +29,40 @@ struct sysinfo_3_2_2 {
 	uint8_t ext_names[8][256];
 };
 
+#define CPUS_TLE_RES_BITS 0x00fffffff8000000UL
+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;
+};
+
+#define CONTAINER_TLE_RES_BITS 0x00ffffffffffff00UL
+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[];
+};
+
 #endif  /* _S390X_STSI_H_ */
s390x/topology.c +326 -0

349 lines not on this page · raw message

s390x/unittests.cfg +4 -0
index fc3666b..a90ad24 100644
@@ -221,3 +221,7 @@ file = ex.elf
 
 [topology]
 file = topology.elf
+
+[topology-2]
+file = topology.elf
+extra_params = -cpu max,ctop=on -smp sockets=31,cores=8,maxcpus=248  -append '-sockets 31 -cores 8'
Signature · 1 line
2.31.1
Reviewed-by on v10 2/2
#8 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoting Pierre Morel (2023-06-27 10:21:55)

Quoted 17 lines

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

We retrieve the maximum nested level with SCLP and use the topology tree provided by sockets and cores only to stay compatible with qemu topology before topology extension with drawers and books.
arguments.

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.

Quoted 1 line
#9 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

In reply to Pierre Morel
Quoted 6 lines · Pierre Morel

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

We retrieve the maximum nested level with SCLP and use the topology tree provided by sockets and cores only to stay compatible with qemu topology before topology extension with

"before checking ..." ?

Quoted 11 lines

drawers and books.
arguments.

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.

Quoted 8 lines
---
  lib/s390x/sclp.c    |   6 +
  lib/s390x/sclp.h    |   4 +-
  lib/s390x/stsi.h    |  36 +++++
  s390x/topology.c    | 326 ++++++++++++++++++++++++++++++++++++++++++++
  s390x/unittests.cfg |   4 +
  5 files changed, 375 insertions(+), 1 deletion(-)

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Thomas

#10 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoting Thomas Huth (2023-07-06 12:48:50)
[...]

Quoted 6 lines

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Yep, as you guessed this depends on:
Fixing infinite loop on SCLP READ SCP INFO error
https://lore.kernel.org/all/[email protected]/

#11 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoted 5 lines · Nico Boehr

Quoting Thomas Huth (2023-07-06 12:48:50)
[...]

Quoted 3 lines

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

Quoted 7 lines
Quoted 3 lines
   lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Yep, as you guessed this depends on:
Fixing infinite loop on SCLP READ SCP INFO error
https://lore.kernel.org/all/[email protected]/

Ok, that fixes the assertion, but now I get a test failure:

ABORT: READ_SCP_INFO failed

What else could I be missing?

Thomas

#12 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoting Thomas Huth (2023-07-10 16:38:22)

Quoted 14 lines · Nico Boehr
Quoted 5 lines

Quoting Thomas Huth (2023-07-06 12:48:50)
[...]

Quoted 3 lines

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

Quoted 7 lines
Quoted 3 lines
   lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Yep, as you guessed this depends on:
Fixing infinite loop on SCLP READ SCP INFO error
https://lore.kernel.org/all/[email protected]/

Quoted 5 lines

Ok, that fixes the assertion, but now I get a test failure:

ABORT: READ_SCP_INFO failed

What else could I be missing?

Argh, I forgot that you need this fixup to the patch:
https://lore.kernel.org/all/[email protected]/

If that doesn't work, let me know, so I can try and reproduce it here.

Tested-by
#13 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoted 17 lines · Nico Boehr

Quoting Thomas Huth (2023-07-10 16:38:22)

Quoted 16 lines · Nico Boehr
Quoted 5 lines

Quoting Thomas Huth (2023-07-06 12:48:50)
[...]

Quoted 3 lines

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

Quoted 7 lines
Quoted 3 lines
    lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Yep, as you guessed this depends on:
Fixing infinite loop on SCLP READ SCP INFO error
https://lore.kernel.org/all/[email protected]/

Ok, that fixes the assertion, but now I get a test failure:

Quoted 8 lines
Quoted 3 lines

ABORT: READ_SCP_INFO failed

What else could I be missing?

Argh, I forgot that you need this fixup to the patch:
https://lore.kernel.org/all/[email protected]/

If that doesn't work, let me know, so I can try and reproduce it here.

Thank you very much, removing that line fixed the problem, indeed. Both topology tests are passing now on my z15 LPAR.

#14 lore raw

Re: [kvm-unit-tests PATCH v10 2/2] s390x: topology: Checking Configuration Topology Information

Quoted 27 lines · Thomas Huth
Quoted 26 lines · Nico Boehr

Quoting Thomas Huth (2023-07-10 16:38:22)

Quoted 15 lines · Nico Boehr
Quoted 5 lines

Quoting Thomas Huth (2023-07-06 12:48:50)
[...]

Quoted 3 lines

Does this patch series depend on some other patches that are not upstream yet? I just tried to run the test, but I'm only getting:

Quoted 8 lines
Quoted 3 lines

    lib/s390x/sclp.c:122: assert failed: read_info

Any ideas what could be wrong?

Yep, as you guessed this depends on:
Fixing infinite loop on SCLP READ SCP INFO error
https://lore.kernel.org/all/[email protected]/

Quoted 5 lines

Ok, that fixes the assertion, but now I get a test failure:

ABORT: READ_SCP_INFO failed

What else could I be missing?

Argh, I forgot that you need this fixup to the patch:
https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 1 line

If that doesn't work, let me know, so I can try and reproduce it here.

Thank you very much, removing that line fixed the problem, indeed. Both topology tests are passing now on my z15 LPAR.

Thanks,

Pierre

#15 lore raw
In reply to Pierre Morel

Quoting Pierre Morel (2023-06-27 10:21:53)

Quoted 3 lines

Hi,

new version of the kvm-unit-test s390x CPU topology series.

This is now on our internal CI, so we can at least see that it doesn't break anything when the topology is not yet there :)