Skip to contentSkip to conversation

s390 cpu hotplug

RFC PATCH Superseded Jason J. Herne 7 participants 49 messages Aug 1, 2013 – Oct 2, 2013

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover s390 cpu hotplug

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

Jason J. Herne (8):
s390-qemu: cpu hotplug - Define New SCLP Codes
s390-qemu: cpu hotplug - SCLP CPU Info
s390-qemu: cpu hotplug - SCLP Event integration
s390-qemu: cpu hotplug - Storage key global access
s390-qemu: cpu hotplug - ipi_states enhancements
s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug
s390-qemu: cpu hotplug - Implement hot_add_cpu hook
qemu-monitor: HMP cpu-add wrapper

 hmp-commands.hx                   |   13 ++++
 hmp.c                             |   10 ++++
 hmp.h                             |    1 +
 hw/s390x/Makefile.objs            |    2 +-
 hw/s390x/event-facility.c         |    7 +++
 hw/s390x/s390-virtio-ccw.c        |    8 ++-
 hw/s390x/s390-virtio.c            |   47 +++++++++------
 hw/s390x/s390-virtio.h            |    2 +-
 hw/s390x/sclp.c                   |   53 +++++++++++++++-
 hw/s390x/sclpcpu.c                |  120 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |    3 +
 include/hw/s390x/sclp.h           |   41 +++++++++++++
 target-s390x/cpu.c                |   36 ++++++++++-
 target-s390x/cpu.h                |    7 +++
 target-s390x/helper.c             |   12 ++++
 15 files changed, 336 insertions(+), 26 deletions(-)
 create mode 100644 hw/s390x/sclpcpu.c
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH v3 1/8 s390-qemu: cpu hotplug - Define New SCLP Codes

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---
 hw/s390x/sclp.c         |    2 +-
 include/hw/s390x/sclp.h |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +1 -1
index 86d6ae0..cb53d7e 100644
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {
     case SCLP_CMDW_READ_SCP_INFO:
     case SCLP_CMDW_READ_SCP_INFO_FORCED:
         read_SCP_info(sccb);
include/hw/s390x/sclp.h +8 -0
index 231a38a..174097d 100644
@@ -26,6 +26,14 @@
 #define SCLP_CMD_WRITE_EVENT_DATA               0x00760005
 #define SCLP_CMD_WRITE_EVENT_MASK               0x00780005
 
+/* CPU hotplug SCLP codes */
+#define SCLP_NO_CMD_PARM                        0xffff00ff
+#define SCLP_HAS_CPU_INFO                       0x0C00000000000000ULL
+#define SCLP_CMDW_READ_CPU_INFO                 0x00010001
+#define SCLP_CMDW_CONFIGURE_CPU                 0x00110001
+#define SCLP_CMDW_DECONFIGURE_CPU               0x00100001
+#define SCLP_CMDW_CPU_CMD_PARM                  0xff00
+
 /* SCLP response codes */
 #define SCLP_RC_NORMAL_READ_COMPLETION          0x0010
 #define SCLP_RC_NORMAL_COMPLETION               0x0020
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

Quoted 15 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---

hw/s390x/sclp.c         |    2 +-
include/hw/s390x/sclp.h |    8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +0 -0
index 86d6ae0..cb53d7e 100644

hw/s390x/sclp.c static void sclp_execute(SCCB *sccb, uint64_t code) · line 48

Quoted 5 lines
hw/s390x/sclp.c +1 -1
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
    S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {

switch (code & ~SCLP_CMD_PARM)

Or are the upper bits parm as well? In fact, what about the upper 32 bits?

Alex

Quoted 25 lines
hw/s390x/sclp.c +0 -0
    case SCLP_CMDW_READ_SCP_INFO:
    case SCLP_CMDW_READ_SCP_INFO_FORCED:
        read_SCP_info(sccb);
include/hw/s390x/sclp.h +8 -0
index 231a38a..174097d 100644
@@ -26,6 +26,14 @@
 #define SCLP_CMD_WRITE_EVENT_DATA               0x00760005
 #define SCLP_CMD_WRITE_EVENT_MASK               0x00780005
 
+/* CPU hotplug SCLP codes */
+#define SCLP_NO_CMD_PARM                        0xffff00ff
+#define SCLP_HAS_CPU_INFO                       0x0C00000000000000ULL
+#define SCLP_CMDW_READ_CPU_INFO                 0x00010001
+#define SCLP_CMDW_CONFIGURE_CPU                 0x00110001
+#define SCLP_CMDW_DECONFIGURE_CPU               0x00100001
+#define SCLP_CMDW_CPU_CMD_PARM                  0xff00
+
 /* SCLP response codes */
 #define SCLP_RC_NORMAL_READ_COMPLETION          0x0010
 #define SCLP_RC_NORMAL_COMPLETION               0x0020
Signature · 1 line
1.7.10.4
#3 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

Quoted 21 lines · Alexander Graf
Quoted 18 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---

hw/s390x/sclp.c         |    2 +-
include/hw/s390x/sclp.h |    8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +0 -0
index 86d6ae0..cb53d7e 100644
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
    S390SCLPDevice *sdev = get_event_facility();
 
Quoted 6 lines

hw/s390x/sclp.c static void sclp_execute(SCCB *sccb, uint64_t code) · line 48

Quoted 2 lines
hw/s390x/sclp.c +1 -1
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {

switch (code & ~SCLP_CMD_PARM)

Or are the upper bits parm as well? In fact, what about the upper 32 bits?

As of now those are ignored by the sclp. So (code & SCLP_NO_CMD_PARM) seems better to me.

#4 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

Quoted 27 lines · Christian Borntraeger
Quoted 26 lines · Alexander Graf
Quoted 15 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---

hw/s390x/sclp.c         |    2 +-
include/hw/s390x/sclp.h |    8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +0 -0
index 86d6ae0..cb53d7e 100644

hw/s390x/sclp.c static void sclp_execute(SCCB *sccb, uint64_t code) · line 48

Quoted 5 lines
hw/s390x/sclp.c +1 -1
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {

switch (code & ~SCLP_CMD_PARM)

Quoted 8 lines
Quoted 1 line

Or are the upper bits parm as well? In fact, what about the upper 32 bits?

As of now those are ignored by the sclp. So (code & SCLP_NO_CMD_PARM) seems better to me.

What if I rename it to SCLP_CMD_CODE_MASK? This removes the negative from the name and keeps the same semantics.

Signature · 1 line
-- Jason J. Herne ([email protected])
#5 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

Am 16.09.2013 um 09:29 schrieb "Jason J. Herne" <[email protected]>:

Quoted 28 lines · Christian Borntraeger
Quoted 27 lines · Alexander Graf
Quoted 26 lines · Jason J. Herne
Quoted 16 lines

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---

hw/s390x/sclp.c         |    2 +-
include/hw/s390x/sclp.h |    8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +0 -0
index 86d6ae0..cb53d7e 100644

hw/s390x/sclp.c static void sclp_execute(SCCB *sccb, uint64_t code) · line 48

Quoted 5 lines
hw/s390x/sclp.c +1 -1
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
    S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {

switch (code & ~SCLP_CMD_PARM)

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Or are the upper bits parm as well? In fact, what about the upper 32 bits?

As of now those are ignored by the sclp. So (code & SCLP_NO_CMD_PARM) seems better to me.

What if I rename it to SCLP_CMD_CODE_MASK? This removes the negative from the name and keeps the same semantics.

Does the mask include payload information as well or only the cmd code?

Alex

Quoted 4 lines
Signature · 2 lines
-- 
-- Jason J. Herne ([email protected])
#6 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

Quoted 32 lines · Alexander Graf

Am 16.09.2013 um 09:29 schrieb "Jason J. Herne" <[email protected]>:

Quoted 28 lines · Christian Borntraeger
Quoted 27 lines · Alexander Graf
Quoted 26 lines · Jason J. Herne
Quoted 16 lines

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---

hw/s390x/sclp.c         |    2 +-
include/hw/s390x/sclp.h |    8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +0 -0
index 86d6ae0..cb53d7e 100644

hw/s390x/sclp.c static void sclp_execute(SCCB *sccb, uint64_t code) · line 48

Quoted 5 lines
hw/s390x/sclp.c +1 -1
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_NO_CMD_PARM) {

switch (code & ~SCLP_CMD_PARM)

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Or are the upper bits parm as well? In fact, what about the upper 32 bits?

As of now those are ignored by the sclp. So (code & SCLP_NO_CMD_PARM) seems better to me.

What if I rename it to SCLP_CMD_CODE_MASK? This removes the negative from the name and keeps the same semantics.

Does the mask include payload information as well or only the cmd code?

It contains all elements of the command code and nothing more.

Quoted 8 lines
Quoted 5 lines

--
-- Jason J. Herne ([email protected])

Signature · 1 line
-- Jason J. Herne ([email protected])
#7 lore raw

Re: [Qemu-devel] [PATCH 1/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Define New SCLP Codes

In reply to Jason J. Herne

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 5 lines

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

"s390-qemu:" is really bad. For one, all QEMU patches are somehow about QEMU, so that's redundant. For another, "sclp:" would be much more telling to me which patches to look at than text disappearing at the end of the subject line in the mail client. :)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#8 lore raw

RFC PATCH v3 2/8 s390-qemu: cpu hotplug - SCLP CPU Info

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Implement the CPU data in SCLP "Read SCP Info". And implement "Read CPU Info" SCLP command. This data will be used by the guest to get information about hot plugged cpus.

---
 hw/s390x/sclp.c         |   51 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/sclp.h |   32 +++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
hw/s390x/sclp.c +51 -0
index cb53d7e..da8cf7a 100644
@@ -15,6 +15,7 @@
 #include "cpu.h"
 #include "sysemu/kvm.h"
 #include "exec/memory.h"
+#include "sysemu/sysemu.h"
 
 #include "hw/s390x/sclp.h"
 
@@ -31,7 +32,26 @@ static inline S390SCLPDevice *get_event_facility(void)
 static void read_SCP_info(SCCB *sccb)
 {
     ReadInfo *read_info = (ReadInfo *) sccb;
+    CPUState *cpu;
     int shift = 0;
+    int cpu_count = 0;
+    int i = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {
+        cpu_count++;
+    }
+
+    /* CPU information */
+    read_info->entries_cpu = cpu_to_be16(cpu_count);
+    read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
+    read_info->highest_cpu = cpu_to_be16(max_cpus);
+
+    for (i = 0; i < cpu_count; i++) {
+        read_info->entries[i].address = i;
+        read_info->entries[i].type = 0;
+    }
+
+    read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO);
 
     while ((ram_size >> (20 + shift)) > 65535) {
         shift++;
@@ -41,6 +61,34 @@ static void read_SCP_info(SCCB *sccb)
     sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
 }
 
+/* Provide information about the CPU */
+static void sclp_read_cpu_info(SCCB *sccb)
+{
+    ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
+    CPUState *cpu;
+    int cpu_count = 0;
+    int i = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {
+        cpu_count++;
+    }
+
+    cpu_info->nr_configured = cpu_to_be16(cpu_count);
+    cpu_info->offset_configured = cpu_to_be16(offsetof(ReadCpuInfo, entries));
+    cpu_info->nr_standby = cpu_to_be16(0);
+
+    /* The standby offset is 16-byte for each CPU */
+    cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured
+        + cpu_info->nr_configured*sizeof(CpuEntry));
+
+    for (i = 0; i < cpu_count; i++) {
+        cpu_info->entries[i].address = i;
+        cpu_info->entries[i].type = 0;
+    }
+
+    sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
+}
+
 static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
@@ -50,6 +98,9 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
     case SCLP_CMDW_READ_SCP_INFO_FORCED:
         read_SCP_info(sccb);
         break;
+    case SCLP_CMDW_READ_CPU_INFO:
+        sclp_read_cpu_info(sccb);
+        break;
     default:
         sdev->sclp_command_handler(sdev->ef, sccb, code);
         break;
include/hw/s390x/sclp.h +32 -0
index 174097d..89ae7d1 100644
@@ -79,12 +79,44 @@ typedef struct SCCBHeader {
 
 #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
 
+/* CPU information */
+typedef struct CpuEntry {
+    uint8_t address;
+    uint8_t reserved0[13];
+    uint8_t type;
+    uint8_t reserved1;
+} QEMU_PACKED CpuEntry;
+
 typedef struct ReadInfo {
     SCCBHeader h;
     uint16_t rnmax;
     uint8_t rnsize;
+    uint8_t  _reserved1[16 - 11];       /* 11-15 */
+    uint16_t entries_cpu;               /* 16-17 */
+    uint16_t offset_cpu;                /* 18-19 */
+    uint8_t  _reserved2[24 - 20];       /* 20-23 */
+    uint8_t  loadparm[8];               /* 24-31 */
+    uint8_t  _reserved3[48 - 32];       /* 32-47 */
+    uint64_t facilities;                /* 48-55 */
+    uint8_t  _reserved0[100 - 56];
+    uint32_t rnsize2;
+    uint64_t rnmax2;
+    uint8_t  _reserved4[120-112];       /* 112-119 */
+    uint16_t highest_cpu;
+    uint8_t  _reserved5[128 - 122];     /* 122-127 */
+    struct CpuEntry entries[0];
 } QEMU_PACKED ReadInfo;
 
+typedef struct ReadCpuInfo {
+    SCCBHeader h;
+    uint16_t nr_configured;         /* 8-9 */
+    uint16_t offset_configured;     /* 10-11 */
+    uint16_t nr_standby;            /* 12-13 */
+    uint16_t offset_standby;        /* 14-15 */
+    uint8_t reserved0[24-16];       /* 16-23 */
+    struct CpuEntry entries[0];
+} QEMU_PACKED ReadCpuInfo;
+
 typedef struct SCCB {
     SCCBHeader h;
     char data[SCCB_DATA_LEN];
Signature · 1 line
1.7.10.4
#9 lore raw

Re: [Qemu-devel] [PATCH 2/8] [PATCH RFC v3] s390-qemu: cpu hotplug - SCLP CPU Info

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 54 lines

From: "Jason J. Herne" <[email protected]>

Implement the CPU data in SCLP "Read SCP Info". And implement "Read CPU Info" SCLP command. This data will be used by the guest to get information about hot plugged cpus.

---
 hw/s390x/sclp.c         |   51 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/sclp.h |   32 +++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
hw/s390x/sclp.c +20 -0
index cb53d7e..da8cf7a 100644
@@ -15,6 +15,7 @@
 #include "cpu.h"
 #include "sysemu/kvm.h"
 #include "exec/memory.h"
+#include "sysemu/sysemu.h"
 
 #include "hw/s390x/sclp.h"
 
@@ -31,7 +32,26 @@ static inline S390SCLPDevice *get_event_facility(void)
 static void read_SCP_info(SCCB *sccb)
 {
     ReadInfo *read_info = (ReadInfo *) sccb;
+    CPUState *cpu;
     int shift = 0;
+    int cpu_count = 0;
+    int i = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {
+        cpu_count++;
+    }
+
+    /* CPU information */
+    read_info->entries_cpu = cpu_to_be16(cpu_count);
+    read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
+    read_info->highest_cpu = cpu_to_be16(max_cpus);
+
+    for (i = 0; i < cpu_count; i++) {
+        read_info->entries[i].address = i;
+        read_info->entries[i].type = 0;
+    }
+
+    read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO);
 
     while ((ram_size >> (20 + shift)) > 65535) {
         shift++;
@@ -41,6 +61,34 @@ static void read_SCP_info(SCCB *sccb)
     sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
 }

hw/s390x/sclp.c static void read_SCP_info(SCCB *sccb) · line 72

Quoted 10 lines
hw/s390x/sclp.c +9 -0
 
+/* Provide information about the CPU */
+static void sclp_read_cpu_info(SCCB *sccb)
+{
+    ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
+    CPUState *cpu;
+    int cpu_count = 0;
+    int i = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {

This becomes CPU_FOREACH(cpu) { now.

Quoted 37 lines
hw/s390x/sclp.c +22 -0
+        cpu_count++;
+    }
+
+    cpu_info->nr_configured = cpu_to_be16(cpu_count);
+    cpu_info->offset_configured = cpu_to_be16(offsetof(ReadCpuInfo, entries));
+    cpu_info->nr_standby = cpu_to_be16(0);
+
+    /* The standby offset is 16-byte for each CPU */
+    cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured
+        + cpu_info->nr_configured*sizeof(CpuEntry));
+
+    for (i = 0; i < cpu_count; i++) {
+        cpu_info->entries[i].address = i;
+        cpu_info->entries[i].type = 0;
+    }
+
+    sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
+}
+
 static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
@@ -50,6 +98,9 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
     case SCLP_CMDW_READ_SCP_INFO_FORCED:
         read_SCP_info(sccb);
         break;
+    case SCLP_CMDW_READ_CPU_INFO:
+        sclp_read_cpu_info(sccb);
+        break;
     default:
         sdev->sclp_command_handler(sdev->ef, sccb, code);
         break;
include/hw/s390x/sclp.h +0 -0
index 174097d..89ae7d1 100644

include/hw/s390x/sclp.h typedef struct SCCBHeader { · line 88

Quoted 10 lines
include/hw/s390x/sclp.h +7 -0
@@ -79,12 +79,44 @@ typedef struct SCCBHeader {
 
 #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
 
+/* CPU information */
+typedef struct CpuEntry {
+    uint8_t address;
+    uint8_t reserved0[13];
+    uint8_t type;
+    uint8_t reserved1;
+} QEMU_PACKED CpuEntry;

Feel free to use CPUEntry capitalization if this is not copied from a Linux struct of that name - your choice.

Andreas

Quoted 35 lines
include/hw/s390x/sclp.h +25 -0
+
 typedef struct ReadInfo {
     SCCBHeader h;
     uint16_t rnmax;
     uint8_t rnsize;
+    uint8_t  _reserved1[16 - 11];       /* 11-15 */
+    uint16_t entries_cpu;               /* 16-17 */
+    uint16_t offset_cpu;                /* 18-19 */
+    uint8_t  _reserved2[24 - 20];       /* 20-23 */
+    uint8_t  loadparm[8];               /* 24-31 */
+    uint8_t  _reserved3[48 - 32];       /* 32-47 */
+    uint64_t facilities;                /* 48-55 */
+    uint8_t  _reserved0[100 - 56];
+    uint32_t rnsize2;
+    uint64_t rnmax2;
+    uint8_t  _reserved4[120-112];       /* 112-119 */
+    uint16_t highest_cpu;
+    uint8_t  _reserved5[128 - 122];     /* 122-127 */
+    struct CpuEntry entries[0];
 } QEMU_PACKED ReadInfo;
 
+typedef struct ReadCpuInfo {
+    SCCBHeader h;
+    uint16_t nr_configured;         /* 8-9 */
+    uint16_t offset_configured;     /* 10-11 */
+    uint16_t nr_standby;            /* 12-13 */
+    uint16_t offset_standby;        /* 14-15 */
+    uint8_t reserved0[24-16];       /* 16-23 */
+    struct CpuEntry entries[0];
+} QEMU_PACKED ReadCpuInfo;
+
 typedef struct SCCB {
     SCCBHeader h;
     char data[SCCB_DATA_LEN];
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

RFC PATCH v3 3/8 s390-qemu: cpu hotplug - SCLP Event integration

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Add an sclp event for "cpu was hot plugged". This allows Qemu to deliver an SCLP interrupt to the guest stating that the requested cpu hotplug was completed.

---
 hw/s390x/Makefile.objs            |    2 +-
 hw/s390x/event-facility.c         |    7 +++
 hw/s390x/sclpcpu.c                |  120 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |    3 +
 include/hw/s390x/sclp.h           |    1 +
 5 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 hw/s390x/sclpcpu.c
hw/s390x/Makefile.objs +1 -1
index 77e1218..104ae8e 100644
@@ -2,7 +2,7 @@ obj-y = s390-virtio-bus.o s390-virtio.o
 obj-y += s390-virtio-hcall.o
 obj-y += sclp.o
 obj-y += event-facility.o
-obj-y += sclpquiesce.o
+obj-y += sclpquiesce.o sclpcpu.o
 obj-y += ipl.o
 obj-y += css.o
 obj-y += s390-virtio-ccw.o
hw/s390x/event-facility.c +7 -0
index 0faade0..aec35cb 100644
@@ -317,6 +317,7 @@ static int init_event_facility(S390SCLPDevice *sdev)
 {
     SCLPEventFacility *event_facility;
     DeviceState *quiesce;
+    DeviceState *cpu_hotplug;
 
     event_facility = g_malloc0(sizeof(SCLPEventFacility));
     sdev->ef = event_facility;
@@ -335,6 +336,12 @@ static int init_event_facility(S390SCLPDevice *sdev)
     }
     qdev_init_nofail(quiesce);
 
+    cpu_hotplug = qdev_create(&event_facility->sbus.qbus, "sclpcpuhotplug");
+    if (!cpu_hotplug) {
+        return -1;
+    }
+    qdev_init_nofail(cpu_hotplug);
+
     return 0;
 }
 
hw/s390x/sclpcpu.c new file +120 -0

120 lines not on this page · raw message

include/hw/s390x/event-facility.h +3 -0
index 791ab2a..d63969f 100644
@@ -17,14 +17,17 @@
 
 #include <hw/qdev.h>
 #include "qemu/thread.h"
+#include "hw/s390x/sclp.h"
 
 /* SCLP event types */
+#define SCLP_EVENT_CONFIG_MGT_DATA              0x04
 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
 
 /* SCLP event masks */
 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
+#define SCLP_EVENT_MASK_CONFIG_MGT_DATA         0x10000000
 
 #define SCLP_UNCONDITIONAL_READ                 0x00
 #define SCLP_SELECTIVE_READ                     0x01
include/hw/s390x/sclp.h +1 -0
index 89ae7d1..7728ad8 100644
@@ -154,5 +154,6 @@ typedef struct S390SCLPDeviceClass {
 
 void s390_sclp_init(void);
 void sclp_service_interrupt(uint32_t sccb);
+void raise_irq_cpu_hotplug(void);
 
 #endif
Signature · 1 line
1.7.10.4
#11 lore raw

Re: [Qemu-devel] [PATCH 3/8] [PATCH RFC v3] s390-qemu: cpu hotplug - SCLP Event integration

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 21 lines

From: "Jason J. Herne" <[email protected]>

Add an sclp event for "cpu was hot plugged". This allows Qemu to deliver an SCLP interrupt to the guest stating that the requested cpu hotplug was completed.

---
 hw/s390x/Makefile.objs            |    2 +-
 hw/s390x/event-facility.c         |    7 +++
 hw/s390x/sclpcpu.c                |  120 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |    3 +
 include/hw/s390x/sclp.h           |    1 +
 5 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 hw/s390x/sclpcpu.c
hw/s390x/Makefile.objs +0 -0
index 77e1218..104ae8e 100644

hw/s390x/Makefile.objs obj-y = s390-virtio-bus.o s390-virtio.o · line 5

Quoted 5 lines
hw/s390x/Makefile.objs +1 -1
@@ -2,7 +2,7 @@ obj-y = s390-virtio-bus.o s390-virtio.o
 obj-y += s390-virtio-hcall.o
 obj-y += sclp.o
 obj-y += event-facility.o
-obj-y += sclpquiesce.o
+obj-y += sclpquiesce.o sclpcpu.o

On a line of its own for consistency and to avoid '-' line?

Quoted 16 lines
hw/s390x/Makefile.objs +0 -0
 obj-y += ipl.o
 obj-y += css.o
 obj-y += s390-virtio-ccw.o
hw/s390x/event-facility.c +1 -0
index 0faade0..aec35cb 100644
@@ -317,6 +317,7 @@ static int init_event_facility(S390SCLPDevice *sdev)
 {
     SCLPEventFacility *event_facility;
     DeviceState *quiesce;
+    DeviceState *cpu_hotplug;
 
     event_facility = g_malloc0(sizeof(SCLPEventFacility));
     sdev->ef = event_facility;

hw/s390x/event-facility.c static int init_event_facility(S390SCLPDevice *sdev) · line 339

Quoted 4 lines
hw/s390x/event-facility.c +1 -0
@@ -335,6 +336,12 @@ static int init_event_facility(S390SCLPDevice *sdev)
     }
     qdev_init_nofail(quiesce);
 
+    cpu_hotplug = qdev_create(&event_facility->sbus.qbus, "sclpcpuhotplug");

Please don't create devices in such an init function. Also don't access .qbus please.

Instead, please use object_initialize() followed by qdev_set_parent_bus() in an instance_init function.

Conversion of the initfn to a realizefn will be a bit more involved so I won't ask that for this series, but if there were volunteers among your colleagues that would be appreciated. The effect would be to propagate errors to the caller of the realizefn rather than asserting here.

Quoted 19 lines
hw/s390x/event-facility.c +5 -0
+    if (!cpu_hotplug) {
+        return -1;
+    }
+    qdev_init_nofail(cpu_hotplug);
+
     return 0;
 }
 
hw/s390x/sclpcpu.c new file +5 -0
new file mode 100644
index 0000000..5b4139e
@@ -0,0 +1,120 @@
+/*
+ * SCLP event type
+ *    Signal CPU - Trigger SCLP interrupt for system CPU configure or
+ *    de-configure
+ *

hw/s390x/sclpcpu.c line 15

Quoted 10 lines
hw/s390x/sclpcpu.c new file +10 -0
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Thang Pham <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version.  See the COPYING file in the top-level directory.
+ *
+ */
+#include <hw/qdev.h>

"hw/qdev.h", but I'm guessing that's redundant with either sclp.h or event-facility.h?

Quoted 81 lines
hw/s390x/sclpcpu.c new file +81 -0
+#include "sysemu/sysemu.h"
+#include "hw/s390x/sclp.h"
+#include "hw/s390x/event-facility.h"
+#include "cpu.h"
+#include "sysemu/cpus.h"
+#include "sysemu/kvm.h"
+
+typedef struct ConfigMgtData {
+    EventBufferHeader ebh;
+    uint8_t reserved;
+    uint8_t event_qualifier;
+} QEMU_PACKED ConfigMgtData;
+
+static qemu_irq irq_cpu_hotplug; /* Only used in this file */
+
+#define EVENT_QUAL_CPU_CHANGE  1
+
+void raise_irq_cpu_hotplug(void)
+{
+    qemu_irq_raise(irq_cpu_hotplug);
+}
+
+static int event_type(void)
+{
+    return SCLP_EVENT_CONFIG_MGT_DATA;
+}
+
+static unsigned int send_mask(void)
+{
+    return SCLP_EVENT_MASK_CONFIG_MGT_DATA;
+}
+
+static unsigned int receive_mask(void)
+{
+    return 0;
+}
+
+static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
+                           int *slen)
+{
+    ConfigMgtData *cdata = (ConfigMgtData *) evt_buf_hdr;
+    if (*slen < sizeof(ConfigMgtData)) {
+        return 0;
+    }
+
+    /* Event is no longer pending */
+    if (!event->event_pending) {
+        return 0;
+    }
+    event->event_pending = false;
+
+    /* Event header data */
+    cdata->ebh.length = cpu_to_be16(sizeof(ConfigMgtData));
+    cdata->ebh.type = SCLP_EVENT_CONFIG_MGT_DATA;
+    cdata->ebh.flags |= SCLP_EVENT_BUFFER_ACCEPTED;
+
+    /* Trigger a rescan of CPUs by setting event qualifier */
+    cdata->event_qualifier = EVENT_QUAL_CPU_CHANGE;
+    *slen -= sizeof(ConfigMgtData);
+
+    return 1;
+}
+
+static void trigger_signal(void *opaque, int n, int level)
+{
+    SCLPEvent *event = opaque;
+    event->event_pending = true;
+
+    /* Trigger SCLP read operation */
+    sclp_service_interrupt(0);
+}
+
+static int irq_cpu_hotplug_init(SCLPEvent *event)
+{
+    irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
+    return 0;
+}
+
+static void cpu_class_init(ObjectClass *klass, void *data)
+{
+    SCLPEventClass *k = SCLP_EVENT_CLASS(klass);

hw/s390x/sclpcpu.c line 106

Quoted 10 lines
hw/s390x/sclpcpu.c new file +10 -0
+
+    k->init = irq_cpu_hotplug_init;
+    k->get_send_mask = send_mask;
+    k->get_receive_mask = receive_mask;
+    k->event_type = event_type;
+    k->read_event_data = read_event_data;
+    k->write_event_data = NULL;
+}
+
+static TypeInfo sclp_cpu_info = {

static const

hw/s390x/sclpcpu.c line 107

Quoted 1 line
hw/s390x/sclpcpu.c new file +1 -0
+    .name          = "sclpcpuhotplug",

Please use dashes rather than concatenation.

hw/s390x/sclpcpu.c line 120

Quoted 13 lines
hw/s390x/sclpcpu.c new file +13 -0
+    .parent        = TYPE_SCLP_EVENT,
+    .instance_size = sizeof(SCLPEvent),
+    .class_init    = cpu_class_init,
+    .class_size    = sizeof(SCLPEventClass),
+};
+
+static void register_types(void)
+{
+    type_register_static(&sclp_cpu_info);
+}
+
+type_init(register_types)
+

Trailing white line.

include/hw/s390x/event-facility.h line 18

Quoted 7 lines
include/hw/s390x/event-facility.h +0 -0
index 791ab2a..d63969f 100644
@@ -17,14 +17,17 @@
 
 #include <hw/qdev.h>

Ah, copy&paste and answer to the above. ;)

Quoted 21 lines
include/hw/s390x/event-facility.h +3 -0
 #include "qemu/thread.h"
+#include "hw/s390x/sclp.h"
 
 /* SCLP event types */
+#define SCLP_EVENT_CONFIG_MGT_DATA              0x04
 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
 
 /* SCLP event masks */
 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
+#define SCLP_EVENT_MASK_CONFIG_MGT_DATA         0x10000000
 
 #define SCLP_UNCONDITIONAL_READ                 0x00
 #define SCLP_SELECTIVE_READ                     0x01
include/hw/s390x/sclp.h +0 -0
index 89ae7d1..7728ad8 100644

include/hw/s390x/sclp.h typedef struct S390SCLPDeviceClass { · line 159

Quoted 6 lines
include/hw/s390x/sclp.h +1 -0
@@ -154,5 +154,6 @@ typedef struct S390SCLPDeviceClass {
 
 void s390_sclp_init(void);
 void sclp_service_interrupt(uint32_t sccb);
+void raise_irq_cpu_hotplug(void);
 
 #endif

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#12 lore raw

RFC PATCH v3 4/8 s390-qemu: cpu hotplug - Storage key global access

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Introduces global access to storage key data so we can set it for each cpu in the S390 cpu initialization routine.

---
 hw/s390x/s390-virtio-ccw.c |    5 ++---
 hw/s390x/s390-virtio.c     |   21 ++++++++++++++++-----
 hw/s390x/s390-virtio.h     |    2 +-
 target-s390x/cpu.h         |    4 ++++
 4 files changed, 23 insertions(+), 9 deletions(-)
hw/s390x/s390-virtio-ccw.c +2 -3
index aebbbf1..b469960 100644
@@ -65,7 +65,6 @@ static void ccw_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     int shift = 0;
-    uint8_t *storage_keys;
     int ret;
     VirtualCssBus *css_bus;
 
@@ -94,10 +93,10 @@ static void ccw_init(QEMUMachineInitArgs *args)
     memory_region_add_subregion(sysmem, 0, ram);
 
     /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
     /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
     if (kvm_enabled()) {
         kvm_s390_enable_css_support(s390_cpu_addr2state(0));
hw/s390x/s390-virtio.c +16 -5
index 439d732..21e9124 100644
@@ -123,6 +123,18 @@ static void s390_virtio_register_hcalls(void)
                                    s390_virtio_hcall_set_status);
 }
 
+static uint8_t *storage_keys;
+
+uint8_t *s390_get_storage_keys(void)
+{
+    return storage_keys;
+}
+
+void s390_alloc_storage_keys(ram_addr_t ram_size)
+{
+    storage_keys = g_malloc0(ram_size / TARGET_PAGE_SIZE);
+}
+
 /*
  * The number of running CPUs. On s390 a shutdown is the state of all CPUs
  * being either stopped or disabled (for interrupts) waiting. We have to
@@ -176,7 +188,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
     qdev_init_nofail(dev);
 }
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
+void s390_init_cpus(const char *cpu_model)
 {
     int i;
 
@@ -196,7 +208,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
         ipi_states[i] = cpu;
         cs->halted = 1;
         cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = storage_keys;
+        cpu->env.storage_keys = s390_get_storage_keys();
     }
 }
 
@@ -231,7 +243,6 @@ static void s390_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     int shift = 0;
-    uint8_t *storage_keys;
     void *virtio_region;
     hwaddr virtio_region_len;
     hwaddr virtio_region_start;
@@ -270,10 +281,10 @@ static void s390_init(QEMUMachineInitArgs *args)
                               virtio_region_len);
 
     /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
     /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
     /* Create VirtIO network adapters */
     s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390");
hw/s390x/s390-virtio.h +1 -1
index 5c405e7..c1cb042 100644
@@ -20,7 +20,7 @@
 typedef int (*s390_virtio_fn)(const uint64_t *args);
 void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys);
+void s390_init_cpus(const char *cpu_model);
 void s390_init_ipl_dev(const char *kernel_filename,
                        const char *kernel_cmdline,
                        const char *initrd_filename,
target-s390x/cpu.h +4 -0
index 65bef86..877eac7 100644
@@ -374,6 +374,10 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 {
 }
 #endif
+
+uint8_t *s390_get_storage_keys(void);
+void s390_alloc_storage_keys(ram_addr_t ram_size);
+
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 1 line
1.7.10.4
#13 lore raw

Re: [Qemu-devel] [PATCH 4/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Storage key global access

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 71 lines

From: "Jason J. Herne" <[email protected]>

Introduces global access to storage key data so we can set it for each cpu in the S390 cpu initialization routine.

---
 hw/s390x/s390-virtio-ccw.c |    5 ++---
 hw/s390x/s390-virtio.c     |   21 ++++++++++++++++-----
 hw/s390x/s390-virtio.h     |    2 +-
 target-s390x/cpu.h         |    4 ++++
 4 files changed, 23 insertions(+), 9 deletions(-)
hw/s390x/s390-virtio-ccw.c +2 -3
index aebbbf1..b469960 100644
@@ -65,7 +65,6 @@ static void ccw_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     int shift = 0;
-    uint8_t *storage_keys;
     int ret;
     VirtualCssBus *css_bus;
 
@@ -94,10 +93,10 @@ static void ccw_init(QEMUMachineInitArgs *args)
     memory_region_add_subregion(sysmem, 0, ram);
 
     /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
     /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
     if (kvm_enabled()) {
         kvm_s390_enable_css_support(s390_cpu_addr2state(0));
hw/s390x/s390-virtio.c +13 -1
index 439d732..21e9124 100644
@@ -123,6 +123,18 @@ static void s390_virtio_register_hcalls(void)
                                    s390_virtio_hcall_set_status);
 }
 
+static uint8_t *storage_keys;
+
+uint8_t *s390_get_storage_keys(void)
+{
+    return storage_keys;
+}
+
+void s390_alloc_storage_keys(ram_addr_t ram_size)
+{
+    storage_keys = g_malloc0(ram_size / TARGET_PAGE_SIZE);
+}
+
 /*
  * The number of running CPUs. On s390 a shutdown is the state of all CPUs
  * being either stopped or disabled (for interrupts) waiting. We have to
@@ -176,7 +188,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
     qdev_init_nofail(dev);
 }
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
+void s390_init_cpus(const char *cpu_model)
 {
     int i;
 

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) · line 211

Quoted 5 lines
hw/s390x/s390-virtio.c +1 -1
@@ -196,7 +208,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
         ipi_states[i] = cpu;
         cs->halted = 1;
         cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = storage_keys;
+        cpu->env.storage_keys = s390_get_storage_keys();

Why not go this from the CPU initfn? Is there any ccw- vs. non-ccw difference? Thinking about -device s390-cpu here. I believe it's safe to assume that machine init and thus allocation has run before the CPU is instantiated - possibly assert that.

Andreas

Quoted 53 lines
hw/s390x/s390-virtio.c +2 -3
     }
 }
 
@@ -231,7 +243,6 @@ static void s390_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     int shift = 0;
-    uint8_t *storage_keys;
     void *virtio_region;
     hwaddr virtio_region_len;
     hwaddr virtio_region_start;
@@ -270,10 +281,10 @@ static void s390_init(QEMUMachineInitArgs *args)
                               virtio_region_len);
 
     /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
     /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
     /* Create VirtIO network adapters */
     s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390");
hw/s390x/s390-virtio.h +1 -1
index 5c405e7..c1cb042 100644
@@ -20,7 +20,7 @@
 typedef int (*s390_virtio_fn)(const uint64_t *args);
 void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys);
+void s390_init_cpus(const char *cpu_model);
 void s390_init_ipl_dev(const char *kernel_filename,
                        const char *kernel_cmdline,
                        const char *initrd_filename,
target-s390x/cpu.h +4 -0
index 65bef86..877eac7 100644
@@ -374,6 +374,10 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 {
 }
 #endif
+
+uint8_t *s390_get_storage_keys(void);
+void s390_alloc_storage_keys(ram_addr_t ram_size);
+
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#14 lore raw

Re: [Qemu-devel] [PATCH 4/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Storage key global access

Quoted 35 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 34 lines

From: "Jason J. Herne" <[email protected]>

hw/s390x/s390-virtio.c +13 -1
index 439d732..21e9124 100644
@@ -123,6 +123,18 @@ static void s390_virtio_register_hcalls(void)
                                     s390_virtio_hcall_set_status);
  }
 
+static uint8_t *storage_keys;
+
+uint8_t *s390_get_storage_keys(void)
+{
+    return storage_keys;
+}
+
+void s390_alloc_storage_keys(ram_addr_t ram_size)
+{
+    storage_keys = g_malloc0(ram_size / TARGET_PAGE_SIZE);
+}
+
  /*
   * The number of running CPUs. On s390 a shutdown is the state of all CPUs
   * being either stopped or disabled (for interrupts) waiting. We have to
@@ -176,7 +188,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
      qdev_init_nofail(dev);
  }
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
+void s390_init_cpus(const char *cpu_model)
  {
      int i;
 
Quoted 13 lines

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) · line 211

Quoted 6 lines
hw/s390x/s390-virtio.c +1 -1
@@ -196,7 +208,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
          ipi_states[i] = cpu;
          cs->halted = 1;
          cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = storage_keys;
+        cpu->env.storage_keys = s390_get_storage_keys();

Why not go this from the CPU initfn? Is there any ccw- vs. non-ccw difference? Thinking about -device s390-cpu here. I believe it's safe to assume that machine init and thus allocation has run before the CPU is instantiated - possibly assert that.

Patch 6/8 does exactly that.

Signature · 1 line
-- Jason J. Herne ([email protected])
#15 lore raw

Re: [Qemu-devel] [PATCH 4/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Storage key global access

In reply to Jason J. Herne
Quoted 43 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Introduces global access to storage key data so we can set it for each cpu in the S390 cpu initialization routine.

---

hw/s390x/s390-virtio-ccw.c |    5 ++---
hw/s390x/s390-virtio.c     |   21 ++++++++++++++++-----
hw/s390x/s390-virtio.h     |    2 +-
target-s390x/cpu.h         |    4 ++++
4 files changed, 23 insertions(+), 9 deletions(-)
hw/s390x/s390-virtio-ccw.c +2 -3
index aebbbf1..b469960 100644
@@ -65,7 +65,6 @@ static void ccw_init(QEMUMachineInitArgs *args)
    MemoryRegion *sysmem = get_system_memory();
    MemoryRegion *ram = g_new(MemoryRegion, 1);
    int shift = 0;
-    uint8_t *storage_keys;
    int ret;
    VirtualCssBus *css_bus;
 
@@ -94,10 +93,10 @@ static void ccw_init(QEMUMachineInitArgs *args)
    memory_region_add_subregion(sysmem, 0, ram);
 
    /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
    /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
    if (kvm_enabled()) {
        kvm_s390_enable_css_support(s390_cpu_addr2state(0));
hw/s390x/s390-virtio.c +0 -0
index 439d732..21e9124 100644

hw/s390x/s390-virtio.c static void s390_virtio_register_hcalls(void) · line 130

Quoted 8 lines
hw/s390x/s390-virtio.c +5 -0
@@ -123,6 +123,18 @@ static void s390_virtio_register_hcalls(void)
                                   s390_virtio_hcall_set_status);
 }
 
+static uint8_t *storage_keys;
+
+uint8_t *s390_get_storage_keys(void)
+{
+    return storage_keys;

This is basically the same as having a global in my point of view. I would personally just make it a global and call it a day.

However, it might make sense to make storage keys be a device. That way you get direct access for free (you can ask for the device by-path) and you have somewhere to hook migration off of.

Alex

Quoted 80 lines
hw/s390x/s390-virtio.c +11 -5
+}
+
+void s390_alloc_storage_keys(ram_addr_t ram_size)
+{
+    storage_keys = g_malloc0(ram_size / TARGET_PAGE_SIZE);
+}
+
 /*
 * The number of running CPUs. On s390 a shutdown is the state of all CPUs
 * being either stopped or disabled (for interrupts) waiting. We have to
@@ -176,7 +188,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
    qdev_init_nofail(dev);
 }
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
+void s390_init_cpus(const char *cpu_model)
 {
    int i;
 
@@ -196,7 +208,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
        ipi_states[i] = cpu;
        cs->halted = 1;
        cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = storage_keys;
+        cpu->env.storage_keys = s390_get_storage_keys();
    }
 }
 
@@ -231,7 +243,6 @@ static void s390_init(QEMUMachineInitArgs *args)
    MemoryRegion *sysmem = get_system_memory();
    MemoryRegion *ram = g_new(MemoryRegion, 1);
    int shift = 0;
-    uint8_t *storage_keys;
    void *virtio_region;
    hwaddr virtio_region_len;
    hwaddr virtio_region_start;
@@ -270,10 +281,10 @@ static void s390_init(QEMUMachineInitArgs *args)
                              virtio_region_len);
 
    /* allocate storage keys */
-    storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
+    s390_alloc_storage_keys(my_ram_size);
 
    /* init CPUs */
-    s390_init_cpus(args->cpu_model, storage_keys);
+    s390_init_cpus(args->cpu_model);
 
    /* Create VirtIO network adapters */
    s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390");
hw/s390x/s390-virtio.h +1 -1
index 5c405e7..c1cb042 100644
@@ -20,7 +20,7 @@
 typedef int (*s390_virtio_fn)(const uint64_t *args);
 void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
 
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys);
+void s390_init_cpus(const char *cpu_model);
 void s390_init_ipl_dev(const char *kernel_filename,
                       const char *kernel_cmdline,
                       const char *initrd_filename,
target-s390x/cpu.h +4 -0
index 65bef86..877eac7 100644
@@ -374,6 +374,10 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 {
 }
 #endif
+
+uint8_t *s390_get_storage_keys(void);
+void s390_alloc_storage_keys(ram_addr_t ram_size);
+
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 1 line
1.7.10.4
#16 lore raw

RFC PATCH v3 5/8 s390-qemu: cpu hotplug - ipi_states enhancements

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Modify s390_cpu_addr2state to allow fetching state information for cpu addresses above smp_cpus. Hotplug requires this capability.

Also add s390_cpu_set_state function to allow modification of ipi_state entries during hotplug.

---
 hw/s390x/s390-virtio.c |    9 +++++----
 target-s390x/cpu.h     |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
hw/s390x/s390-virtio.c +5 -4
index 21e9124..5ad9cf3 100644
@@ -54,12 +54,13 @@
 static VirtIOS390Bus *s390_bus;
 static S390CPU **ipi_states;
 
-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    if (cpu_addr >= smp_cpus) {
-        return NULL;
-    }
+    ipi_states[cpu_addr] = state;
+}
 
+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+{
     return ipi_states[cpu_addr];
 }
 
target-s390x/cpu.h +1 -1
index 877eac7..62eb810 100644
@@ -377,7 +377,7 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 
 uint8_t *s390_get_storage_keys(void);
 void s390_alloc_storage_keys(ram_addr_t ram_size);
-
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state);
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 1 line
1.7.10.4
#17 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 26 lines

From: "Jason J. Herne" <[email protected]>

Modify s390_cpu_addr2state to allow fetching state information for cpu addresses above smp_cpus. Hotplug requires this capability.

Also add s390_cpu_set_state function to allow modification of ipi_state entries during hotplug.

---
 hw/s390x/s390-virtio.c |    9 +++++----
 target-s390x/cpu.h     |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
hw/s390x/s390-virtio.c +1 -2
index 21e9124..5ad9cf3 100644
@@ -54,12 +54,13 @@
 static VirtIOS390Bus *s390_bus;
 static S390CPU **ipi_states;
 
-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    if (cpu_addr >= smp_cpus) {

hw/s390x/s390-virtio.c line 66

Quoted 10 lines
hw/s390x/s390-virtio.c +4 -2
-        return NULL;
-    }
+    ipi_states[cpu_addr] = state;
+}
 
+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+{
     return ipi_states[cpu_addr];
 }
 

This is what got us into the link<> discussion last time. If we do

for (i = 0; i < ARRAY_SIZE(ipi_states); i++) {
    name = g_strdup_printf("cpu[%i]", i);
    object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                             &ipi_states[i], &err);
}

then we get said /machine/cpu[n] link<> properties, at a QMP level either returning nothing or the canonical path to the CPU object.

On IRC I didn't get an answer of whether it was being done the above way because there is infrastructure missing, and a look at object.h now confirms that suspicion. CC'ing Anthony and Paolo.

Since object_property_add_link() uses a NULL opaque, my idea would be to add a single setter hook argument passed through as opaque to object_set_link_property(), which would call it with the old and the new value.

The purpose would be to avoid growing our own internal setter API, which is disjoint from the QMP qom-set we are targetting at.

Regards,
Andreas

Quoted 14 lines
target-s390x/cpu.h +1 -1
index 877eac7..62eb810 100644
@@ -377,7 +377,7 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 
 uint8_t *s390_get_storage_keys(void);
 void s390_alloc_storage_keys(ram_addr_t ram_size);
-
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state);
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#18 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

Quoted 53 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 26 lines

From: "Jason J. Herne" <[email protected]>

Modify s390_cpu_addr2state to allow fetching state information for cpu addresses above smp_cpus. Hotplug requires this capability.

Also add s390_cpu_set_state function to allow modification of ipi_state entries during hotplug.

---
  hw/s390x/s390-virtio.c |    9 +++++----
  target-s390x/cpu.h     |    2 +-
  2 files changed, 6 insertions(+), 5 deletions(-)
hw/s390x/s390-virtio.c +1 -2
index 21e9124..5ad9cf3 100644
@@ -54,12 +54,13 @@
  static VirtIOS390Bus *s390_bus;
  static S390CPU **ipi_states;
 
-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
  {
-    if (cpu_addr >= smp_cpus) {

hw/s390x/s390-virtio.c line 66

Quoted 10 lines
hw/s390x/s390-virtio.c +4 -2
-        return NULL;
-    }
+    ipi_states[cpu_addr] = state;
+}
 
+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+{
      return ipi_states[cpu_addr];
  }
 

This is what got us into the link<> discussion last time. If we do

for (i = 0; i < ARRAY_SIZE(ipi_states); i++) {
     name = g_strdup_printf("cpu[%i]", i);
     object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                              &ipi_states[i], &err);
}

then we get said /machine/cpu[n] link<> properties, at a QMP level either returning nothing or the canonical path to the CPU object.

On IRC I didn't get an answer of whether it was being done the above way because there is infrastructure missing, and a look at object.h now confirms that suspicion. CC'ing Anthony and Paolo.

Quoted 8 lines

Since object_property_add_link() uses a NULL opaque, my idea would be to add a single setter hook argument passed through as opaque to object_set_link_property(), which would call it with the old and the new value.

The purpose would be to avoid growing our own internal setter API, which is disjoint from the QMP qom-set we are targetting at.

Ok, you lost me :). I must admit my understanding of QOM is still limited. Sorry for not keeping up. Why do we need this new hook? The link would contain a pointer to the correct ipi_states entry right? What are we using opaque for?

Signature · 1 line
-- Jason J. Herne ([email protected])
#19 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

In reply to Andreas Färber
Quoted 3 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 2 lines

From: "Jason J. Herne" <[email protected]>

...

Quoted 16 lines

This is what got us into the link<> discussion last time. If we do

for (i = 0; i < ARRAY_SIZE(ipi_states); i++) {
     name = g_strdup_printf("cpu[%i]", i);
     object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                              &ipi_states[i], &err);
}

then we get said /machine/cpu[n] link<> properties, at a QMP level either returning nothing or the canonical path to the CPU object.

On IRC I didn't get an answer of whether it was being done the above way because there is infrastructure missing, and a look at object.h now confirms that suspicion. CC'ing Anthony and Paolo.

Quoted 7 lines

Since object_property_add_link() uses a NULL opaque, my idea would be to add a single setter hook argument passed through as opaque to object_set_link_property(), which would call it with the old and the new value.

The purpose would be to avoid growing our own internal setter API, which is disjoint from the QMP qom-set we are targetting at.

I wrote the code, very close to how you suggested and it appears to be working when tested with qom-list. I'm still not certain why we need the ability to set the opaque of object_set_link_property()?

For reference here is what I did:

void s390_init_cpus(const char *cpu_model)

{
    int i;
    char* name;

    if (cpu_model == NULL) {
        cpu_model = "host";
    }

    ipi_states = g_malloc0(sizeof(S390CPU *) * max_cpus);

    for (i = 0; i < max_cpus; i++) {
        name = g_strdup_printf("cpu[%i]", i);
        object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                                 (Object **)&ipi_states[i], NULL);
    }

    for (i = 0; i < smp_cpus; i++) {
        cpu_s390x_init(cpu_model);
    }
}

Yep, I know cpu_model is going away ;).

Signature · 1 line
-- Jason J. Herne ([email protected])
#20 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

Quoted 57 lines · On Thu, 19 Sep 2013 16:19:46 -0400 "Jason J. Herne"…
Quoted 3 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 2 lines

From: "Jason J. Herne" <[email protected]>

...

Quoted 16 lines

This is what got us into the link<> discussion last time. If we do

for (i = 0; i < ARRAY_SIZE(ipi_states); i++) {
     name = g_strdup_printf("cpu[%i]", i);
     object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                              &ipi_states[i], &err);
}

then we get said /machine/cpu[n] link<> properties, at a QMP level either returning nothing or the canonical path to the CPU object.

On IRC I didn't get an answer of whether it was being done the above way because there is infrastructure missing, and a look at object.h now confirms that suspicion. CC'ing Anthony and Paolo.

Quoted 7 lines

Since object_property_add_link() uses a NULL opaque, my idea would be to add a single setter hook argument passed through as opaque to object_set_link_property(), which would call it with the old and the new value.

The purpose would be to avoid growing our own internal setter API, which is disjoint from the QMP qom-set we are targetting at.

I wrote the code, very close to how you suggested and it appears to be working when tested with qom-list. I'm still not certain why we need the ability to set the opaque of object_set_link_property()?

For reference here is what I did:

void s390_init_cpus(const char *cpu_model)

{
     int i;
     char* name;

     if (cpu_model == NULL) {
         cpu_model = "host";
     }

     ipi_states = g_malloc0(sizeof(S390CPU *) * max_cpus);

     for (i = 0; i < max_cpus; i++) {
         name = g_strdup_printf("cpu[%i]", i);
         object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                                  (Object **)&ipi_states[i], NULL);
     }

     for (i = 0; i < smp_cpus; i++) {
         cpu_s390x_init(cpu_model);
     }
}
Quoted 1 line

Yep, I know cpu_model is going away ;).

Jason, do you have more information how cpu modeling or at least the parameterization will be managed in future? I'm close to finishing a patch that introduces S390 cpu models and need to know all this more precisely. Is there any document or discussion you can point me to. Thanks a lot.

Michael

Quoted 1 line
#21 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

In reply to Jason J. Herne
Quoted 57 lines · Jason J. Herne
Quoted 3 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 2 lines

From: "Jason J. Herne" <[email protected]>

...

Quoted 16 lines

This is what got us into the link<> discussion last time. If we do

for (i = 0; i < ARRAY_SIZE(ipi_states); i++) {
     name = g_strdup_printf("cpu[%i]", i);
     object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                              &ipi_states[i], &err);
}

then we get said /machine/cpu[n] link<> properties, at a QMP level either returning nothing or the canonical path to the CPU object.

On IRC I didn't get an answer of whether it was being done the above way because there is infrastructure missing, and a look at object.h now confirms that suspicion. CC'ing Anthony and Paolo.

Quoted 7 lines

Since object_property_add_link() uses a NULL opaque, my idea would be to add a single setter hook argument passed through as opaque to object_set_link_property(), which would call it with the old and the new value.

The purpose would be to avoid growing our own internal setter API, which is disjoint from the QMP qom-set we are targetting at.

I wrote the code, very close to how you suggested and it appears to be working when tested with qom-list. I'm still not certain why we need the ability to set the opaque of object_set_link_property()?

For reference here is what I did:

void s390_init_cpus(const char *cpu_model)

{
     int i;
     char* name;

     if (cpu_model == NULL) {
         cpu_model = "host";
     }

     ipi_states = g_malloc0(sizeof(S390CPU *) * max_cpus);

     for (i = 0; i < max_cpus; i++) {
         name = g_strdup_printf("cpu[%i]", i);
         object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
                                  (Object **)&ipi_states[i], NULL);
     }

     for (i = 0; i < smp_cpus; i++) {
         cpu_s390x_init(cpu_model);
     }
}
Quoted 2 lines

Yep, I know cpu_model is going away ;).

Ping? :)

Signature · 1 line
-- Jason J. Herne ([email protected])
#22 lore raw

Re: [Qemu-devel] [PATCH 5/8] [PATCH RFC v3] s390-qemu: cpu hotplug - ipi_states enhancements

In reply to Jason J. Herne
Quoted 19 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Modify s390_cpu_addr2state to allow fetching state information for cpu addresses above smp_cpus. Hotplug requires this capability.

Also add s390_cpu_set_state function to allow modification of ipi_state entries during hotplug.

---

hw/s390x/s390-virtio.c |    9 +++++----
target-s390x/cpu.h     |    2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
hw/s390x/s390-virtio.c +0 -0
index 21e9124..5ad9cf3 100644

hw/s390x/s390-virtio.c line 59

Quoted 10 lines
hw/s390x/s390-virtio.c +2 -4
@@ -54,12 +54,13 @@
 static VirtIOS390Bus *s390_bus;
 static S390CPU **ipi_states;
 
-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    if (cpu_addr >= smp_cpus) {
-        return NULL;
-    }
+    ipi_states[cpu_addr] = state;

We should still ensure that we don't access anything beyond the size of the array, no?

Alex

Quoted 23 lines
hw/s390x/s390-virtio.c +3 -0
+}
 
+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+{
    return ipi_states[cpu_addr];
 }
 
target-s390x/cpu.h +1 -1
index 877eac7..62eb810 100644
@@ -377,7 +377,7 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
 
 uint8_t *s390_get_storage_keys(void);
 void s390_alloc_storage_keys(ram_addr_t ram_size);
-
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state);
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
Signature · 1 line
1.7.10.4
#23 lore raw

RFC PATCH v3 6/8 s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

s390_new_cpu is created to encapsulate the creation of a new QOM S390CPU object given a cpuid and a model string.

All actual cpu initialization code is moved from boot time specific functions to s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is done to allow us to use the same basic code path for a cpu created at boot time and one created during a hotplug operation.

---
 hw/s390x/s390-virtio.c |   25 ++++++++++++-------------
 target-s390x/cpu.c     |    4 ++--
 target-s390x/cpu.h     |    1 +
 target-s390x/helper.c  |   12 ++++++++++++
 4 files changed, 27 insertions(+), 15 deletions(-)
hw/s390x/s390-virtio.c +12 -13
index 5ad9cf3..103f32e 100644
@@ -56,11 +56,16 @@ static S390CPU **ipi_states;
 
 void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    ipi_states[cpu_addr] = state;
+    if (cpu_addr < max_cpus) {
+        ipi_states[cpu_addr] = state;
+    }
 }
 
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
 {
+    if (cpu_addr >= max_cpus) {
+        return NULL;
+    }
     return ipi_states[cpu_addr];
 }
 
@@ -197,19 +202,13 @@ void s390_init_cpus(const char *cpu_model)
         cpu_model = "host";
     }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-        CPUState *cs;
+    ipi_states = g_malloc(sizeof(S390CPU *) * max_cpus);
 
-        cpu = cpu_s390x_init(cpu_model);
-        cs = CPU(cpu);
-
-        ipi_states[i] = cpu;
-        cs->halted = 1;
-        cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = s390_get_storage_keys();
+    for (i = 0; i < max_cpus; i++) {
+        ipi_states[i] = NULL;
+        if (i < smp_cpus) {
+            s390_new_cpu(cpu_model, i);
+        }
     }
 }
 
target-s390x/cpu.c +2 -2
index 6be6c08..c90a91c 100644
@@ -116,7 +116,6 @@ static void s390_cpu_initfn(Object *obj)
     S390CPU *cpu = S390_CPU(obj);
     CPUS390XState *env = &cpu->env;
     static bool inited;
-    static int cpu_num = 0;
 #if !defined(CONFIG_USER_ONLY)
     struct tm tm;
 #endif
@@ -135,8 +134,9 @@ static void s390_cpu_initfn(Object *obj)
      * cpu counter in s390_cpu_reset to a negative number at
      * initial ipl */
     cs->halted = 1;
+    cpu->env.exception_index = EXCP_HLT;
+    env->storage_keys = s390_get_storage_keys();
 #endif
-    env->cpu_num = cpu_num++;
     env->ext_index = -1;
 
     if (tcg_enabled() && !inited) {
target-s390x/cpu.h +1 -0
index 62eb810..0f68dd0 100644
@@ -315,6 +315,7 @@ static inline int get_ilen(uint8_t opc)
 #endif
 
 S390CPU *cpu_s390x_init(const char *cpu_model);
+S390CPU *s390_new_cpu(const char *cpu_model, int64_t cpuid);
 void s390x_translate_init(void);
 int cpu_s390x_exec(CPUS390XState *s);
 
target-s390x/helper.c +12 -0
index 61abfd7..a39b148 100644
@@ -70,6 +70,18 @@ void s390x_cpu_timer(void *opaque)
 }
 #endif
 
+S390CPU *s390_new_cpu(const char *cpu_model, int64_t cpuid)
+{
+    S390CPU *cpu;
+
+    cpu = cpu_s390x_init(cpu_model);
+    cpu->env.cpu_num = cpuid;
+#if !defined(CONFIG_USER_ONLY)
+    s390_cpu_set_ipistate(cpuid, cpu);
+#endif
+    return cpu;
+}
+
 S390CPU *cpu_s390x_init(const char *cpu_model)
 {
     S390CPU *cpu;
Signature · 1 line
1.7.10.4
#24 lore raw

Re: [Qemu-devel] [PATCH 6/8] [PATCH RFC v3] s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 9 lines

From: "Jason J. Herne" <[email protected]>

s390_new_cpu is created to encapsulate the creation of a new QOM S390CPU object given a cpuid and a model string.

All actual cpu initialization code is moved from boot time specific functions to s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is done to allow us to use the same basic code path for a cpu created at boot time and one created during a hotplug operation.

Intentionally indented?

Quoted 41 lines
---
 hw/s390x/s390-virtio.c |   25 ++++++++++++-------------
 target-s390x/cpu.c     |    4 ++--
 target-s390x/cpu.h     |    1 +
 target-s390x/helper.c  |   12 ++++++++++++
 4 files changed, 27 insertions(+), 15 deletions(-)
hw/s390x/s390-virtio.c +7 -6
index 5ad9cf3..103f32e 100644
@@ -56,11 +56,16 @@ static S390CPU **ipi_states;
 
 void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    ipi_states[cpu_addr] = state;
+    if (cpu_addr < max_cpus) {
+        ipi_states[cpu_addr] = state;
+    }
 }
 
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
 {
+    if (cpu_addr >= max_cpus) {
+        return NULL;
+    }
     return ipi_states[cpu_addr];
 }
 
@@ -197,19 +202,13 @@ void s390_init_cpus(const char *cpu_model)
         cpu_model = "host";
     }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-        CPUState *cs;
+    ipi_states = g_malloc(sizeof(S390CPU *) * max_cpus);

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model) · line 208

Quoted 10 lines
hw/s390x/s390-virtio.c +2 -7
 
-        cpu = cpu_s390x_init(cpu_model);
-        cs = CPU(cpu);
-
-        ipi_states[i] = cpu;
-        cs->halted = 1;
-        cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = s390_get_storage_keys();
+    for (i = 0; i < max_cpus; i++) {
+        ipi_states[i] = NULL;

Using g_malloc0() above would hopefully be more efficient and would allow to leave the loop untouched for easier review.

Quoted 19 lines
hw/s390x/s390-virtio.c +3 -0
+        if (i < smp_cpus) {
+            s390_new_cpu(cpu_model, i);
+        }
     }
 }
 
target-s390x/cpu.c +0 -1
index 6be6c08..c90a91c 100644
@@ -116,7 +116,6 @@ static void s390_cpu_initfn(Object *obj)
     S390CPU *cpu = S390_CPU(obj);
     CPUS390XState *env = &cpu->env;
     static bool inited;
-    static int cpu_num = 0;
 #if !defined(CONFIG_USER_ONLY)
     struct tm tm;
 #endif

target-s390x/cpu.c static void s390_cpu_initfn(Object *obj) · line 138

Quoted 5 lines
target-s390x/cpu.c +2 -0
@@ -135,8 +134,9 @@ static void s390_cpu_initfn(Object *obj)
      * cpu counter in s390_cpu_reset to a negative number at
      * initial ipl */
     cs->halted = 1;
+    cpu->env.exception_index = EXCP_HLT;
+    env->storage_keys = s390_get_storage_keys();

4/8?

Quoted 22 lines
target-s390x/cpu.c +0 -1
 #endif
-    env->cpu_num = cpu_num++;
     env->ext_index = -1;
 
     if (tcg_enabled() && !inited) {
target-s390x/cpu.h +1 -0
index 62eb810..0f68dd0 100644
@@ -315,6 +315,7 @@ static inline int get_ilen(uint8_t opc)
 #endif
 
 S390CPU *cpu_s390x_init(const char *cpu_model);
+S390CPU *s390_new_cpu(const char *cpu_model, int64_t cpuid);
 void s390x_translate_init(void);
 int cpu_s390x_exec(CPUS390XState *s);
 
target-s390x/helper.c +0 -0
index 61abfd7..a39b148 100644

target-s390x/helper.c void s390x_cpu_timer(void *opaque) · line 73

Quoted 4 lines
target-s390x/helper.c +1 -0
@@ -70,6 +70,18 @@ void s390x_cpu_timer(void *opaque)
 }
 #endif
 
+S390CPU *s390_new_cpu(const char *cpu_model, int64_t cpuid)

Like I said on IRC, I'm not so fond of copying x86 workarounds here... x86 does not have a fully QOM'ified CPU, s390x does.

target-s390x/helper.c void s390x_cpu_timer(void *opaque) · line 78

Quoted 5 lines
target-s390x/helper.c +5 -0
+{
+    S390CPU *cpu;
+
+    cpu = cpu_s390x_init(cpu_model);
+    cpu->env.cpu_num = cpuid;

linux-user never calls s390_new_cpu(), so it will change behavior in always having cpu_num of 0. I guess we can live with that but such a change needs to be mentioned in the commit message at least.

Why is this moved to after CPU init? Can't we just override the field if need be? Either Jens or Christian said that we would not want to fill up holes in ipi_tables to have the CPU address be always unique; which would mean that it would always be counting as before. if we need to tweak it, we should add a property to be able to set it from command line and QMP.

This affects migration btw: We would need to migrate the current or next CPU address since the last CPU might've been hot-unplugged so that next CPU address != last non-NULL ipi_states[] slot plus one.

target-s390x/helper.c void s390x_cpu_timer(void *opaque) · line 81

Quoted 3 lines
target-s390x/helper.c +3 -0
+#if !defined(CONFIG_USER_ONLY)
+    s390_cpu_set_ipistate(cpuid, cpu);
+#endif

...leaving only this then. Why not do this from the CPU realizefn so that errors actually can be propagated? If cpuid >= max_cpus the above will silently do nothing.

In that case we don't need this function any longer.

target-s390x/helper.c void s390x_cpu_timer(void *opaque) · line 87

Quoted 6 lines
target-s390x/helper.c +3 -0
+    return cpu;
+}
+
 S390CPU *cpu_s390x_init(const char *cpu_model)
 {
     S390CPU *cpu;

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#25 lore raw

Re: [Qemu-devel] [PATCH 6/8] [PATCH RFC v3] s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug

Quoted 26 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 9 lines

From: "Jason J. Herne" <[email protected]>

s390_new_cpu is created to encapsulate the creation of a new QOM S390CPU object given a cpuid and a model string.

All actual cpu initialization code is moved from boot time specific functions to s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is done to allow us to use the same basic code path for a cpu created at boot time and one created during a hotplug operation.

Intentionally indented?

Quoted 13 lines
---
  hw/s390x/s390-virtio.c |   25 ++++++++++++-------------
  target-s390x/cpu.c     |    4 ++--
  target-s390x/cpu.h     |    1 +
  target-s390x/helper.c  |   12 ++++++++++++
  4 files changed, 27 insertions(+), 15 deletions(-)
hw/s390x/s390-virtio.c +0 -0
index 5ad9cf3..103f32e 100644

...

Quoted 11 lines
Quoted 11 lines
hw/s390x/s390-virtio.c +1 -5
@@ -197,19 +202,13 @@ void s390_init_cpus(const char *cpu_model)
          cpu_model = "host";
      }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-        CPUState *cs;
+    ipi_states = g_malloc(sizeof(S390CPU *) * max_cpus);
 
Quoted 13 lines

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model) · line 208

Quoted 9 lines
hw/s390x/s390-virtio.c +2 -7
-        cpu = cpu_s390x_init(cpu_model);
-        cs = CPU(cpu);
-
-        ipi_states[i] = cpu;
-        cs->halted = 1;
-        cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = s390_get_storage_keys();
+    for (i = 0; i < max_cpus; i++) {
+        ipi_states[i] = NULL;

Using g_malloc0() above would hopefully be more efficient and would allow to leave the loop untouched for easier review.

I don't follow. I'm completely changing this loop. I do not believe we can obtain the same functionality implemented here while not touching the loop.

Quoted 18 lines
Quoted 18 lines
hw/s390x/s390-virtio.c +3 -0
+        if (i < smp_cpus) {
+            s390_new_cpu(cpu_model, i);
+        }
      }
  }
 
target-s390x/cpu.c +0 -1
index 6be6c08..c90a91c 100644
@@ -116,7 +116,6 @@ static void s390_cpu_initfn(Object *obj)
      S390CPU *cpu = S390_CPU(obj);
      CPUS390XState *env = &cpu->env;
      static bool inited;
-    static int cpu_num = 0;
  #if !defined(CONFIG_USER_ONLY)
      struct tm tm;
  #endif
Quoted 9 lines

target-s390x/cpu.c static void s390_cpu_initfn(Object *obj) · line 138

Quoted 6 lines
target-s390x/cpu.c +2 -0
@@ -135,8 +134,9 @@ static void s390_cpu_initfn(Object *obj)
       * cpu counter in s390_cpu_reset to a negative number at
       * initial ipl */
      cs->halted = 1;
+    cpu->env.exception_index = EXCP_HLT;
+    env->storage_keys = s390_get_storage_keys();

4/8?

Are you asking if this belongs in patch #4? if so, I would say no. It does deal with storage keys, yes. But we're not changing storage key semantics here (as we are in patch 4), we're just moving where the storage key ptr gets set. This is in support of re-organizing how cpus are initialized as per patch title/description.

Signature · 1 line
-- Jason J. Herne ([email protected])
#26 lore raw

Re: [Qemu-devel] [PATCH 6/8] [PATCH RFC v3] s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug

Quoted 89 lines · Jason J. Herne
Quoted 30 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 6 lines

From: "Jason J. Herne" <[email protected]>

s390_new_cpu is created to encapsulate the creation of a new QOM
S390CPU
object given a cpuid and a model string.

Quoted 7 lines

All actual cpu initialization code is moved from boot time
specific functions to
s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is
done to allow us
to use the same basic code path for a cpu created at boot time
and one created
during a hotplug operation.

Intentionally indented?

Quoted 13 lines
---
  hw/s390x/s390-virtio.c |   25 ++++++++++++-------------
  target-s390x/cpu.c     |    4 ++--
  target-s390x/cpu.h     |    1 +
  target-s390x/helper.c  |   12 ++++++++++++
  4 files changed, 27 insertions(+), 15 deletions(-)
hw/s390x/s390-virtio.c +0 -0
index 5ad9cf3..103f32e 100644

...

Quoted 11 lines
Quoted 11 lines
hw/s390x/s390-virtio.c +1 -5
@@ -197,19 +202,13 @@ void s390_init_cpus(const char *cpu_model)
          cpu_model = "host";
      }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-        CPUState *cs;
+    ipi_states = g_malloc(sizeof(S390CPU *) * max_cpus);
 
Quoted 13 lines

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model) · line 208

Quoted 9 lines
hw/s390x/s390-virtio.c +2 -7
-        cpu = cpu_s390x_init(cpu_model);
-        cs = CPU(cpu);
-
-        ipi_states[i] = cpu;
-        cs->halted = 1;
-        cpu->env.exception_index = EXCP_HLT;
-        cpu->env.storage_keys = s390_get_storage_keys();
+    for (i = 0; i < max_cpus; i++) {
+        ipi_states[i] = NULL;

Using g_malloc0() above would hopefully be more efficient and would allow to leave the loop untouched for easier review.

I don't follow. I'm completely changing this loop. I do not believe we can obtain the same functionality implemented here while not touching the loop.

Quoted 18 lines
Quoted 18 lines
hw/s390x/s390-virtio.c +3 -0
+        if (i < smp_cpus) {
+            s390_new_cpu(cpu_model, i);
+        }
      }
  }
 
target-s390x/cpu.c +0 -1
index 6be6c08..c90a91c 100644
@@ -116,7 +116,6 @@ static void s390_cpu_initfn(Object *obj)
      S390CPU *cpu = S390_CPU(obj);
      CPUS390XState *env = &cpu->env;
      static bool inited;
-    static int cpu_num = 0;
  #if !defined(CONFIG_USER_ONLY)
      struct tm tm;
  #endif
Quoted 9 lines

target-s390x/cpu.c static void s390_cpu_initfn(Object *obj) · line 138

Quoted 6 lines
target-s390x/cpu.c +2 -0
@@ -135,8 +134,9 @@ static void s390_cpu_initfn(Object *obj)
       * cpu counter in s390_cpu_reset to a negative number at
       * initial ipl */
      cs->halted = 1;
+    cpu->env.exception_index = EXCP_HLT;
+    env->storage_keys = s390_get_storage_keys();

4/8?

Quoted 6 lines

Are you asking if this belongs in patch #4? if so, I would say no. It does deal with storage keys, yes. But we're not changing storage key semantics here (as we are in patch 4), we're just moving where the storage key ptr gets set. This is in support of re-organizing how cpus are initialized as per patch title/description.

Ping? :)

Signature · 1 line
-- Jason J. Herne ([email protected])
#27 lore raw

Re: [Qemu-devel] [PATCH 6/8] [PATCH RFC v3] s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug

In reply to Jason J. Herne
Quoted 23 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

s390_new_cpu is created to encapsulate the creation of a new QOM S390CPU object given a cpuid and a model string.

All actual cpu initialization code is moved from boot time specific functions to s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is done to allow us to use the same basic code path for a cpu created at boot time and one created during a hotplug operation.

---

hw/s390x/s390-virtio.c |   25 ++++++++++++-------------
target-s390x/cpu.c     |    4 ++--
target-s390x/cpu.h     |    1 +
target-s390x/helper.c  |   12 ++++++++++++
4 files changed, 27 insertions(+), 15 deletions(-)
hw/s390x/s390-virtio.c +0 -0
index 5ad9cf3..103f32e 100644

hw/s390x/s390-virtio.c static S390CPU **ipi_states; · line 59

Quoted 5 lines
hw/s390x/s390-virtio.c +1 -1
@@ -56,11 +56,16 @@ static S390CPU **ipi_states;
 
 void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
 {
-    ipi_states[cpu_addr] = state;
+    if (cpu_addr < max_cpus) {

Ah, here you add the checks back in. Works for me.

Quoted 13 lines
hw/s390x/s390-virtio.c +5 -0
+        ipi_states[cpu_addr] = state;
+    }
 }
 
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
 {
+    if (cpu_addr >= max_cpus) {
+        return NULL;
+    }
    return ipi_states[cpu_addr];
 }
 

hw/s390x/s390-virtio.c void s390_init_cpus(const char *cpu_model) · line 205

Quoted 9 lines
hw/s390x/s390-virtio.c +1 -5
@@ -197,19 +202,13 @@ void s390_init_cpus(const char *cpu_model)
        cpu_model = "host";
    }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-        CPUState *cs;
+    ipi_states = g_malloc(sizeof(S390CPU *) * max_cpus);

g_new is easier :).

Alex

#28 lore raw

RFC PATCH v3 7/8 s390-qemu: cpu hotplug - Implement hot_add_cpu hook

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Implement hot_add_cpu for S390 to allow hot plugging of cpus.

---
 hw/s390x/s390-virtio-ccw.c |    3 +++
 target-s390x/cpu.c         |   32 ++++++++++++++++++++++++++++++++
 target-s390x/cpu.h         |    2 ++
 3 files changed, 37 insertions(+)
hw/s390x/s390-virtio-ccw.c +3 -0
index b469960..30b6a48 100644
@@ -117,6 +117,9 @@ static QEMUMachine ccw_machine = {
     .alias = "s390-ccw",
     .desc = "VirtIO-ccw based S390 machine",
     .init = ccw_init,
+#if !defined(CONFIG_USER_ONLY)
+    .hot_add_cpu = ccw_hot_add_cpu,
+#endif
     .block_default_type = IF_VIRTIO,
     .no_cdrom = 1,
     .no_floppy = 1,
target-s390x/cpu.c +32 -0
index c90a91c..60029d9 100644
@@ -27,6 +27,8 @@
 #include "qemu-common.h"
 #include "qemu/timer.h"
 #include "hw/hw.h"
+#include "hw/s390x/sclp.h"
+#include "sysemu/sysemu.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
 #endif
@@ -154,6 +156,36 @@ static void s390_cpu_finalize(Object *obj)
 #endif
 }
 
+#if !defined(CONFIG_USER_ONLY)
+void ccw_hot_add_cpu(const int64_t id, Error **errp)
+{
+    S390CPU *new_cpu;
+    CPUState *cpu;
+    const char *model_str;
+    int cpu_count = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {
+        cpu_count++;
+    }
+
+    if (cpu_count == max_cpus) {
+        error_setg(errp, "Maximum number of cpus already defined");
+        return;
+    }
+
+    if (id != cpu_count) {
+        error_setg(errp, "Unable to add CPU: %" PRIi64
+                   ", The next available id is %d", id, cpu_count);
+        return;
+    }
+
+    model_str = s390_cpu_addr2state(0)->env.cpu_model_str;
+    new_cpu = s390_new_cpu(model_str, id);
+    object_property_set_bool(OBJECT(new_cpu), true, "realized", NULL);
+    raise_irq_cpu_hotplug();
+}
+#endif
+
 static const VMStateDescription vmstate_s390_cpu = {
     .name = "cpu",
     .unmigratable = 1,
target-s390x/cpu.h +2 -0
index 0f68dd0..711aad4 100644
@@ -383,6 +383,8 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
 
+void ccw_hot_add_cpu(const int64_t id, Error **errp);
+
 /* service interrupts are floating therefore we must not pass an cpustate */
 void s390_sclp_extint(uint32_t parm);
 
Signature · 1 line
1.7.10.4
#29 lore raw

Re: [Qemu-devel] [PATCH 7/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Implement hot_add_cpu hook

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 16 lines

From: "Jason J. Herne" <[email protected]>

Implement hot_add_cpu for S390 to allow hot plugging of cpus.

---
 hw/s390x/s390-virtio-ccw.c |    3 +++
 target-s390x/cpu.c         |   32 ++++++++++++++++++++++++++++++++
 target-s390x/cpu.h         |    2 ++
 3 files changed, 37 insertions(+)
hw/s390x/s390-virtio-ccw.c +0 -0
index b469960..30b6a48 100644

hw/s390x/s390-virtio-ccw.c static QEMUMachine ccw_machine = { · line 122

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +3 -0
@@ -117,6 +117,9 @@ static QEMUMachine ccw_machine = {
     .alias = "s390-ccw",
     .desc = "VirtIO-ccw based S390 machine",
     .init = ccw_init,
+#if !defined(CONFIG_USER_ONLY)
+    .hot_add_cpu = ccw_hot_add_cpu,
+#endif

I doubt this #ifdeffery is necessary here?

Quoted 19 lines
hw/s390x/s390-virtio-ccw.c +0 -0
     .block_default_type = IF_VIRTIO,
     .no_cdrom = 1,
     .no_floppy = 1,
target-s390x/cpu.c +2 -0
index c90a91c..60029d9 100644
@@ -27,6 +27,8 @@
 #include "qemu-common.h"
 #include "qemu/timer.h"
 #include "hw/hw.h"
+#include "hw/s390x/sclp.h"
+#include "sysemu/sysemu.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
 #endif
@@ -154,6 +156,36 @@ static void s390_cpu_finalize(Object *obj)
 #endif
 }

target-s390x/cpu.c static void s390_cpu_finalize(Object *obj) · line 167

Quoted 10 lines
target-s390x/cpu.c +9 -0
 
+#if !defined(CONFIG_USER_ONLY)
+void ccw_hot_add_cpu(const int64_t id, Error **errp)
+{
+    S390CPU *new_cpu;
+    CPUState *cpu;
+    const char *model_str;
+    int cpu_count = 0;
+
+    for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {

CPU_FOREACH(cpu) {

target-s390x/cpu.c static void s390_cpu_finalize(Object *obj) · line 180

Quoted 13 lines
target-s390x/cpu.c +13 -0
+        cpu_count++;
+    }
+
+    if (cpu_count == max_cpus) {
+        error_setg(errp, "Maximum number of cpus already defined");
+        return;
+    }
+
+    if (id != cpu_count) {
+        error_setg(errp, "Unable to add CPU: %" PRIi64
+                   ", The next available id is %d", id, cpu_count);
+        return;
+    }

This logic seems wrong according to your colleagues. It should be checking against the static cpu_num counter or not checking at all if we want to allow explicit device_add s390-cpu,cpu-num=42.

target-s390x/cpu.c static void s390_cpu_finalize(Object *obj) · line 183

Quoted 3 lines
target-s390x/cpu.c +3 -0
+
+    model_str = s390_cpu_addr2state(0)->env.cpu_model_str;
+    new_cpu = s390_new_cpu(model_str, id);

As announced, a patch in my large series finally sent out removes cpu_model_str field. Since we don't have any for s390x, I suggest that you use the QOM constructs so that device_add works as well, i.e. new_cpu = object_new(TYPE_S390_CPU).

target-s390x/cpu.c static void s390_cpu_finalize(Object *obj) · line 185

Quoted 2 lines
target-s390x/cpu.c +2 -0
+    object_property_set_bool(OBJECT(new_cpu), true, "realized", NULL);
+    raise_irq_cpu_hotplug();

This would mean moving this line into the realizefn, conditional on dev->hotplugged (and probably #ifndef CONFIG_USER_ONLY).

Regards,
Andreas

Quoted 20 lines
target-s390x/cpu.c +3 -0
+}
+#endif
+
 static const VMStateDescription vmstate_s390_cpu = {
     .name = "cpu",
     .unmigratable = 1,
target-s390x/cpu.h +2 -0
index 0f68dd0..711aad4 100644
@@ -383,6 +383,8 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
 void s390_add_running_cpu(S390CPU *cpu);
 unsigned s390_del_running_cpu(S390CPU *cpu);
 
+void ccw_hot_add_cpu(const int64_t id, Error **errp);
+
 /* service interrupts are floating therefore we must not pass an cpustate */
 void s390_sclp_extint(uint32_t parm);
 
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#30 lore raw

Re: [Qemu-devel] [PATCH 7/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Implement hot_add_cpu hook

Quoted 12 lines · Andreas Färber

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 11 lines

From: "Jason J. Herne" <[email protected]>

Implement hot_add_cpu for S390 to allow hot plugging of cpus.

---
  hw/s390x/s390-virtio-ccw.c |    3 +++
  target-s390x/cpu.c         |   32 ++++++++++++++++++++++++++++++++
  target-s390x/cpu.h         |    2 ++
  3 files changed, 37 insertions(+)
Quoted 14 lines

hw/s390x/s390-virtio-ccw.c static QEMUMachine ccw_machine = { · line 122

Quoted 11 lines
hw/s390x/s390-virtio-ccw.c +3 -0
index b469960..30b6a48 100644
@@ -117,6 +117,9 @@ static QEMUMachine ccw_machine = {
      .alias = "s390-ccw",
      .desc = "VirtIO-ccw based S390 machine",
      .init = ccw_init,
+#if !defined(CONFIG_USER_ONLY)
+    .hot_add_cpu = ccw_hot_add_cpu,
+#endif

I doubt this #ifdeffery is necessary here?

This was needed because ccw_hot_add_cpu calls s390_cpu_addr2state which is wrapped in the very same ifdef. However, the offending line is this:

model_str = s390_cpu_addr2state(0)->env.cpu_model_str;

Since we're doing away with that line anyway I can probably remove that ifdef. However, does it make sense to have a cpu-add command for the linux-user target?

Also, do you know when your patch to remove the model string will hit the master branch?

Signature · 1 line
-- Jason J. Herne ([email protected])
#31 lore raw

Re: [Qemu-devel] [PATCH 7/8] [PATCH RFC v3] s390-qemu: cpu hotplug - Implement hot_add_cpu hook

Am 13.09.2013 17:29, schrieb Jason J. Herne:

Quoted 28 lines · Andreas Färber
Quoted 12 lines

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 11 lines

From: "Jason J. Herne" <[email protected]>

Implement hot_add_cpu for S390 to allow hot plugging of cpus.

---
  hw/s390x/s390-virtio-ccw.c |    3 +++
  target-s390x/cpu.c         |   32 ++++++++++++++++++++++++++++++++
  target-s390x/cpu.h         |    2 ++
  3 files changed, 37 insertions(+)
Quoted 14 lines

hw/s390x/s390-virtio-ccw.c static QEMUMachine ccw_machine = { · line 122

Quoted 11 lines
hw/s390x/s390-virtio-ccw.c +3 -0
index b469960..30b6a48 100644
@@ -117,6 +117,9 @@ static QEMUMachine ccw_machine = {
      .alias = "s390-ccw",
      .desc = "VirtIO-ccw based S390 machine",
      .init = ccw_init,
+#if !defined(CONFIG_USER_ONLY)
+    .hot_add_cpu = ccw_hot_add_cpu,
+#endif

I doubt this #ifdeffery is necessary here?

Quoted 2 lines

This was needed because ccw_hot_add_cpu calls s390_cpu_addr2state which is wrapped in the very same ifdef.

This whole file should never get compiled for CONFIG_USER_ONLY.

Quoted 10 lines

However, the offending line is this:

model_str = s390_cpu_addr2state(0)->env.cpu_model_str;

Since we're doing away with that line anyway I can probably remove that ifdef. However, does it make sense to have a cpu-add command for the linux-user target?

Also, do you know when your patch to remove the model string will hit the master branch?

I've pushed it to qom-cpu-next branch for now, suggest to rebase on that. It all depends on when I get to review all the pending patches and respin some interfering ones and then get someone to pull, which is outside of my control.

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#32 lore raw

RFC PATCH v3 8/8 qemu-monitor: HMP cpu-add wrapper

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Add HMP cpu-add wrapper to allow cpu hot plugging via monitor.

---
 hmp-commands.hx |   13 +++++++++++++
 hmp.c           |   10 ++++++++++
 hmp.h           |    1 +
 3 files changed, 24 insertions(+)
hmp-commands.hx +13 -0
index 8c6b91a..cb8712b 100644
@@ -1587,6 +1587,19 @@ Executes a qemu-io command on the given block device.
 ETEXI
 
     {
+        .name       = "cpu-add",
+        .args_type  = "id:i",
+        .params     = "id",
+        .help       = "add cpu",
+        .mhandler.cmd  = hmp_cpu_add,
+    },
+
+STEXI
+@item cpu-add @var{id}
+Add CPU with id @var{id}
+ETEXI
+
+    {
         .name       = "info",
         .args_type  = "item:s?",
         .params     = "[subcommand]",
hmp.c +10 -0
index c45514b..9465bd4 100644
@@ -1475,6 +1475,16 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &errp);
 }
 
+void hmp_cpu_add(Monitor *mon, const QDict *qdict)
+{
+    int cpuid;
+    Error *err = NULL;
+
+    cpuid = qdict_get_int(qdict, "id");
+    qmp_cpu_add(cpuid, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
 {
     const char *args = qdict_get_str(qdict, "args");
hmp.h +1 -0
index 6c3bdcd..9effca5 100644
@@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
 void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+void hmp_cpu_add(Monitor *mon, const QDict *qdict);
 
 #endif
Signature · 1 line
1.7.10.4
#33 lore raw

Re: [Qemu-devel] [PATCH 8/8] [PATCH RFC v3] qemu-monitor: HMP cpu-add wrapper

Luiz,

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 5 lines

From: "Jason J. Herne" <[email protected]>

Add HMP cpu-add wrapper to allow cpu hot plugging via monitor.

What are your thoughts on this?

Thanks,
Andreas

Quoted 63 lines
---
 hmp-commands.hx |   13 +++++++++++++
 hmp.c           |   10 ++++++++++
 hmp.h           |    1 +
 3 files changed, 24 insertions(+)
hmp-commands.hx +13 -0
index 8c6b91a..cb8712b 100644
@@ -1587,6 +1587,19 @@ Executes a qemu-io command on the given block device.
 ETEXI
 
     {
+        .name       = "cpu-add",
+        .args_type  = "id:i",
+        .params     = "id",
+        .help       = "add cpu",
+        .mhandler.cmd  = hmp_cpu_add,
+    },
+
+STEXI
+@item cpu-add @var{id}
+Add CPU with id @var{id}
+ETEXI
+
+    {
         .name       = "info",
         .args_type  = "item:s?",
         .params     = "[subcommand]",
hmp.c +10 -0
index c45514b..9465bd4 100644
@@ -1475,6 +1475,16 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &errp);
 }
 
+void hmp_cpu_add(Monitor *mon, const QDict *qdict)
+{
+    int cpuid;
+    Error *err = NULL;
+
+    cpuid = qdict_get_int(qdict, "id");
+    qmp_cpu_add(cpuid, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
 {
     const char *args = qdict_get_str(qdict, "args");
hmp.h +1 -0
index 6c3bdcd..9effca5 100644
@@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
 void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+void hmp_cpu_add(Monitor *mon, const QDict *qdict);
 
 #endif
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Reviewed-by
#34 lore raw

Re: [Qemu-devel] [PATCH 8/8] [PATCH RFC v3] qemu-monitor: HMP cpu-add wrapper

Quoted 10 lines · On Thu, 01 Aug 2013 18:02:08 +0200 Andreas Färber <[email protected]> wrote:

Luiz,

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 5 lines

From: "Jason J. Herne" <[email protected]>

Add HMP cpu-add wrapper to allow cpu hot plugging via monitor.

What are your thoughts on this?

Looks good:

Quoted 69 lines

Thanks,
Andreas

Quoted 63 lines
---
 hmp-commands.hx |   13 +++++++++++++
 hmp.c           |   10 ++++++++++
 hmp.h           |    1 +
 3 files changed, 24 insertions(+)
hmp-commands.hx +13 -0
index 8c6b91a..cb8712b 100644
@@ -1587,6 +1587,19 @@ Executes a qemu-io command on the given block device.
 ETEXI
 
     {
+        .name       = "cpu-add",
+        .args_type  = "id:i",
+        .params     = "id",
+        .help       = "add cpu",
+        .mhandler.cmd  = hmp_cpu_add,
+    },
+
+STEXI
+@item cpu-add @var{id}
+Add CPU with id @var{id}
+ETEXI
+
+    {
         .name       = "info",
         .args_type  = "item:s?",
         .params     = "[subcommand]",
hmp.c +10 -0
index c45514b..9465bd4 100644
@@ -1475,6 +1475,16 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &errp);
 }
 
+void hmp_cpu_add(Monitor *mon, const QDict *qdict)
+{
+    int cpuid;
+    Error *err = NULL;
+
+    cpuid = qdict_get_int(qdict, "id");
+    qmp_cpu_add(cpuid, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
 {
     const char *args = qdict_get_str(qdict, "args");
hmp.h +1 -0
index 6c3bdcd..9effca5 100644
@@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
 void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+void hmp_cpu_add(Monitor *mon, const QDict *qdict);
 
 #endif
#35 lore raw
In reply to Jason J. Herne

Hello,

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 9 lines

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

Quoted 8 lines

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

We have been having several off-list discussions since then that I'll try to briefly summarize here, please correct or extend as needed:

1) CPU topology for QOM

Physically a System z machine may have an MCM with, e.g., 6 CPUs with 6 cores each. But unlike x86, there is PR/SM, LPAR and possibly z/VM in between Linux and hardware, so we do actually want to be able to hot-plug in quantities of 1 and not by 6 on s390x for the foreseeable future. We seem willing to set a QOM ABI in stone based on that assumption.

=> s390-cpu (or future subtypes) to be used with device_add. => Flat /machine/cpu[n] list in composition tree a possibility.

1a) CPU topology for guests

STSI instruction topology support not implemented yet.

=> Guest unaware of any emulated topology today.

hyptop tool requires hypfs implementation for KVM.

=> Guest unaware of sibling VMs today, unlike z/VM and LPAR.

2) CPU hot-unplug

Hotplug will always use a unique linear CPU address, even if hot-unplug leads to a sparse address space.

=> cpu_num != cpu_index

With all that in mind, I'll now need to review the s390 patches again.

For the HMP patch I am waiting on feedback from Igor once he returns from his vacation and, if there are no objections, would like to see that patch go through Luiz' queue since unrelated to s390x.

Regards,
Andreas

Quoted 29 lines

Jason J. Herne (8):
s390-qemu: cpu hotplug - Define New SCLP Codes
s390-qemu: cpu hotplug - SCLP CPU Info
s390-qemu: cpu hotplug - SCLP Event integration
s390-qemu: cpu hotplug - Storage key global access
s390-qemu: cpu hotplug - ipi_states enhancements
s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug
s390-qemu: cpu hotplug - Implement hot_add_cpu hook
qemu-monitor: HMP cpu-add wrapper

 hmp-commands.hx                   |   13 ++++
 hmp.c                             |   10 ++++
 hmp.h                             |    1 +
 hw/s390x/Makefile.objs            |    2 +-
 hw/s390x/event-facility.c         |    7 +++
 hw/s390x/s390-virtio-ccw.c        |    8 ++-
 hw/s390x/s390-virtio.c            |   47 +++++++++------
 hw/s390x/s390-virtio.h            |    2 +-
 hw/s390x/sclp.c                   |   53 +++++++++++++++-
 hw/s390x/sclpcpu.c                |  120 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |    3 +
 include/hw/s390x/sclp.h           |   41 +++++++++++++
 target-s390x/cpu.c                |   36 ++++++++++-
 target-s390x/cpu.h                |    7 +++
 target-s390x/helper.c             |   12 ++++
 15 files changed, 336 insertions(+), 26 deletions(-)
 create mode 100644 hw/s390x/sclpcpu.c
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#36 lore raw
Quoted 8 lines · On Wed, 04 Sep 2013 14:45:44 +0200 Andreas Färber <[email protected]> wrote:

=> cpu_num != cpu_index

With all that in mind, I'll now need to review the s390 patches again.

For the HMP patch I am waiting on feedback from Igor once he returns from his vacation and, if there are no objections, would like to see that patch go through Luiz' queue since unrelated to s390x.

I don't remember seeing that patch, I was CC'ed?

Anyway, if you point me to the patch I can review it and add my Reviewed-by, which should be as good as having the patch merged on master through my queue.

#37 lore raw

Am 04.09.2013 14:56, schrieb Luiz Capitulino:

Quoted 8 lines
Quoted 3 lines · On Wed, 04 Sep 2013 14:45:44 +0200 Andreas Färber <[email protected]> wrote:

For the HMP patch I am waiting on feedback from Igor once he returns from his vacation and, if there are no objections, would like to see that patch go through Luiz' queue since unrelated to s390x.

I don't remember seeing that patch, I was CC'ed?

Originally no, but you added a Reviewed-by after I CC'ed you. :)

Apart from me not being familiar with the HMP infrastructure, I was wondering if there was a reason why this wasn't done from the start.

So we don't have some only-new-QMP-commands policy and people are encouraged to implement an HMP command when they do a QMP command?

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#38 lore raw
Quoted 9 lines · On Wed, 04 Sep 2013 15:04:17 +0200 Andreas Färber <[email protected]> wrote:

Am 04.09.2013 14:56, schrieb Luiz Capitulino:

Quoted 8 lines
Quoted 3 lines · On Wed, 04 Sep 2013 14:45:44 +0200 Andreas Färber <[email protected]> wrote:

For the HMP patch I am waiting on feedback from Igor once he returns from his vacation and, if there are no objections, would like to see that patch go through Luiz' queue since unrelated to s390x.

I don't remember seeing that patch, I was CC'ed?

It should be good then :)

Quoted 7 lines

Originally no, but you added a Reviewed-by after I CC'ed you. :)

Apart from me not being familiar with the HMP infrastructure, I was wondering if there was a reason why this wasn't done from the start.

So we don't have some only-new-QMP-commands policy

Not sure what you meant, but what is usually not accepted are new HMP-only commands.

Quoted 2 lines

and people are
encouraged to implement an HMP command when they do a QMP command?

If the new command makes sense in HMP, yes they're.

#39 lore raw
In reply to Andreas Färber
Quoted 24 lines · Andreas Färber

Hello,

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 9 lines

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

Quoted 8 lines

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

We have been having several off-list discussions since then that I'll try to briefly summarize here, please correct or extend as needed:

Quoted 7 lines

1) CPU topology for QOM

Physically a System z machine may have an MCM with, e.g., 6 CPUs with 6 cores each. But unlike x86, there is PR/SM, LPAR and possibly z/VM in between Linux and hardware, so we do actually want to be able to hot-plug in quantities of 1 and not by 6 on s390x for the foreseeable future. We seem willing to set a QOM ABI in stone based on that assumption.

Just stepping in, Jason is on vacation this week.

To summarize my understanding:
You were thinking if CPU model needs topology (e.g. -device mcm,id=m1, -device cpu,mcm=m1) and s390 was the only arch left, that you were not sure about if topology is needed? All other platforms dont need topology for cpu hotplug?

Yes, we want to be able to hotplug single cores (not chips, not MCMs). It is pretty hard to pin the vCPUs to a given real topology for KVM. You need to pin on LPAR and KVM. Libvirt could do some pinning of guest vCPUs to host CPUs and LPAR can have dedicated CPUs. But pinning a full chip (6cores) would only make sense in very rare cases.

Quoted 7 lines

=> s390-cpu (or future subtypes) to be used with device_add. => Flat /machine/cpu[n] list in composition tree a possibility.

1a) CPU topology for guests

STSI instruction topology support not implemented yet.

Right not implemented yet, but we certainly want to be able to define the guest visible topology at some point in time (grouping of cores basically). But I guess this does not mean that we have to go away from the flat list of CPUs.

Quoted 2 lines

=> Guest unaware of any emulated topology today.

An additional problem is, that for the normal case (linux scheduler, no pinning, also no gang scheduling) the topology would change too fast. The guest would be busy rebuilding the scheduler domains all the time.

Quoted 4 lines

hyptop tool requires hypfs implementation for KVM.

=> Guest unaware of sibling VMs today, unlike z/VM and LPAR.

Right. But we will look into hyptop at some point in time.

Quoted 6 lines

2) CPU hot-unplug

Hotplug will always use a unique linear CPU address, even if hot-unplug leads to a sparse address space.

Quoted 8 lines

=> cpu_num != cpu_index

With all that in mind, I'll now need to review the s390 patches again.

For the HMP patch I am waiting on feedback from Igor once he returns from his vacation and, if there are no objections, would like to see that patch go through Luiz' queue since unrelated to s390x.

Yes, would be cool if the HMP patch could go upstream via that path. That would reduce the rework/patch burden of Jason.

Quoted 35 lines

Regards,
Andreas

Quoted 29 lines

Jason J. Herne (8):
s390-qemu: cpu hotplug - Define New SCLP Codes
s390-qemu: cpu hotplug - SCLP CPU Info
s390-qemu: cpu hotplug - SCLP Event integration
s390-qemu: cpu hotplug - Storage key global access
s390-qemu: cpu hotplug - ipi_states enhancements
s390-qemu: cpu hotplug - s390 cpu init improvements for hotplug
s390-qemu: cpu hotplug - Implement hot_add_cpu hook
qemu-monitor: HMP cpu-add wrapper

 hmp-commands.hx                   |   13 ++++
 hmp.c                             |   10 ++++
 hmp.h                             |    1 +
 hw/s390x/Makefile.objs            |    2 +-
 hw/s390x/event-facility.c         |    7 +++
 hw/s390x/s390-virtio-ccw.c        |    8 ++-
 hw/s390x/s390-virtio.c            |   47 +++++++++------
 hw/s390x/s390-virtio.h            |    2 +-
 hw/s390x/sclp.c                   |   53 +++++++++++++++-
 hw/s390x/sclpcpu.c                |  120 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |    3 +
 include/hw/s390x/sclp.h           |   41 +++++++++++++
 target-s390x/cpu.c                |   36 ++++++++++-
 target-s390x/cpu.h                |    7 +++
 target-s390x/helper.c             |   12 ++++
 15 files changed, 336 insertions(+), 26 deletions(-)
 create mode 100644 hw/s390x/sclpcpu.c
#40 lore raw

Am 05.09.2013 12:40, schrieb Christian Borntraeger:

Quoted 27 lines · Andreas Färber
Quoted 26 lines

Hello,

Am 01.08.2013 16:12, schrieb Jason J. Herne:

Quoted 9 lines

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

Quoted 8 lines

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

We have been having several off-list discussions since then that I'll try to briefly summarize here, please correct or extend as needed:

1) CPU topology for QOM

Quoted 7 lines
Quoted 5 lines

Physically a System z machine may have an MCM with, e.g., 6 CPUs with 6 cores each. But unlike x86, there is PR/SM, LPAR and possibly z/VM in between Linux and hardware, so we do actually want to be able to hot-plug in quantities of 1 and not by 6 on s390x for the foreseeable future. We seem willing to set a QOM ABI in stone based on that assumption.

Just stepping in, Jason is on vacation this week.

Everyone is welcome to comment. :)

Quoted 4 lines

To summarize my understanding:
You were thinking if CPU model needs topology (e.g. -device mcm,id=m1, -device cpu,mcm=m1) and s390 was the only arch left, that you were not sure about if topology is needed? All other platforms dont need topology for cpu hotplug?

No, on the contrary: I don't want s390x to blindly copy x86 cpu-add, because for x86 we know that what we have is a hack to make it work today, but there we know we want to do device_add Xeon-X42-4242 instead, which then hot-plugs the 6 cores x 2 threads at once that a physical hot-plug would do and not hot-add individual threads.

So the question of topology is not about what is below KVM but about what is inside QEMU, since x86 emulates i440fx/q35 based hardware. The understanding I reached on IRC is that s390x (similar to sPAPR) tries to emulate LPAR / z/VM layer rather than the hardware below them, thus no applicable concept of "real" hardware and arbitrary quantities.

Quoted 5 lines

Yes, we want to be able to hotplug single cores (not chips, not MCMs). It is pretty hard to pin the vCPUs to a given real topology for KVM. You need to pin on LPAR and KVM. Libvirt could do some pinning of guest vCPUs to host CPUs and LPAR can have dedicated CPUs. But pinning a full chip (6cores) would only make sense in very rare cases.

Last time I looked into this, the post-add hook was solely for overall ccw initialization. So we can use device_add s390-cpu today, can't we?

The question that I still need to investigate is how the always-incrementing CPU address interacts with maxcpus. Consider maxcpus=6 and smp_cpus=2. 4x device_add should work. Now if we did 1x device_del, then 1x device_add should work again IMO. cpu-add checks the user-supplied id against maxcpus though iirc.

Therefore my saying in multiple contexts that we should get the QEMU and KVM CPU count checks into the CPU realizefn so that we get the checks irrespective of the call site with nice error reporting.

Quoted 10 lines
Quoted 6 lines

=> s390-cpu (or future subtypes) to be used with device_add. => Flat /machine/cpu[n] list in composition tree a possibility.

1a) CPU topology for guests

STSI instruction topology support not implemented yet.

Right not implemented yet, but we certainly want to be able to define the guest visible topology at some point in time (grouping of cores basically). But I guess this does not mean that we have to go away from the flat list of CPUs.

So STSI would show what real LPAR/CPU we are running on? But QEMU would have /machine/cpu[0]? Or do we need /machine/cpugroup[0]/cpu[0]? The latter is my concern here, to decide about child<> vs. link<> properties.

To cope with device_add s390-cpu adding the device to /machine/peripheral/<id> or /machine/peripheral-anon/device[0] I *think* we'll need link<>, which would then translate back to ipi_states array as backend and the remaining question would be where to expose those properties in the composition tree - i.e. /machine/cpu[n] or /machine/ipi/cpu[n] or something - please suggest. Similarly if those become link<> properties then the CPUs created by the machine via smp_cpus need a canonical path as well; quite obviously both cannot be the same.

Background is that long-term Anthony would like x86 CPU hot-plug to become setting/unsetting some /machine/cpu-socket[n] link<> property of the machine, and the ipi_states array seems a close equivalent on s390x.

Quoted 5 lines
Quoted 1 line

=> Guest unaware of any emulated topology today.

An additional problem is, that for the normal case (linux scheduler, no pinning, also no gang scheduling) the topology would change too fast. The guest would be busy rebuilding the scheduler domains all the time.

[snip]

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#41 lore raw
Quoted 2 lines · Andreas Färber

Am 05.09.2013 12:40, schrieb Christian Borntraeger:

Quoted 1 line · Andreas Färber

...

Quoted 10 lines

To cope with device_add s390-cpu adding the device to /machine/peripheral/<id> or /machine/peripheral-anon/device[0] I *think* we'll need link<>, which would then translate back to ipi_states array as backend and the remaining question would be where to expose those properties in the composition tree - i.e. /machine/cpu[n] or /machine/ipi/cpu[n] or something - please suggest. Similarly if those become link<> properties then the CPUs created by the machine via smp_cpus need a canonical path as well; quite obviously both cannot be the same.

Ok, if I understand right then /machine/peripheral[-anon]/device[n] is the canonical path given to a a cpu that is created via qdev_device_add.
We're going to create a link to that cpu via path
/machine/cpu[cpu_addr].

I'm not sure what you meant by "if those become link<> properties then the CPUs created by the machine via smp_cpus need a canonical path as well". Wouldn't the canonical path just be /machine/peripheral[-anon]/device[n]? Are you saying we really want something different for non-hotplugged cpus?

Quoted 14 lines

Background is that long-term Anthony would like x86 CPU hot-plug to become setting/unsetting some /machine/cpu-socket[n] link<> property of the machine, and the ipi_states array seems a close equivalent on s390x.

Quoted 5 lines
Quoted 1 line

=> Guest unaware of any emulated topology today.

An additional problem is, that for the normal case (linux scheduler, no pinning, also no gang scheduling) the topology would change too fast. The guest would be busy rebuilding the scheduler domains all the time.

[snip]

Regards,
Andreas

Signature · 1 line
-- Jason J. Herne ([email protected])
Reviewed-by on the v3 series
#42 lore raw
In reply to Jason J. Herne
Quoted 9 lines · Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

Quoted 8 lines

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

Very simple and clean patch set. I don't think it deserves the RFC tag.

Apart from the minor comments I had consider it

Alex

#43 lore raw

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 15 lines · Jason J. Herne
Quoted 13 lines

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Quoted 7 lines
Quoted 5 lines

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Hot unplugging is currently not implemented by this code.

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Open issues:
* Might ipi_states need to become a device due to migration?
* QOM properties considerations
* Device creation in qdev initfn
* Parent field access
* QOM-unfriendly creation and reliance upon helper function

Andreas

Quoted 8 lines

Apart from the minor comments I had consider it

Alex

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#44 lore raw
Quoted 20 lines · Andreas Färber

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 19 lines · Jason J. Herne
Quoted 17 lines

From: "Jason J. Herne" <[email protected]>

Latest code for cpu Hotplug on S390 architecture. This one is vastly simpler
than v2 as we have decided to avoid the command line specification of -device s390-cpu.

The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01183.html

There is also a patch in this series to add cpu-add to the Qemu monitor interface.

Hotplugged cpus are created in the configured state and can be used by the guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Hot unplugging is currently not implemented by this code.

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Yeah, that's what I'm referring to. I've seen a lot worse patch sets at v8 than this RFC :).

I don't think we should apply it as is, and I'm very happy to see your review and comment on the modeling bits :). But I try to never apply or cherry pick RFC patches - and this set looks like he sent it with the intent of getting it merged.

Alex

#45 lore raw

Am 05.09.2013 15:10, schrieb Alexander Graf:

Quoted 12 lines · Andreas Färber
Quoted 7 lines

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 1 line

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Yeah, that's what I'm referring to. I've seen a lot worse patch sets at v8 than this RFC :).

I don't think we should apply it as is, and I'm very happy to see your review and comment on the modeling bits :). But I try to never apply or cherry pick RFC patches - and this set looks like he sent it with the intent of getting it merged.

Agreed, we can continue with "PATCH v4". I was more upset about the "very simple and clean" bit after I commented on a number of unclean things to improve - mostly about doing things in different places.

If you could find some time to review my two model string patches then I could supply Jason with a branch or even a pull to base on:

http://patchwork.ozlabs.org/patch/272511/
http://patchwork.ozlabs.org/patch/272509/

I would also volunteer to provide a base patch for the link<> issue if there is agreement. Apart from the QOM API question this depends on the contradictory modelling of whether we allow CPU addresses 0..max_cpus as seen in this series or 0..somemax with <= max_cpus non-NULL as discussed on #zkvm.
(child<s390-cpu> properties would allow to model the latter sparse address space very well, but an object can only have one parent in the hot-add case. We could of course add cpu[n] link<s390-cpu> properties as CPUs get added, but that doesn't strike me as very clean. My underlying thought is to offload the error handling to QOM so that we don't start hardcoding s/smp_cpus/max_cpus/g (or some max_cpu_address) all around ipi_states.)

Btw an unanswered question: ipi_states is just pointers to CPUs currently, no further state. So what's "ipi" in the name? Will that array need to carry state beyond S390CPU someday?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#46 lore raw
Quoted 21 lines · Andreas Färber

Am 05.09.2013 15:10, schrieb Alexander Graf:

Quoted 12 lines · Andreas Färber
Quoted 7 lines

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 1 line

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Yeah, that's what I'm referring to. I've seen a lot worse patch sets at v8 than this RFC :).

I don't think we should apply it as is, and I'm very happy to see your review and comment on the modeling bits :). But I try to never apply or cherry pick RFC patches - and this set looks like he sent it with the intent of getting it merged.

Agreed, we can continue with "PATCH v4". I was more upset about the "very simple and clean" bit after I commented on a number of unclean things to improve - mostly about doing things in different places.

If you could find some time to review my two model string patches then I could supply Jason with a branch or even a pull to base on:

Quoted 8 lines

http://patchwork.ozlabs.org/patch/272511/
http://patchwork.ozlabs.org/patch/272509/

I would also volunteer to provide a base patch for the link<> issue if there is agreement. Apart from the QOM API question this depends on the contradictory modelling of whether we allow CPU addresses 0..max_cpus as seen in this series or 0..somemax with <= max_cpus non-NULL as discussed on #zkvm.

According to http://wiki.qemu.org/Features/CPUHotplug:

"adding CPUs should be done in successive order from lower to higher IDs in [0..max-cpus) range. It's possible to add arbitrary CPUs in random order, however that would cause migration to fail on its target side."

Considering that, in a virtual environment, it rarely (if ever) makes sense to define out of order cpu ids maybe we should keep the patch as is and only allow consecutive cpu ids to be used.

By extension, hot-unplug would require that the highest id be unplugged. This is probably not acceptable in any type of "mixed cpu" environment because the greatest id may not be the cpu type you want to remove. I'm not sure if S390 will implement mixed cpu types.

Quoted 8 lines

(child<s390-cpu> properties would allow to model the latter sparse address space very well, but an object can only have one parent in the hot-add case. We could of course add cpu[n] link<s390-cpu> properties as CPUs get added, but that doesn't strike me as very clean. My underlying thought is to offload the error handling to QOM so that we don't start hardcoding s/smp_cpus/max_cpus/g (or some max_cpu_address) all around ipi_states.)

I'm not sure I understand. What is meant by: "an object can only have one parent in the hot-add case."

What is the difference between "child<s390-cpu>" and "cpu[n] link<s390-cpu>"? And why do you feel the link case would be unclean?

Quoted 4 lines

Btw an unanswered question: ipi_states is just pointers to CPUs currently, no further state. So what's "ipi" in the name? Will that array need to carry state beyond S390CPU someday?

Quoting Jens Freimann:
"
The ipi_states array holds all our S390CPU states. The position of a cpu within this array equals its "cpu address". See section "CPU address identification" in the Principles of Operation. This cpu address is used for
cpu signalling (inter-processor interrupts->ipi) via the sigp instruction. The cpu address does not contain information about which book this cpu is plugged into, nor does it hold any other topology information.

When we intercept a sigp instruction in qemu the cpu address is passed to us in a field of the SIE control block. We then use the cpu address as an index to the ipi_states field, get hold of the S390CPU and then for example do an vcpu ioctl on the chosen cpu.
"

Based on this explanation I do not think this array will ever be anything more than what it is today.

Signature · 1 line
-- Jason J. Herne ([email protected])
#47 lore raw

Am 13.09.2013 17:01, schrieb Jason J. Herne:

Quoted 38 lines · Andreas Färber
Quoted 26 lines

Am 05.09.2013 15:10, schrieb Alexander Graf:

Quoted 10 lines · Andreas Färber
Quoted 8 lines

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 2 lines

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Quoted 7 lines

Yeah, that's what I'm referring to. I've seen a lot worse patch sets at v8 than this RFC :).

I don't think we should apply it as is, and I'm very happy to see your review and comment on the modeling bits :). But I try to never apply or cherry pick RFC patches - and this set looks like he sent it with the intent of getting it merged.

Agreed, we can continue with "PATCH v4". I was more upset about the "very simple and clean" bit after I commented on a number of unclean things to improve - mostly about doing things in different places.

If you could find some time to review my two model string patches then I could supply Jason with a branch or even a pull to base on:

Quoted 8 lines

http://patchwork.ozlabs.org/patch/272511/
http://patchwork.ozlabs.org/patch/272509/

I would also volunteer to provide a base patch for the link<> issue if there is agreement. Apart from the QOM API question this depends on the contradictory modelling of whether we allow CPU addresses 0..max_cpus as seen in this series or 0..somemax with <= max_cpus non-NULL as discussed on #zkvm.

According to http://wiki.qemu.org/Features/CPUHotplug:

Quoted 8 lines

"adding CPUs should be done in successive order from lower to higher IDs in [0..max-cpus) range.
It's possible to add arbitrary CPUs in random order, however that would cause migration to fail on its target side."

Considering that, in a virtual environment, it rarely (if ever) makes sense to define out of order cpu ids maybe we should keep the patch as is and only allow consecutive cpu ids to be used.

Your previous series tried to make -device work in place of -smp. This series now only seems to focus on cpu-add, including you referencing its current limitations above.

As I tried to explain, x86 needed cpu-add because unlike s390x its CPU is not yet a fully initialize'able QOM object and thus can't use device_add yet (and long-term we want to use containers instead of today's *-x86_64-cpu).

So I would very much prefer to see s390x continuing to use -smp but using device_add for CPU hot-add and in a way where we don't have to change semantics and ABI again when we implement hot-unplug. I am fine with you implementing a cpu-add wrapper, but on top of a working implementation please rather than limiting your implementation by it upfront.

Quoted 14 lines

By extension, hot-unplug would require that the highest id be unplugged. This is probably not acceptable in any type of "mixed cpu" environment because the greatest id may not be the cpu type you want to remove. I'm not sure if S390 will implement mixed cpu types.

Quoted 8 lines

(child<s390-cpu> properties would allow to model the latter sparse address space very well, but an object can only have one parent in the hot-add case. We could of course add cpu[n] link<s390-cpu> properties as CPUs get added, but that doesn't strike me as very clean. My underlying thought is to offload the error handling to QOM so that we don't start hardcoding s/smp_cpus/max_cpus/g (or some max_cpu_address) all around ipi_states.)

Quoted 5 lines

I'm not sure I understand. What is meant by: "an object can only have one parent in the hot-add case."

What is the difference between "child<s390-cpu>" and "cpu[n] link<s390-cpu>"? And why do you feel the link case would be unclean?

child<> properties determine the canonical path of an object. Each object only has one canonical path. When using link<> properties, the linked-to objects still need a canonical path, which becomes the string value of the property on QMP level (pointer on C level). device_add assigns canonical paths. Realizing a device creates a canonical path in /machine/unassigned as fallback, but that won't work long-term as the composition tree will be our source to find devices to realize, so either the machine code or the S390CPU code should take care of assuring CPUs have canonical paths before manually realizing them.

Quoted 16 lines
Quoted 5 lines

Btw an unanswered question: ipi_states is just pointers to CPUs currently, no further state. So what's "ipi" in the name? Will that array need to carry state beyond S390CPU someday?

Quoting Jens Freimann:
"
The ipi_states array holds all our S390CPU states. The position of a cpu within this array equals its "cpu address". See section "CPU address identification"
in the Principles of Operation. This cpu address is used for cpu signalling (inter-processor interrupts->ipi) via the sigp instruction. The cpu address does not contain information about which book this cpu is plugged into, nor does it hold any other topology information.

Quoted 8 lines

When we intercept a sigp instruction in qemu the cpu address is passed to us in a field of the SIE control block. We then use the cpu address as an index to the ipi_states field, get hold of the S390CPU and then for example do an vcpu ioctl on the chosen cpu.
"

Based on this explanation I do not think this array will ever be anything more than what it is today.

Thanks, seems I overread that.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#48 lore raw
In reply to Jason J. Herne
Quoted 40 lines · On Fri, 13 Sep 2013 11:01:57 -0400 "Jason J. Herne"…
Quoted 23 lines · Andreas Färber

Am 05.09.2013 15:10, schrieb Alexander Graf:

Quoted 9 lines · Andreas Färber
Quoted 7 lines

Am 05.09.2013 14:54, schrieb Alexander Graf:

Quoted 1 line

Very simple and clean patch set. I don't think it deserves the RFC tag.

Negative, see my review. If you want to fix up and queue patches 1-2 that's fine with me, but the others need a respin. No major blocker though, just some more footwork mostly related to QOM and Jason's shifted focus on cpu-add rather than device_add.

Quoted 5 lines

Yeah, that's what I'm referring to. I've seen a lot worse patch sets at v8 than this RFC :).

I don't think we should apply it as is, and I'm very happy to see your review and comment on the modeling bits :). But I try to never apply or cherry pick RFC patches - and this set looks like he sent it with the intent of getting it merged.

Agreed, we can continue with "PATCH v4". I was more upset about the "very simple and clean" bit after I commented on a number of unclean things to improve - mostly about doing things in different places.

If you could find some time to review my two model string patches then I could supply Jason with a branch or even a pull to base on:

Quoted 8 lines

http://patchwork.ozlabs.org/patch/272511/
http://patchwork.ozlabs.org/patch/272509/

I would also volunteer to provide a base patch for the link<> issue if there is agreement. Apart from the QOM API question this depends on the contradictory modelling of whether we allow CPU addresses 0..max_cpus as seen in this series or 0..somemax with <= max_cpus non-NULL as discussed on #zkvm.

According to http://wiki.qemu.org/Features/CPUHotplug:

"adding CPUs should be done in successive order from lower to higher IDs in [0..max-cpus) range.
It's possible to add arbitrary CPUs in random order, however that would cause migration to fail on its target side."

Quoted 8 lines

Considering that, in a virtual environment, it rarely (if ever) makes sense to define out of order cpu ids maybe we should keep the patch as is and only allow consecutive cpu ids to be used.

By extension, hot-unplug would require that the highest id be unplugged. This is probably not acceptable in any type of "mixed cpu" environment because the greatest id may not be the cpu type you want to remove. I'm not sure if S390 will implement mixed cpu types.

As zArch implements only one CPU type in its CEC we also will allow only virtual CPUs of the same type in one KVM.

Quoted 40 lines
Quoted 9 lines

(child<s390-cpu> properties would allow to model the latter sparse address space very well, but an object can only have one parent in the hot-add case. We could of course add cpu[n] link<s390-cpu> properties as CPUs get added, but that doesn't strike me as very clean. My underlying thought is to offload the error handling to QOM so that we don't start hardcoding s/smp_cpus/max_cpus/g (or some max_cpu_address) all around ipi_states.)

I'm not sure I understand. What is meant by: "an object can only have one parent in the hot-add case."

What is the difference between "child<s390-cpu>" and "cpu[n] link<s390-cpu>"? And why do you feel the link case would be unclean?

Quoted 4 lines

Btw an unanswered question: ipi_states is just pointers to CPUs currently, no further state. So what's "ipi" in the name? Will that array need to carry state beyond S390CPU someday?

Quoting Jens Freimann:
"
The ipi_states array holds all our S390CPU states. The position of a cpu within this array equals its "cpu address". See section "CPU address identification"
in the Principles of Operation. This cpu address is used for cpu signalling (inter-processor interrupts->ipi) via the sigp instruction. The cpu address does not contain information about which book this cpu is plugged into, nor does it hold any other topology information.

When we intercept a sigp instruction in qemu the cpu address is passed to us in a field of the SIE control block. We then use the cpu address as an index to the ipi_states field, get hold of the S390CPU and then for example do an vcpu ioctl on the chosen cpu.
"

Based on this explanation I do not think this array will ever be anything more than what it is today.