xref: /qemu/docs/devel/s390-cpu-topology.rst (revision 745c2911cc0a20da2e3a1e96ba0ae42a5ad65773)
10d177cddSPierre MorelQAPI interface for S390 CPU topology
20d177cddSPierre Morel====================================
30d177cddSPierre Morel
40d177cddSPierre MorelThe following sections will explain the QAPI interface for S390 CPU topology
50d177cddSPierre Morelwith the help of exemplary output.
60d177cddSPierre MorelFor this, let's assume that QEMU has been started with the following
70d177cddSPierre Morelcommand, defining 4 CPUs, where CPU[0] is defined by the -smp argument and will
80d177cddSPierre Morelhave default values:
90d177cddSPierre Morel
100d177cddSPierre Morel.. code-block:: bash
110d177cddSPierre Morel
120d177cddSPierre Morel qemu-system-s390x \
130d177cddSPierre Morel    -enable-kvm \
140d177cddSPierre Morel    -cpu z14,ctop=on \
150d177cddSPierre Morel    -smp 1,drawers=3,books=3,sockets=2,cores=2,maxcpus=36 \
160d177cddSPierre Morel    -device z14-s390x-cpu,core-id=19,entitlement=high \
170d177cddSPierre Morel    -device z14-s390x-cpu,core-id=11,entitlement=low \
18*0180a744SZhao Liu    -device z14-s390x-cpu,core-id=12,entitlement=high \
190d177cddSPierre Morel   ...
200d177cddSPierre Morel
210d177cddSPierre MorelAdditions to query-cpus-fast
220d177cddSPierre Morel----------------------------
230d177cddSPierre Morel
240d177cddSPierre MorelThe command query-cpus-fast allows querying the topology tree and
250d177cddSPierre Morelmodifiers for all configured vCPUs.
260d177cddSPierre Morel
270d177cddSPierre Morel.. code-block:: QMP
280d177cddSPierre Morel
290d177cddSPierre Morel { "execute": "query-cpus-fast" }
300d177cddSPierre Morel {
310d177cddSPierre Morel  "return": [
320d177cddSPierre Morel    {
330d177cddSPierre Morel      "dedicated": false,
340d177cddSPierre Morel      "thread-id": 536993,
350d177cddSPierre Morel      "props": {
360d177cddSPierre Morel        "core-id": 0,
370d177cddSPierre Morel        "socket-id": 0,
380d177cddSPierre Morel        "drawer-id": 0,
390d177cddSPierre Morel        "book-id": 0
400d177cddSPierre Morel      },
410d177cddSPierre Morel      "cpu-state": "operating",
420d177cddSPierre Morel      "entitlement": "medium",
430d177cddSPierre Morel      "qom-path": "/machine/unattached/device[0]",
440d177cddSPierre Morel      "cpu-index": 0,
450d177cddSPierre Morel      "target": "s390x"
460d177cddSPierre Morel    },
470d177cddSPierre Morel    {
480d177cddSPierre Morel      "dedicated": false,
490d177cddSPierre Morel      "thread-id": 537003,
500d177cddSPierre Morel      "props": {
510d177cddSPierre Morel        "core-id": 19,
520d177cddSPierre Morel        "socket-id": 1,
530d177cddSPierre Morel        "drawer-id": 0,
540d177cddSPierre Morel        "book-id": 2
550d177cddSPierre Morel      },
560d177cddSPierre Morel      "cpu-state": "operating",
570d177cddSPierre Morel      "entitlement": "high",
580d177cddSPierre Morel      "qom-path": "/machine/peripheral-anon/device[0]",
590d177cddSPierre Morel      "cpu-index": 19,
600d177cddSPierre Morel      "target": "s390x"
610d177cddSPierre Morel    },
620d177cddSPierre Morel    {
630d177cddSPierre Morel      "dedicated": false,
640d177cddSPierre Morel      "thread-id": 537004,
650d177cddSPierre Morel      "props": {
660d177cddSPierre Morel        "core-id": 11,
670d177cddSPierre Morel        "socket-id": 1,
680d177cddSPierre Morel        "drawer-id": 0,
690d177cddSPierre Morel        "book-id": 1
700d177cddSPierre Morel      },
710d177cddSPierre Morel      "cpu-state": "operating",
720d177cddSPierre Morel      "entitlement": "low",
730d177cddSPierre Morel      "qom-path": "/machine/peripheral-anon/device[1]",
740d177cddSPierre Morel      "cpu-index": 11,
750d177cddSPierre Morel      "target": "s390x"
760d177cddSPierre Morel    },
770d177cddSPierre Morel    {
780d177cddSPierre Morel      "dedicated": true,
790d177cddSPierre Morel      "thread-id": 537005,
800d177cddSPierre Morel      "props": {
81*0180a744SZhao Liu        "core-id": 12,
820d177cddSPierre Morel        "socket-id": 0,
830d177cddSPierre Morel        "drawer-id": 3,
840d177cddSPierre Morel        "book-id": 2
850d177cddSPierre Morel      },
860d177cddSPierre Morel      "cpu-state": "operating",
870d177cddSPierre Morel      "entitlement": "high",
880d177cddSPierre Morel      "qom-path": "/machine/peripheral-anon/device[2]",
89*0180a744SZhao Liu      "cpu-index": 12,
900d177cddSPierre Morel      "target": "s390x"
910d177cddSPierre Morel    }
920d177cddSPierre Morel  ]
930d177cddSPierre Morel }
940d177cddSPierre Morel
950d177cddSPierre Morel
960d177cddSPierre MorelQAPI command: set-cpu-topology
970d177cddSPierre Morel------------------------------
980d177cddSPierre Morel
990d177cddSPierre MorelThe command set-cpu-topology allows modifying the topology tree
1000d177cddSPierre Morelor the topology modifiers of a vCPU in the configuration.
1010d177cddSPierre Morel
1020d177cddSPierre Morel.. code-block:: QMP
1030d177cddSPierre Morel
1040d177cddSPierre Morel    { "execute": "set-cpu-topology",
1050d177cddSPierre Morel      "arguments": {
1060d177cddSPierre Morel         "core-id": 11,
1070d177cddSPierre Morel         "socket-id": 0,
1080d177cddSPierre Morel         "book-id": 0,
1090d177cddSPierre Morel         "drawer-id": 0,
1100d177cddSPierre Morel         "entitlement": "low",
1110d177cddSPierre Morel         "dedicated": false
1120d177cddSPierre Morel      }
1130d177cddSPierre Morel    }
1140d177cddSPierre Morel    {"return": {}}
1150d177cddSPierre Morel
1160d177cddSPierre MorelThe core-id parameter is the only mandatory parameter and every
1170d177cddSPierre Morelunspecified parameter keeps its previous value.
1180d177cddSPierre Morel
1190d177cddSPierre MorelQAPI event CPU_POLARIZATION_CHANGE
1200d177cddSPierre Morel----------------------------------
1210d177cddSPierre Morel
1220d177cddSPierre MorelWhen a guest requests a modification of the polarization,
1230d177cddSPierre MorelQEMU sends a CPU_POLARIZATION_CHANGE event.
1240d177cddSPierre Morel
1250d177cddSPierre MorelWhen requesting the change, the guest only specifies horizontal or
1260d177cddSPierre Morelvertical polarization.
1270d177cddSPierre MorelIt is the job of the entity administrating QEMU to set the dedication and fine
1280d177cddSPierre Morelgrained vertical entitlement in response to this event.
1290d177cddSPierre Morel
1300d177cddSPierre MorelNote that a vertical polarized dedicated vCPU can only have a high
1310d177cddSPierre Morelentitlement, giving 6 possibilities for vCPU polarization:
1320d177cddSPierre Morel
1330d177cddSPierre Morel- Horizontal
1340d177cddSPierre Morel- Horizontal dedicated
1350d177cddSPierre Morel- Vertical low
1360d177cddSPierre Morel- Vertical medium
1370d177cddSPierre Morel- Vertical high
1380d177cddSPierre Morel- Vertical high dedicated
1390d177cddSPierre Morel
1400d177cddSPierre MorelExample of the event received when the guest issues the CPU instruction
1410d177cddSPierre MorelPerform Topology Function PTF(0) to request an horizontal polarization:
1420d177cddSPierre Morel
1430d177cddSPierre Morel.. code-block:: QMP
1440d177cddSPierre Morel
1450d177cddSPierre Morel  {
1460d177cddSPierre Morel    "timestamp": {
1470d177cddSPierre Morel      "seconds": 1687870305,
1480d177cddSPierre Morel      "microseconds": 566299
1490d177cddSPierre Morel    },
1500d177cddSPierre Morel    "event": "CPU_POLARIZATION_CHANGE",
1510d177cddSPierre Morel    "data": {
1520d177cddSPierre Morel      "polarization": "horizontal"
1530d177cddSPierre Morel    }
1540d177cddSPierre Morel  }
1550d177cddSPierre Morel
1560d177cddSPierre MorelQAPI query command: query-s390x-cpu-polarization
1570d177cddSPierre Morel------------------------------------------------
1580d177cddSPierre Morel
1590d177cddSPierre MorelThe query command query-s390x-cpu-polarization returns the current
1600d177cddSPierre MorelCPU polarization of the machine.
1610d177cddSPierre MorelIn this case the guest previously issued a PTF(1) to request vertical polarization:
1620d177cddSPierre Morel
1630d177cddSPierre Morel.. code-block:: QMP
1640d177cddSPierre Morel
1650d177cddSPierre Morel    { "execute": "query-s390x-cpu-polarization" }
1660d177cddSPierre Morel    {
1670d177cddSPierre Morel        "return": {
1680d177cddSPierre Morel          "polarization": "vertical"
1690d177cddSPierre Morel        }
1700d177cddSPierre Morel    }
171