mbox series

[v14,00/11] s390x: CPU Topology

Message ID 20230105145313.168489-1-pmorel@linux.ibm.com
Headers show
Series s390x: CPU Topology | expand

Message

Pierre Morel Jan. 5, 2023, 2:53 p.m. UTC
Hi,

This new series adds three features:

1) the implementation of drawers and books in the topology geometry
   and adds polarization and dedication as topology modifiers.

2) The Maximum Nested topology level (MNEST) can be read with SCLP
   read info.

3) Dynamic modification of the CPU topology using the QEMU monitor.


Implementation discussions
==========================

CPU models
----------

Since the facility 11, S390_FEAT_CONFIGURATION_TOPOLOGY is already
in the CPU model for old QEMU we could not activate it as usual from
KVM but needed a KVM capability: KVM_CAP_S390_CPU_TOPOLOGY.
Checking and enabling this capability enables facility 11,
S390_FEAT_CONFIGURATION_TOPOLOGY.

It is the responsibility of the admin to ensure the same CPU
model for source and target host in a migration.

Migration
---------

When the target guest is started, the Multi-processor Topology Change
Report (MTCR) bit is set during the creation of the vCPU by KVM.
We do not need to migrate its state, in the worst case, the target
guest will see the MTCR and actualize its view of the topology
without necessity, but this will be done only one time.

Reset
-----

Reseting the topology is done during subsystem reset, the
polarization is reset to horizontal polarization.

Topology attributes
-------------------

The topology attributes are carried by the CPU object and defined
on object creation.
In the case the new attributes, socket, book, drawer, dedicated,
polarity are not provided QEMU provides defaults values.

- Geometry defaults
  The geometry default are based on the core-id of the core to 
  fill the geometry in a monotone way starting with drawer 0,
  book 0, and filling socket 0 with the number of cores per socket,
  then filling socket 1, socket 2 ... etc until the book is complete
  and all books until the first drawer is complete before starting with
  the next drawer.

  This allows to keep existing start scripts and Libvirt existing
  interface until it is extended.

- Modifiers defaults
  Default polarization is horizontal
  Default dedication is not dedicated.

Dynamic topology modification
-----------------------------

QAPI interface is extended with:
- a command: 'change-topology'
- a query: 'query-topology'
- a event: 'POLARITY_CHANGE'

The admin may use query-topology to verify the topology provided
to the guest and change-topology to modify it.

The event POLARITY_CHANGE is sent when the guest uses the PTF
instruction to request a polarization change. In that case, the
admin is supposed to modify the CPU provisioning accordingly.

Testing
=======

To use the QEMU patches, you will need Linux V6-rc1 or newer,
or use the following Linux mainline patches:

f5ecfee94493 2022-07-20 KVM: s390: resetting the Topology-Change-Report    
24fe0195bc19 2022-07-20 KVM: s390: guest support for topology function     
0130337ec45b 2022-07-20 KVM: s390: Cleanup ipte lock access and SIIF fac.. 

Currently this code is for KVM only, I have no idea if it is interesting
to provide a TCG patch. If ever it will be done in another series.

Documentation
=============

To have a better understanding of the S390x CPU Topology and its
implementation in QEMU you can have a look at the documentation in the
last patch of this series.

The admin will want to match the host and the guest topology, taking
into account that the guest does not recognize multithreading.
Consequently, two vCPU assigned to threads of the same real CPU should
preferably be assigned to the same socket of the guest machine.


Regards,
Pierre

Pierre Morel (11):
  s390x/cpu topology: adding s390 specificities to CPU topology
  s390x/cpu topology: add topology entries on CPU hotplug
  target/s390x/cpu topology: handle STSI(15) and build the SYSIB
  s390x/sclp: reporting the maximum nested topology entries
  s390x/cpu topology: resetting the Topology-Change-Report
  s390x/cpu topology: interception of PTF instruction
  target/s390x/cpu topology: activating CPU topology
  qapi/s390/cpu topology:  change-topology monitor command
  qapi/s390/cpu topology: monitor query topology information
  qapi/s390/cpu topology: POLARITY_CHANGE qapi event
  docs/s390x/cpu topology: document s390x cpu topology

 docs/system/s390x/cpu-topology.rst | 292 ++++++++++++++
 docs/system/target-s390x.rst       |   1 +
 qapi/machine-target.json           | 116 ++++++
 qapi/machine.json                  |  14 +-
 include/hw/boards.h                |  10 +-
 include/hw/s390x/cpu-topology.h    |  77 ++++
 include/hw/s390x/s390-virtio-ccw.h |   6 +
 include/hw/s390x/sclp.h            |   4 +-
 include/monitor/hmp.h              |   2 +
 target/s390x/cpu.h                 |  86 ++++
 target/s390x/kvm/kvm_s390x.h       |   1 +
 hw/core/machine-smp.c              |  48 ++-
 hw/core/machine.c                  |   4 +
 hw/s390x/cpu-topology.c            | 604 +++++++++++++++++++++++++++++
 hw/s390x/s390-virtio-ccw.c         |  13 +
 hw/s390x/sclp.c                    |   4 +
 softmmu/vl.c                       |   6 +
 target/s390x/cpu-sysemu.c          |  29 ++
 target/s390x/cpu.c                 |  10 +
 target/s390x/cpu_models.c          |   1 +
 target/s390x/kvm/cpu_topology.c    | 136 +++++++
 target/s390x/kvm/kvm.c             |  46 ++-
 hmp-commands-info.hx               |  16 +
 hmp-commands.hx                    |  16 +
 hw/s390x/meson.build               |   1 +
 qemu-options.hx                    |   6 +-
 target/s390x/kvm/meson.build       |   3 +-
 27 files changed, 1537 insertions(+), 15 deletions(-)
 create mode 100644 docs/system/s390x/cpu-topology.rst
 create mode 100644 include/hw/s390x/cpu-topology.h
 create mode 100644 hw/s390x/cpu-topology.c
 create mode 100644 target/s390x/kvm/cpu_topology.c