Skip to contentSkip to conversation

migration: s390x css migration

PATCH Superseded Halil Pasic 5 participants 24 messages May 29, 2017 – Jun 8, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#2 lore raw

PATCH v2 2/7 s390x: add helper get_machine_class

In reply to Halil Pasic

We will need the machine class at machine initialization time, so the usual way via qdev won't do. Let's cache the machine class and also use the default values of the base machine for capability discovery.

---
 hw/s390x/s390-virtio-ccw.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
hw/s390x/s390-virtio-ccw.c +23 -23
index fdd4384ff0..04148916ed 100644
@@ -242,36 +242,35 @@ static inline void machine_set_dea_key_wrap(Object *obj, bool value,
     ms->dea_key_wrap = value;
 }
 
-bool ri_allowed(void)
-{
-    if (kvm_enabled()) {
-        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
-        if (object_class_dynamic_cast(OBJECT_CLASS(mc),
-                                      TYPE_S390_CCW_MACHINE)) {
-            S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
+static S390CcwMachineClass *current_mc;
 
-            return s390mc->ri_allowed;
-        }
+static S390CcwMachineClass *get_machine_class(void)
+{
+    if (unlikely(!current_mc)) {
         /*
-         * Make sure the "none" machine can have ri, otherwise it won't * be
-         * unlocked in KVM and therefore the host CPU model might be wrong.
-         */
-        return true;
+        * No s390 ccw machine was instantiated, we are likely to
+        * be called for the 'none' machine. The properties will
+        * have their after-initialization values.
+        */
+        current_mc = S390_MACHINE_CLASS(
+                     object_class_by_name(TYPE_S390_CCW_MACHINE));
     }
-    return 0;
+    return current_mc;
 }
 
-bool cpu_model_allowed(void)
+bool ri_allowed(void)
 {
-    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
-    if (object_class_dynamic_cast(OBJECT_CLASS(mc),
-                                  TYPE_S390_CCW_MACHINE)) {
-        S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
-
-        return s390mc->cpu_model_allowed;
+    if (!kvm_enabled()) {
+        return false;
     }
-    /* allow CPU model qmp queries with the "none" machine */
-    return true;
+    /* for "none" machine this results in true */
+    return get_machine_class()->ri_allowed;
+}
+
+bool cpu_model_allowed(void)
+{
+    /* for "none" machine this results in true */
+    return get_machine_class()->cpu_model_allowed;
 }
 
 static char *machine_get_loadparm(Object *obj, Error **errp)
@@ -360,6 +359,7 @@ static const TypeInfo ccw_machine_info = {
     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
     {                                                                         \
         MachineState *machine = MACHINE(obj);                                 \
+        current_mc = S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine));          \
         ccw_machine_##suffix##_instance_options(machine);                     \
     }                                                                         \
     static const TypeInfo ccw_machine_##suffix##_info = {                     \
Signature · 1 line
2.11.2
#0 lore raw

v2 cover migration: s390x css migration

The scope of this patch series is now limited to decoupling channel subsystem migration from the migration of virtio-ccw proxies.

The vmstatifying of virtio-ccw proxies is now done by another series currently consisting of a single patch running under the name 'vmstatify config migration for virtio-ccw'. Since this series depends on that patch, I have included it here too (for convenience).

The reorganization was requested by Dave.

v1 --> v2:
* Split out the vmystatify virtio-ccw part, reorganize
* Use WITH_TMP instead of one-shot VMStateInfo's

Halil Pasic (7):
s390x: vmstatify config migration for virtio-ccw
s390x: add helper get_machine_class
s390x: add css_migration_enabled to machine class s390x/css: add missing css state conditionally s390x/css: add ORB to SubchDev
s390x/css: activate ChannelSubSys migration s390x/css: use SubchDev.orb

 hw/intc/s390_flic.c                |  48 ++++
 hw/s390x/ccw-device.c              |  10 +
 hw/s390x/ccw-device.h              |   4 +
 hw/s390x/css.c                     | 494 +++++++++++++++++++++++++------------
 hw/s390x/s390-virtio-ccw.c         |  58 +++--
 hw/s390x/virtio-ccw.c              | 155 ++++++------
 include/hw/s390x/css.h             |  17 +-
 include/hw/s390x/s390-virtio-ccw.h |   7 +
 include/hw/s390x/s390_flic.h       |   5 +
 9 files changed, 544 insertions(+), 254 deletions(-)
Signature · 1 line
2.11.2
#1 lore raw

PATCH v2 1/7 s390x: vmstatify config migration for virtio-ccw

Let's vmstatify virtio_ccw_save_config and virtio_ccw_load_config for flexibility (extending using subsections) and for fun.

To achieve this we need to hack the config_vector, which is VirtIODevice (that is common virtio) state, in the middle of the VirtioCcwDevice state representation. This somewhat ugly, but we have no choice because the stream format needs to be preserved.

Almost no changes in behavior. Exception is everything that comes with vmstate like extra bookkeeping about what's in the stream, and maybe some extra checks and better error reporting.

---

Note: Do not review this here! There is a stand alone patch on the list. Having this here is to is just for convenience.

---
 hw/intc/s390_flic.c          |  28 ++++
 hw/s390x/ccw-device.c        |  10 ++
 hw/s390x/ccw-device.h        |   4 +
 hw/s390x/css.c               | 361 ++++++++++++++++++++++++++-----------------
 hw/s390x/virtio-ccw.c        | 154 +++++++++---------
 include/hw/s390x/css.h       |  12 +-
 include/hw/s390x/s390_flic.h |   5 +
 7 files changed, 354 insertions(+), 220 deletions(-)
hw/intc/s390_flic.c +28 -0
index 711c11454f..7e7546a576 100644
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "hw/qdev.h"
 #include "qapi/error.h"
+#include "hw/s390x/s390-virtio-ccw.h"
 
 S390FLICState *s390_get_flic(void)
 {
@@ -137,3 +138,30 @@ static void qemu_s390_flic_register_types(void)
 }
 
 type_init(qemu_s390_flic_register_types)
+
+const VMStateDescription vmstate_adapter_info = {
+    .name = "s390_adapter_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(ind_offset, AdapterInfo),
+        /*
+         * We do not have to migrate neither the id nor the addresses.
+         * The id is set by css_register_io_adapter and the addresses
+         * are set based on the IndAddr objects after those get mapped.
+         */
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+const VMStateDescription vmstate_adapter_routes = {
+
+    .name = "s390_adapter_routes",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_STRUCT(adapter, AdapterRoutes, 1, vmstate_adapter_info, \
+                       AdapterInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
hw/s390x/ccw-device.c +10 -0
index fb8d640a7e..f9bfa154d6 100644
@@ -50,6 +50,16 @@ static void ccw_device_class_init(ObjectClass *klass, void *data)
     dc->props = ccw_device_properties;
 }
 
+const VMStateDescription vmstate_ccw_dev = {
+    .name = "s390_ccw_dev",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_STRUCT_POINTER(sch, CcwDevice, vmstate_subch_dev, SubchDev),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const TypeInfo ccw_device_info = {
     .name = TYPE_CCW_DEVICE,
     .parent = TYPE_DEVICE,
hw/s390x/ccw-device.h +4 -0
index 89c8e5dff7..4e6af287e7 100644
@@ -27,6 +27,10 @@ typedef struct CcwDevice {
     CssDevId subch_id;
 } CcwDevice;
 
+extern const VMStateDescription vmstate_ccw_dev;
+#define VMSTATE_CCW_DEVICE(_field, _state)                     \
+    VMSTATE_STRUCT(_field, _state, 1, vmstate_ccw_dev, CcwDevice)
+
 typedef struct CCWDeviceClass {
     DeviceClass parent_class;
     void (*unplug)(HotplugHandler *, DeviceState *, Error **);
hw/s390x/css.c +218 -143

385 lines not on this page · raw message

hw/s390x/virtio-ccw.c +80 -74

174 lines not on this page · raw message

include/hw/s390x/css.h +9 -3
index e61fa74d9b..d74e44d312 100644
@@ -88,6 +88,7 @@ struct SubchDev {
     bool ccw_fmt_1;
     bool thinint_active;
     uint8_t ccw_no_data_cnt;
+    uint16_t migrated_schid; /* used for missmatch detection */
     /* transport-provided data: */
     int (*ccw_cb) (SubchDev *, CCW1);
     void (*disable_cb)(SubchDev *);
@@ -95,22 +96,27 @@ struct SubchDev {
     void *driver_data;
 };
 
+extern const VMStateDescription vmstate_subch_dev;
+
 typedef struct IndAddr {
     hwaddr addr;
     uint64_t map;
     unsigned long refcnt;
-    int len;
+    int32_t len;
     QTAILQ_ENTRY(IndAddr) sibling;
 } IndAddr;
 
+extern const VMStateDescription vmstate_ind_addr;
+
+#define VMSTATE_PTR_TO_IND_ADDR(_f, _s)                                   \
+    VMSTATE_STRUCT(_f, _s, 1, vmstate_ind_addr, IndAddr*)
+
 IndAddr *get_indicator(hwaddr ind_addr, int len);
 void release_indicator(AdapterInfo *adapter, IndAddr *indicator);
 int map_indicator(AdapterInfo *adapter, IndAddr *indicator);
 
 typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t ssid,
                                        uint16_t schid);
-void subch_device_save(SubchDev *s, QEMUFile *f);
-int subch_device_load(SubchDev *s, QEMUFile *f);
 int css_create_css_image(uint8_t cssid, bool default_image);
 bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno);
 void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
include/hw/s390x/s390_flic.h +5 -0
index f9e6890c90..caa6fc608d 100644
@@ -31,6 +31,11 @@ typedef struct AdapterRoutes {
     int gsi[ADAPTER_ROUTES_MAX_GSI];
 } AdapterRoutes;
 
+extern const VMStateDescription vmstate_adapter_routes;
+
+#define VMSTATE_ADAPTER_ROUTES(_f, _s) \
+    VMSTATE_STRUCT(_f, _s, 1, vmstate_adapter_routes, AdapterRoutes)
+
 #define TYPE_S390_FLIC_COMMON "s390-flic"
 #define S390_FLIC_COMMON(obj) \
     OBJECT_CHECK(S390FLICState, (obj), TYPE_S390_FLIC_COMMON)
Signature · 1 line
2.11.2
#6 lore raw

PATCH v2 4/7 s390x/css: add missing css state conditionally

In reply to Halil Pasic

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Let's also annotate the bits which do not need to be migrated for better readability.

---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)
hw/intc/s390_flic.c +20 -0
index 7e7546a576..b889e74571 100644
@@ -139,6 +139,22 @@ static void qemu_s390_flic_register_types(void)
 
 type_init(qemu_s390_flic_register_types)
 
+static bool adapter_info_so_needed(void *opaque)
+{
+    return css_migration_enabled();
+}
+
+const VMStateDescription vmstate_adapter_info_so = {
+    .name = "s390_adapter_info/summary_offset",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = adapter_info_so_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(summary_offset, AdapterInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_adapter_info = {
     .name = "s390_adapter_info",
     .version_id = 1,
@@ -152,6 +168,10 @@ const VMStateDescription vmstate_adapter_info = {
          */
         VMSTATE_END_OF_LIST()
     },
+    .subsections = (const VMStateDescription * []) {
+        &vmstate_adapter_info_so,
+        NULL
+    }
 };
 
 const VMStateDescription vmstate_adapter_routes = {
hw/s390x/css.c +74 -0

108 lines not on this page · raw message

Signature · 1 line
2.11.2
#4 lore raw

PATCH v2 3/7 s390x: add css_migration_enabled to machine class

In reply to Halil Pasic

Currently the migration of the channel subsystem (css) is only partial and is done by the virtio ccw proxies -- the only migratable css devices existing at the moment.

With the current work on emulated and passthrough devices we need to decouple the migration of the channel subsystem state from virtio ccw, and have a separate section for it. A new section however necessarily breaks the migration compatibility.

So let us introduce a switch at the machine class, and put it in 'off' state for now. We will turn the switch 'on' for future machines once all preparations are met. For compatibility machines the switch will stay 'off'.

---
 hw/s390x/s390-virtio-ccw.c         | 13 +++++++++++++
 include/hw/s390x/s390-virtio-ccw.h |  7 +++++++
 2 files changed, 20 insertions(+)
hw/s390x/s390-virtio-ccw.c +13 -0
index 04148916ed..95256d3982 100644
@@ -196,6 +196,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
 
     s390mc->ri_allowed = true;
     s390mc->cpu_model_allowed = true;
+    s390mc->css_migration_enabled = false; /* TODO: set to true */
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
     mc->hot_add_cpu = s390_hot_add_cpu;
@@ -344,6 +345,11 @@ static const TypeInfo ccw_machine_info = {
     },
 };
 
+bool css_migration_enabled(void)
+{
+    return get_machine_class()->css_migration_enabled;
+}
+
 #define DEFINE_CCW_MACHINE(suffix, verstr, latest)                            \
     static void ccw_machine_##suffix##_class_init(ObjectClass *oc,            \
                                                   void *data)                 \
@@ -445,6 +451,10 @@ static const TypeInfo ccw_machine_info = {
 
 static void ccw_machine_2_10_instance_options(MachineState *machine)
 {
+    /*
+     * TODO Once preparations are done register vmstate for the css if
+     * css_migration_enabled().
+     */
 }
 
 static void ccw_machine_2_10_class_options(MachineClass *mc)
@@ -459,8 +469,11 @@ static void ccw_machine_2_9_instance_options(MachineState *machine)
 
 static void ccw_machine_2_9_class_options(MachineClass *mc)
 {
+    S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
+
     ccw_machine_2_10_class_options(mc);
     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
+    s390mc->css_migration_enabled = false;
 }
 DEFINE_CCW_MACHINE(2_9, "2.9", false);
 
include/hw/s390x/s390-virtio-ccw.h +7 -0
index 7b8a3e4d74..e9c4f4182b 100644
@@ -38,6 +38,7 @@ typedef struct S390CcwMachineClass {
     /*< public >*/
     bool ri_allowed;
     bool cpu_model_allowed;
+    bool css_migration_enabled;
 } S390CcwMachineClass;
 
 /* runtime-instrumentation allowed by the machine */
@@ -45,4 +46,10 @@ bool ri_allowed(void);
 /* cpu model allowed by the machine */
 bool cpu_model_allowed(void);
 
+/**
+ * Returns true if (vmstate based) migration of the channel subsystem
+ * is enabled, false if it is disabled.
+ */
+bool css_migration_enabled(void);
+
 #endif
Signature · 1 line
2.11.2
#14 lore raw

PATCH v2 5/7 s390x/css: add ORB to SubchDev

In reply to Halil Pasic

Since we are going to need a migration compatibility breaking change to activate ChannelSubSys migration let us use the opportunity to introduce ORB to the SubchDev before that (otherwise we would need separate handling e.g. a compat property).

The ORB will be useful for implementing IDA, or async handling of subchannel work.

---
 hw/s390x/css.c         | 35 +++++++++++++++++++++++++++++++++++
 include/hw/s390x/css.h |  1 +
 2 files changed, 36 insertions(+)
hw/s390x/css.c +35 -0
index a15b58d303..e840dfba2a 100644
@@ -163,6 +163,36 @@ static const VMStateDescription vmstate_sense_id = {
     }
 };
 
+static const VMStateDescription vmstate_orb = {
+    .name = "s390_orb",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(intparm, ORB),
+        VMSTATE_UINT16(ctrl0, ORB),
+        VMSTATE_UINT8(lpm, ORB),
+        VMSTATE_UINT8(ctrl1, ORB),
+        VMSTATE_UINT32(cpa, ORB),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static bool vmstate_schdev_orb_needed(void *opaque)
+{
+    return css_migration_enabled();
+}
+
+static const VMStateDescription vmstate_schdev_orb = {
+    .name = "s390_subch_dev/orb",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = vmstate_schdev_orb_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_STRUCT(orb, SubchDev, 1, vmstate_orb, ORB),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static int subch_dev_post_load(void *opaque, int version_id);
 static void subch_dev_pre_save(void *opaque);
 
@@ -187,6 +217,10 @@ const VMStateDescription vmstate_subch_dev = {
         VMSTATE_BOOL(ccw_fmt_1, SubchDev),
         VMSTATE_UINT8(ccw_no_data_cnt, SubchDev),
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (const VMStateDescription * []) {
+        &vmstate_schdev_orb,
+        NULL
     }
 };
 
@@ -1253,6 +1287,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb)
     if (channel_subsys.chnmon_active) {
         css_update_chnmon(sch);
     }
+    sch->orb = *orb;
     sch->channel_prog = orb->cpa;
     /* Trigger the start function. */
     s->ctrl |= (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND);
include/hw/s390x/css.h +1 -0
index d74e44d312..e9c02af550 100644
@@ -89,6 +89,7 @@ struct SubchDev {
     bool thinint_active;
     uint8_t ccw_no_data_cnt;
     uint16_t migrated_schid; /* used for missmatch detection */
+    ORB orb;
     /* transport-provided data: */
     int (*ccw_cb) (SubchDev *, CCW1);
     void (*disable_cb)(SubchDev *);
Signature · 1 line
2.11.2
#16 lore raw

PATCH v2 6/7 s390x/css: activate ChannelSubSys migration

In reply to Halil Pasic

Turn on migration for the channel subsystem for the next machine. For legacy machines we still have to do things the old way.

---
 hw/s390x/css.c             | 5 +++++
 hw/s390x/s390-virtio-ccw.c | 9 ++++-----
 hw/s390x/virtio-ccw.c      | 1 -
 include/hw/s390x/css.h     | 4 ++++
 4 files changed, 13 insertions(+), 6 deletions(-)
hw/s390x/css.c +5 -0
index e840dfba2a..9857eb3d6f 100644
@@ -401,6 +401,11 @@ static int subch_dev_post_load(void *opaque, int version_id)
     return 0;
 }
 
+void css_register_vmstate(void)
+{
+    vmstate_register(NULL, 0, &vmstate_css, &channel_subsys);
+}
+
 IndAddr *get_indicator(hwaddr ind_addr, int len)
 {
     IndAddr *indicator;
hw/s390x/s390-virtio-ccw.c +4 -5
index 95256d3982..3ad6323add 100644
@@ -196,7 +196,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
 
     s390mc->ri_allowed = true;
     s390mc->cpu_model_allowed = true;
-    s390mc->css_migration_enabled = false; /* TODO: set to true */
+    s390mc->css_migration_enabled = true;
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
     mc->hot_add_cpu = s390_hot_add_cpu;
@@ -451,10 +451,9 @@ bool css_migration_enabled(void)
 
 static void ccw_machine_2_10_instance_options(MachineState *machine)
 {
-    /*
-     * TODO Once preparations are done register vmstate for the css if
-     * css_migration_enabled().
-     */
+    if (css_migration_enabled()) {
+        css_register_vmstate();
+    }
 }
 
 static void ccw_machine_2_10_class_options(MachineClass *mc)
hw/s390x/virtio-ccw.c +0 -1
index a75eedeffb..4a0271b0be 100644
@@ -1360,7 +1360,6 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
 
     sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
 
-
     css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
                           d->hotplugged, 1);
 }
include/hw/s390x/css.h +4 -0
index e9c02af550..812fc05804 100644
@@ -209,4 +209,8 @@ extern PropertyInfo css_devid_ro_propinfo;
  * is responsible for unregistering and freeing it.
  */
 SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp);
+
+/** Turn on css migration */
+void css_register_vmstate(void);
+
 #endif
Signature · 1 line
2.11.2
#20 lore raw

PATCH v2 7/7 s390x/css: use SubchDev.orb

In reply to Halil Pasic

Instead of passing around a pointer to ORB let us simplify some functions signatures by using the previously introduced ORB saved at the subchannel (SubchDev).

---
 hw/s390x/css.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
hw/s390x/css.c +9 -10
index 9857eb3d6f..0229cb9412 100644
@@ -854,7 +854,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr,
     return ret;
 }
 
-static void sch_handle_start_func(SubchDev *sch, ORB *orb)
+static void sch_handle_start_func(SubchDev *sch)
 {
 
     PMCW *p = &sch->curr_status.pmcw;
@@ -868,10 +868,10 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb)
 
     if (!(s->ctrl & SCSW_ACTL_SUSP)) {
         /* Start Function triggered via ssch, i.e. we have an ORB */
+        ORB *orb = &sch->orb;
         s->cstat = 0;
         s->dstat = 0;
         /* Look at the orb and try to execute the channel program. */
-        assert(orb != NULL); /* resume does not pass an orb */
         p->intparm = orb->intparm;
         if (!(orb->lpm & path)) {
             /* Generate a deferred cc 3 condition. */
@@ -885,8 +885,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb)
         sch->ccw_no_data_cnt = 0;
         suspend_allowed = !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND);
     } else {
-        /* Start Function resumed via rsch, i.e. we don't have an
-         * ORB */
+        /* Start Function resumed via rsch */
         s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND);
         /* The channel program had been suspended before. */
         suspend_allowed = true;
@@ -962,7 +961,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb)
  * read/writes) asynchronous later on if we start supporting more than
  * our current very simple devices.
  */
-static void do_subchannel_work(SubchDev *sch, ORB *orb)
+static void do_subchannel_work(SubchDev *sch)
 {
 
     SCSW *s = &sch->curr_status.scsw;
@@ -973,7 +972,7 @@ static void do_subchannel_work(SubchDev *sch, ORB *orb)
         sch_handle_halt_func(sch);
     } else if (s->ctrl & SCSW_FCTL_START_FUNC) {
         /* Triggered by both ssch and rsch. */
-        sch_handle_start_func(sch, orb);
+        sch_handle_start_func(sch);
     } else {
         /* Cannot happen. */
         return;
@@ -1182,7 +1181,7 @@ int css_do_csch(SubchDev *sch)
     s->ctrl &= ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL);
     s->ctrl |= SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND;
 
-    do_subchannel_work(sch, NULL);
+    do_subchannel_work(sch);
     ret = 0;
 
 out:
@@ -1223,7 +1222,7 @@ int css_do_hsch(SubchDev *sch)
     }
     s->ctrl |= SCSW_ACTL_HALT_PEND;
 
-    do_subchannel_work(sch, NULL);
+    do_subchannel_work(sch);
     ret = 0;
 
 out:
@@ -1298,7 +1297,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb)
     s->ctrl |= (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND);
     s->flags &= ~SCSW_FLAGS_MASK_PNO;
 
-    do_subchannel_work(sch, orb);
+    do_subchannel_work(sch);
     ret = 0;
 
 out:
@@ -1578,7 +1577,7 @@ int css_do_rsch(SubchDev *sch)
     }
 
     s->ctrl |= SCSW_ACTL_RESUME_PEND;
-    do_subchannel_work(sch, NULL);
+    do_subchannel_work(sch);
     ret = 0;
 
 out:
Signature · 1 line
2.11.2
#22 lore raw
In reply to Halil Pasic
Quoted 9 lines · * Halil Pasic ([email protected]) wrote:

The scope of this patch series is now limited to decoupling channel subsystem migration from the migration of virtio-ccw proxies.

The vmstatifying of virtio-ccw proxies is now done by another series currently consisting of a single patch running under the name 'vmstatify config migration for virtio-ccw'. Since this series depends on that patch, I have included it here too (for convenience).

The reorganization was requested by Dave.

Yes, I think that's OK now.
We've now got a clearer split and no new qemu_put_*'s

Dave

Quoted 14 lines

v1 --> v2:
* Split out the vmystatify virtio-ccw part, reorganize
* Use WITH_TMP instead of one-shot VMStateInfo's

Halil Pasic (7):
s390x: vmstatify config migration for virtio-ccw
s390x: add helper get_machine_class
s390x: add css_migration_enabled to machine class s390x/css: add missing css state conditionally s390x/css: add ORB to SubchDev
s390x/css: activate ChannelSubSys migration s390x/css: use SubchDev.orb

Quoted 14 lines
 hw/intc/s390_flic.c                |  48 ++++
 hw/s390x/ccw-device.c              |  10 +
 hw/s390x/ccw-device.h              |   4 +
 hw/s390x/css.c                     | 494 +++++++++++++++++++++++++------------
 hw/s390x/s390-virtio-ccw.c         |  58 +++--
 hw/s390x/virtio-ccw.c              | 155 ++++++------
 include/hw/s390x/css.h             |  17 +-
 include/hw/s390x/s390-virtio-ccw.h |   7 +
 include/hw/s390x/s390_flic.h       |   5 +
 9 files changed, 544 insertions(+), 254 deletions(-)
Signature · 1 line
2.11.2

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Reviewed-by on v2 4/7
#7 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Halil Pasic
Quoted 10 lines · Halil Pasic

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Quoted 8 lines

Let's also annotate the bits which do not need to be migrated for better readability.

---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)

For the vmstate bits. I have exactly zero clue about s390

Quoted 39 lines
hw/s390x/css.c +31 -0
+static const VMStateDescription vmstate_chp_info = {
+    .name = "s390_chp_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(in_use, ChpInfo),
+        VMSTATE_UINT8(type, ChpInfo),
+        VMSTATE_UINT8(is_virtual, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 typedef struct SubchSet {
     SubchDev *sch[MAX_SCHID + 1];
     unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
@@ -215,6 +248,19 @@ typedef struct CssImage {
     ChpInfo chpids[MAX_CHPID + 1];
 } CssImage;
 
+static const VMStateDescription vmstate_css_img = {
+    .name = "s390_css_img",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        /* Subchannel sets have no relevant state. */
+        VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0,
+                             vmstate_chp_info, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+
+};
 
+static const VMStateDescription vmstate_css = {
+    .name = "s390_css",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_container,
+                         CrwContainer, sibling),

hw/s390x/css.c typedef struct CssImage {

Quoted 10 lines
hw/s390x/css.c +10 -0
+        VMSTATE_BOOL(sei_pending, ChannelSubSys),
+        VMSTATE_BOOL(do_crw_mchk, ChannelSubSys),
+        VMSTATE_BOOL(crws_lost, ChannelSubSys),
+        /* These were kind of migrated by virtio */
+        VMSTATE_UINT8(max_cssid, ChannelSubSys),
+        VMSTATE_UINT8(max_ssid, ChannelSubSys),
+        VMSTATE_BOOL(chnmon_active, ChannelSubSys),
+        VMSTATE_UINT64(chnmon_area, ChannelSubSys),
+        VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID + 1,
+                0, vmstate_css_img, CssImage),

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Or I am missunderstanding something?

Later, Juan.

#17 lore raw

Re: [Qemu-devel] [PATCH v2 6/7] s390x/css: activate ChannelSubSys migration

In reply to Halil Pasic
Quoted 10 lines · Halil Pasic

Turn on migration for the channel subsystem for the next machine. For legacy machines we still have to do things the old way.

---
 hw/s390x/css.c             | 5 +++++
 hw/s390x/s390-virtio-ccw.c | 9 ++++-----
 hw/s390x/virtio-ccw.c      | 1 -
 include/hw/s390x/css.h     | 4 ++++
 4 files changed, 13 insertions(+), 6 deletions(-)

[...]

hw/s390x/virtio-ccw.c static void virtio_ccw_device_plugged(DeviceState *d, Error **errp) · line 1365

Quoted 13 lines

static void ccw_machine_2_10_class_options(MachineClass *mc)

hw/s390x/virtio-ccw.c +0 -1
index a75eedeffb..4a0271b0be 100644
@@ -1360,7 +1360,6 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
 
     sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
 
-
     css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
                           d->hotplugged, 1);
 }

Unrelated white-space change?

Thomas

#8 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Juan Quintela
Quoted 14 lines · Juan Quintela
Quoted 13 lines · Halil Pasic

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Let's also annotate the bits which do not need to be migrated for better readability.

Quoted 8 lines
Quoted 5 lines
---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)

Thanks!

Quoted 60 lines

For the vmstate bits. I have exactly zero clue about s390

Quoted 39 lines
hw/s390x/css.c +31 -0
+static const VMStateDescription vmstate_chp_info = {
+    .name = "s390_chp_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(in_use, ChpInfo),
+        VMSTATE_UINT8(type, ChpInfo),
+        VMSTATE_UINT8(is_virtual, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 typedef struct SubchSet {
     SubchDev *sch[MAX_SCHID + 1];
     unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
@@ -215,6 +248,19 @@ typedef struct CssImage {
     ChpInfo chpids[MAX_CHPID + 1];
 } CssImage;
 
+static const VMStateDescription vmstate_css_img = {
+    .name = "s390_css_img",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        /* Subchannel sets have no relevant state. */
+        VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0,
+                             vmstate_chp_info, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+
+};
 
+static const VMStateDescription vmstate_css = {
+    .name = "s390_css",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_container,
+                         CrwContainer, sibling),

hw/s390x/css.c typedef struct CssImage {

Quoted 10 lines
hw/s390x/css.c +10 -0
+        VMSTATE_BOOL(sei_pending, ChannelSubSys),
+        VMSTATE_BOOL(do_crw_mchk, ChannelSubSys),
+        VMSTATE_BOOL(crws_lost, ChannelSubSys),
+        /* These were kind of migrated by virtio */
+        VMSTATE_UINT8(max_cssid, ChannelSubSys),
+        VMSTATE_UINT8(max_ssid, ChannelSubSys),
+        VMSTATE_BOOL(chnmon_active, ChannelSubSys),
+        VMSTATE_UINT64(chnmon_area, ChannelSubSys),
+        VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID + 1,
+                0, vmstate_css_img, CssImage),

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

Quoted 8 lines

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Or I am missunderstanding something?

I think you are misunderstanding. Sparse arrays of pointers were not supported in the first place. Support was added by me recentily (patch 07d4e69 "migration/vmstate: fix array of ptr with nullptrs"). For a null pointer just a single byte is transmitted. So we should be more like around 64KB, given that it is really sparse. Bottom line, the in stream representation is at least as efficient as the in memory representation.

Of course we could do something special for sparse arrays of pointers in general, and indeed, one of the possibilities is a list/vector of non null indexes.

I would like to ask the s390x maintainers (mainly Connie) about the particular case, and the migration maintainers (I spontaneously think of you Juan and Dave) about the general case (If we want to have something like VMSTATE_ARRAY_OF_POINTER_TO_STRUCT_SPARSE).

Regards,
Halil

Quoted 2 lines

Later, Juan.

#18 lore raw

Re: [Qemu-devel] [PATCH v2 6/7] s390x/css: activate ChannelSubSys migration

In reply to Thomas Huth
Quoted 21 lines · Thomas Huth
Quoted 10 lines · Halil Pasic

Turn on migration for the channel subsystem for the next machine. For legacy machines we still have to do things the old way.

---
 hw/s390x/css.c             | 5 +++++
 hw/s390x/s390-virtio-ccw.c | 9 ++++-----
 hw/s390x/virtio-ccw.c      | 1 -
 include/hw/s390x/css.h     | 4 ++++
 4 files changed, 13 insertions(+), 6 deletions(-)

[...]

Quoted 9 lines

static void ccw_machine_2_10_class_options(MachineClass *mc)

hw/s390x/virtio-ccw.c +0 -0
index a75eedeffb..4a0271b0be 100644
@@ -1360,7 +1360,6 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
 
     sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
 
Quoted 9 lines

hw/s390x/virtio-ccw.c static void virtio_ccw_device_plugged(DeviceState *d, Error **errp) · line 1365

Quoted 4 lines
hw/s390x/virtio-ccw.c +0 -1
-
     css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
                           d->hotplugged, 1);
 }

Unrelated white-space change?

Thomas

Indeed :-( Will remove for the next re-spin.

Thanks a lot!

Halil

Acked-by on v2 2/7
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/7] s390x: add helper get_machine_class

In reply to Halil Pasic
Quoted 8 lines · On Mon, 29 May 2017 15:55:15 +0200 Halil Pasic <[email protected]> wrote:

We will need the machine class at machine initialization time, so the usual way via qdev won't do. Let's cache the machine class and also use the default values of the base machine for capability discovery.

---
 hw/s390x/s390-virtio-ccw.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

I'm still not sure if that is the best way to go; but if it isn't, I'm unable to find that better path. So,

Acked-by on v2 3/7
#5 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] s390x: add css_migration_enabled to machine class

In reply to Halil Pasic
Quoted 2 lines · On Mon, 29 May 2017 15:55:16 +0200 Halil Pasic <[email protected]> wrote:

Currently the migration of the channel subsystem (css) is only partial and is done by the virtio ccw proxies -- the only migratable css devices

extra blank ---------------------------------------------------^

Quoted 78 lines

existing at the moment.

With the current work on emulated and passthrough devices we need to decouple the migration of the channel subsystem state from virtio ccw, and have a separate section for it. A new section however necessarily breaks the migration compatibility.

So let us introduce a switch at the machine class, and put it in 'off' state for now. We will turn the switch 'on' for future machines once all preparations are met. For compatibility machines the switch will stay 'off'.

---
 hw/s390x/s390-virtio-ccw.c         | 13 +++++++++++++
 include/hw/s390x/s390-virtio-ccw.h |  7 +++++++
 2 files changed, 20 insertions(+)
hw/s390x/s390-virtio-ccw.c +13 -0
index 04148916ed..95256d3982 100644
@@ -196,6 +196,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
 
     s390mc->ri_allowed = true;
     s390mc->cpu_model_allowed = true;
+    s390mc->css_migration_enabled = false; /* TODO: set to true */
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
     mc->hot_add_cpu = s390_hot_add_cpu;
@@ -344,6 +345,11 @@ static const TypeInfo ccw_machine_info = {
     },
 };
 
+bool css_migration_enabled(void)
+{
+    return get_machine_class()->css_migration_enabled;
+}
+
 #define DEFINE_CCW_MACHINE(suffix, verstr, latest)                            \
     static void ccw_machine_##suffix##_class_init(ObjectClass *oc,            \
                                                   void *data)                 \
@@ -445,6 +451,10 @@ static const TypeInfo ccw_machine_info = {
 
 static void ccw_machine_2_10_instance_options(MachineState *machine)
 {
+    /*
+     * TODO Once preparations are done register vmstate for the css if
+     * css_migration_enabled().
+     */
 }
 
 static void ccw_machine_2_10_class_options(MachineClass *mc)
@@ -459,8 +469,11 @@ static void ccw_machine_2_9_instance_options(MachineState *machine)
 
 static void ccw_machine_2_9_class_options(MachineClass *mc)
 {
+    S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
+
     ccw_machine_2_10_class_options(mc);
     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
+    s390mc->css_migration_enabled = false;
 }
 DEFINE_CCW_MACHINE(2_9, "2.9", false);
 
include/hw/s390x/s390-virtio-ccw.h +1 -0
index 7b8a3e4d74..e9c4f4182b 100644
@@ -38,6 +38,7 @@ typedef struct S390CcwMachineClass {
     /*< public >*/
     bool ri_allowed;
     bool cpu_model_allowed;
+    bool css_migration_enabled;
 } S390CcwMachineClass;
 
 /* runtime-instrumentation allowed by the machine */

include/hw/s390x/s390-virtio-ccw.h bool ri_allowed(void); · line 55

Quoted 10 lines
include/hw/s390x/s390-virtio-ccw.h +6 -0
@@ -45,4 +46,10 @@ bool ri_allowed(void);
 /* cpu model allowed by the machine */
 bool cpu_model_allowed(void);
 
+/**
+ * Returns true if (vmstate based) migration of the channel subsystem
+ * is enabled, false if it is disabled.
+ */
+bool css_migration_enabled(void);
+
 #endif
#9 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Halil Pasic
Quoted 102 lines · On Thu, 1 Jun 2017 11:35:27 +0200 Halil Pasic <[email protected]> wrote:
Quoted 14 lines · Juan Quintela
Quoted 13 lines · Halil Pasic

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Let's also annotate the bits which do not need to be migrated for better readability.

Quoted 8 lines
Quoted 5 lines
---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)

Thanks!

Quoted 60 lines

For the vmstate bits. I have exactly zero clue about s390

Quoted 39 lines
hw/s390x/css.c +31 -0
+static const VMStateDescription vmstate_chp_info = {
+    .name = "s390_chp_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(in_use, ChpInfo),
+        VMSTATE_UINT8(type, ChpInfo),
+        VMSTATE_UINT8(is_virtual, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 typedef struct SubchSet {
     SubchDev *sch[MAX_SCHID + 1];
     unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
@@ -215,6 +248,19 @@ typedef struct CssImage {
     ChpInfo chpids[MAX_CHPID + 1];
 } CssImage;
 
+static const VMStateDescription vmstate_css_img = {
+    .name = "s390_css_img",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        /* Subchannel sets have no relevant state. */
+        VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0,
+                             vmstate_chp_info, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+
+};
 
+static const VMStateDescription vmstate_css = {
+    .name = "s390_css",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_container,
+                         CrwContainer, sibling),

hw/s390x/css.c typedef struct CssImage {

Quoted 10 lines
hw/s390x/css.c +10 -0
+        VMSTATE_BOOL(sei_pending, ChannelSubSys),
+        VMSTATE_BOOL(do_crw_mchk, ChannelSubSys),
+        VMSTATE_BOOL(crws_lost, ChannelSubSys),
+        /* These were kind of migrated by virtio */
+        VMSTATE_UINT8(max_cssid, ChannelSubSys),
+        VMSTATE_UINT8(max_ssid, ChannelSubSys),
+        VMSTATE_BOOL(chnmon_active, ChannelSubSys),
+        VMSTATE_UINT64(chnmon_area, ChannelSubSys),
+        VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID + 1,
+                0, vmstate_css_img, CssImage),

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

Quoted 8 lines

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Or I am missunderstanding something?

I think you are misunderstanding. Sparse arrays of pointers were not supported in the first place. Support was added by me recentily (patch 07d4e69 "migration/vmstate: fix array of ptr with nullptrs"). For a null pointer just a single byte is transmitted. So we should be more like around 64KB, given that it is really sparse. Bottom line, the in stream representation is at least as efficient as the in memory representation.

Quoted 3 lines

Of course we could do something special for sparse arrays of pointers in general, and indeed, one of the possibilities is a list/vector of non null indexes.

Just as discussion fodder: For a run-of-the-mill qemu guest, I'd expect a low double-digit number of subchannels in css 0xfe, in subchannel set 0, which are clustered right at the beginning, and one chpid (0) in css 0xfe.

As the subchannel id is autogenerated based upon the devno (if provided), it is easy to have subchannels in an arbitrary subchannel set (of which there are only four), but to get high subchannel ids with a lot of empty slots before, you'd have to create a lot (really a lot) of devices and then detach most of them again - not a very likely pattern.

The 3270 support does not really change much: one additional subchannel (with the same characteristics) and one further chpid. But I don't expect many people to use 3270, and it is not (yet) migratable anyway.

vfio-ccw devices will be in another css (possibly mapped), but they are not migrateable either.

So if we want to optimize, some "nothing of interest beyond that point" marker might be useful - but not very.

Quoted 11 lines

I would like to ask the s390x maintainers (mainly Connie) about the particular case, and the migration maintainers (I spontaneously think of you Juan and Dave) about the general case (If we want to have something like VMSTATE_ARRAY_OF_POINTER_TO_STRUCT_SPARSE).

Regards,
Halil

Quoted 2 lines

Later, Juan.

Reviewed-by on v2 4/7
#13 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Halil Pasic
Quoted 7 lines · On Mon, 29 May 2017 15:55:17 +0200 Halil Pasic <[email protected]> wrote:

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via

Either 'with' or 'via' ;)

Quoted 121 lines

css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Let's also annotate the bits which do not need to be migrated for better readability.

---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)
hw/intc/s390_flic.c +20 -0
index 7e7546a576..b889e74571 100644
@@ -139,6 +139,22 @@ static void qemu_s390_flic_register_types(void)
 
 type_init(qemu_s390_flic_register_types)
 
+static bool adapter_info_so_needed(void *opaque)
+{
+    return css_migration_enabled();
+}
+
+const VMStateDescription vmstate_adapter_info_so = {
+    .name = "s390_adapter_info/summary_offset",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = adapter_info_so_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(summary_offset, AdapterInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_adapter_info = {
     .name = "s390_adapter_info",
     .version_id = 1,
@@ -152,6 +168,10 @@ const VMStateDescription vmstate_adapter_info = {
          */
         VMSTATE_END_OF_LIST()
     },
+    .subsections = (const VMStateDescription * []) {
+        &vmstate_adapter_info_so,
+        NULL
+    }
 };
 
 const VMStateDescription vmstate_adapter_routes = {
hw/s390x/css.c +46 -0
index 15517a16e4..a15b58d303 100644
@@ -27,12 +27,45 @@ typedef struct CrwContainer {
     QTAILQ_ENTRY(CrwContainer) sibling;
 } CrwContainer;
 
+static const VMStateDescription vmstate_crw = {
+    .name = "s390_crw",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT16(flags, CRW),
+        VMSTATE_UINT16(rsid, CRW),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+static const VMStateDescription vmstate_crw_container = {
+    .name = "s390_crw_container",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_STRUCT(crw, CrwContainer, 0, vmstate_crw, CRW),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
 typedef struct ChpInfo {
     uint8_t in_use;
     uint8_t type;
     uint8_t is_virtual;
 } ChpInfo;
 
+static const VMStateDescription vmstate_chp_info = {
+    .name = "s390_chp_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(in_use, ChpInfo),
+        VMSTATE_UINT8(type, ChpInfo),
+        VMSTATE_UINT8(is_virtual, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 typedef struct SubchSet {
     SubchDev *sch[MAX_SCHID + 1];
     unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
@@ -215,6 +248,19 @@ typedef struct CssImage {
     ChpInfo chpids[MAX_CHPID + 1];
 } CssImage;
 
+static const VMStateDescription vmstate_css_img = {
+    .name = "s390_css_img",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        /* Subchannel sets have no relevant state. */
+        VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0,
+                             vmstate_chp_info, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+
+};
+
 typedef struct IoAdapter {
     uint32_t id;
     uint8_t type;

hw/s390x/css.c typedef struct ChannelSubSys { · line 285

Quoted 8 lines
hw/s390x/css.c +2 -0
@@ -232,10 +278,34 @@ typedef struct ChannelSubSys {
     uint64_t chnmon_area;
     CssImage *css[MAX_CSSID + 1];
     uint8_t default_cssid;
+    /* don't migrate */
     IoAdapter *io_adapters[CSS_IO_ADAPTER_TYPE_NUMS][MAX_ISC + 1];
+    /* don't migrate */
     QTAILQ_HEAD(, IndAddr) indicator_addresses;
 } ChannelSubSys;

I think a couple of words as to _why_ they are not migrated would be nice. Imagine revisiting this in a few years :)

Quoted 27 lines
hw/s390x/css.c +22 -0
+static const VMStateDescription vmstate_css = {
+    .name = "s390_css",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_container,
+                         CrwContainer, sibling),
+        VMSTATE_BOOL(sei_pending, ChannelSubSys),
+        VMSTATE_BOOL(do_crw_mchk, ChannelSubSys),
+        VMSTATE_BOOL(crws_lost, ChannelSubSys),
+        /* These were kind of migrated by virtio */
+        VMSTATE_UINT8(max_cssid, ChannelSubSys),
+        VMSTATE_UINT8(max_ssid, ChannelSubSys),
+        VMSTATE_BOOL(chnmon_active, ChannelSubSys),
+        VMSTATE_UINT64(chnmon_area, ChannelSubSys),
+        VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID + 1,
+                0, vmstate_css_img, CssImage),
+        VMSTATE_UINT8(default_cssid, ChannelSubSys),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static ChannelSubSys channel_subsys = {
     .pending_crws = QTAILQ_HEAD_INITIALIZER(channel_subsys.pending_crws),
     .do_crw_mchk = true,

hw/s390x/css.c static int subch_dev_post_load(void *opaque, int version_id) · line 354

Quoted 10 lines
hw/s390x/css.c +4 -0
@@ -275,6 +345,10 @@ static int subch_dev_post_load(void *opaque, int version_id)
         css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s);
     }
 
+    if (css_migration_enabled()) {
+        /* No compat voodoo to do ;) */
+        return 0;
+    }
     /*
      * Hack alert. If we don't migrate the channel subsystem status
      * we still need to find out if the guest enabled mss/mcss-e.

Other than the nits,

Reviewed-by on v2 5/7
#15 lore raw

Re: [Qemu-devel] [PATCH v2 5/7] s390x/css: add ORB to SubchDev

In reply to Halil Pasic
Quoted 8 lines · On Mon, 29 May 2017 15:55:18 +0200 Halil Pasic <[email protected]> wrote:

Since we are going to need a migration compatibility breaking change to activate ChannelSubSys migration let us use the opportunity to introduce ORB to the SubchDev before that (otherwise we would need separate handling e.g. a compat property).

The ORB will be useful for implementing IDA, or async handling of subchannel work.

Quoted 6 lines
---
 hw/s390x/css.c         | 35 +++++++++++++++++++++++++++++++++++
 include/hw/s390x/css.h |  1 +
 2 files changed, 36 insertions(+)
#10 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Cornelia Huck
Quoted 82 lines · Cornelia Huck
Quoted 79 lines · On Thu, 1 Jun 2017 11:35:27 +0200 Halil Pasic <[email protected]> wrote:
Quoted 14 lines · Juan Quintela
Quoted 13 lines · Halil Pasic

Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is).

Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled.

Let's also annotate the bits which do not need to be migrated for better readability.

Quoted 8 lines
Quoted 5 lines
---
 hw/intc/s390_flic.c | 20 +++++++++++++++
 hw/s390x/css.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)

Thanks!

Quoted 53 lines

For the vmstate bits. I have exactly zero clue about s390

Quoted 49 lines
hw/s390x/css.c +41 -0
+static const VMStateDescription vmstate_chp_info = {
+    .name = "s390_chp_info",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(in_use, ChpInfo),
+        VMSTATE_UINT8(type, ChpInfo),
+        VMSTATE_UINT8(is_virtual, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 typedef struct SubchSet {
     SubchDev *sch[MAX_SCHID + 1];
     unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
@@ -215,6 +248,19 @@ typedef struct CssImage {
     ChpInfo chpids[MAX_CHPID + 1];
 } CssImage;
 
+static const VMStateDescription vmstate_css_img = {
+    .name = "s390_css_img",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        /* Subchannel sets have no relevant state. */
+        VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0,
+                             vmstate_chp_info, ChpInfo),
+        VMSTATE_END_OF_LIST()
+    }
+
+};
 
+static const VMStateDescription vmstate_css = {
+    .name = "s390_css",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_container,
+                         CrwContainer, sibling),
+        VMSTATE_BOOL(sei_pending, ChannelSubSys),
+        VMSTATE_BOOL(do_crw_mchk, ChannelSubSys),
+        VMSTATE_BOOL(crws_lost, ChannelSubSys),
+        /* These were kind of migrated by virtio */
+        VMSTATE_UINT8(max_cssid, ChannelSubSys),
+        VMSTATE_UINT8(max_ssid, ChannelSubSys),
+        VMSTATE_BOOL(chnmon_active, ChannelSubSys),
+        VMSTATE_UINT64(chnmon_area, ChannelSubSys),
+        VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID + 1,
+                0, vmstate_css_img, CssImage),
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is

#define MAX_CSSID 255
("include/hw/s390x/css.h" line 23)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Or I am missunderstanding something?

I think you are misunderstanding. Sparse arrays of pointers were not supported in the first place. Support was added by me recentily (patch 07d4e69 "migration/vmstate: fix array of ptr with nullptrs"). For a null pointer just a single byte is transmitted. So we should be more like around 64KB, given that it is really sparse. Bottom line, the in stream

Given that my calculation is also wrong. The overhead is below 255 bytes (overhead compared to not transferring anything for null pointers, which is clearly an unrealistic lower bound case).

Quoted 22 lines
Quoted 5 lines

representation is at least as efficient as the in memory representation.

Of course we could do something special for sparse arrays of pointers in general, and indeed, one of the possibilities is a list/vector of non null indexes.

Just as discussion fodder: For a run-of-the-mill qemu guest, I'd expect a low double-digit number of subchannels in css 0xfe, in subchannel set 0, which are clustered right at the beginning, and one chpid (0) in css 0xfe.

As the subchannel id is autogenerated based upon the devno (if provided), it is easy to have subchannels in an arbitrary subchannel set (of which there are only four), but to get high subchannel ids with a lot of empty slots before, you'd have to create a lot (really a lot) of devices and then detach most of them again - not a very likely pattern.

The 3270 support does not really change much: one additional subchannel (with the same characteristics) and one further chpid. But I don't expect many people to use 3270, and it is not (yet) migratable anyway.

Quoted 5 lines

vfio-ccw devices will be in another css (possibly mapped), but they are not migrateable either.

So if we want to optimize, some "nothing of interest beyond that point" marker might be useful - but not very.

Thus I do not think we need extra sparse array handling for this.

(Nevertheless an extra sparse array handling might make sense for vmstate core, provided there is an use case).

Halil

Quoted 14 lines
Quoted 12 lines

I would like to ask the s390x maintainers (mainly Connie) about the particular case, and the migration maintainers (I spontaneously think of you Juan and Dave) about the general case (If we want to have something like VMSTATE_ARRAY_OF_POINTER_TO_STRUCT_SPARSE).

Regards,
Halil

Quoted 2 lines

Later, Juan.

Reviewed-by on v2 6/7
#19 lore raw

Re: [Qemu-devel] [PATCH v2 6/7] s390x/css: activate ChannelSubSys migration

In reply to Halil Pasic
Quoted 10 lines · On Mon, 29 May 2017 15:55:19 +0200 Halil Pasic <[email protected]> wrote:

Turn on migration for the channel subsystem for the next machine. For legacy machines we still have to do things the old way.

---
 hw/s390x/css.c             | 5 +++++
 hw/s390x/s390-virtio-ccw.c | 9 ++++-----
 hw/s390x/virtio-ccw.c      | 1 -
 include/hw/s390x/css.h     | 4 ++++
 4 files changed, 13 insertions(+), 6 deletions(-)

From your reply to Christian's mail, I presume you also tested the result with some compat machines?

With the whitespace change removed,

Reviewed-by on v2 7/7
#21 lore raw

Re: [Qemu-devel] [PATCH v2 7/7] s390x/css: use SubchDev.orb

In reply to Halil Pasic
Quoted 2 lines · On Mon, 29 May 2017 15:55:20 +0200 Halil Pasic <[email protected]> wrote:

Instead of passing around a pointer to ORB let us simplify some functions signatures by using the previously introduced ORB saved at the

Either "function signatures" or "functions' signatures" :)

Quoted 7 lines

subchannel (SubchDev).

---
 hw/s390x/css.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

This is a nice rework.

#23 lore raw
In reply to Halil Pasic
Quoted 23 lines · On Mon, 29 May 2017 15:55:13 +0200 Halil Pasic <[email protected]> wrote:

The scope of this patch series is now limited to decoupling channel subsystem migration from the migration of virtio-ccw proxies.

The vmstatifying of virtio-ccw proxies is now done by another series currently consisting of a single patch running under the name 'vmstatify config migration for virtio-ccw'. Since this series depends on that patch, I have included it here too (for convenience).

The reorganization was requested by Dave.

v1 --> v2:
* Split out the vmystatify virtio-ccw part, reorganize
* Use WITH_TMP instead of one-shot VMStateInfo's

Halil Pasic (7):
s390x: vmstatify config migration for virtio-ccw
s390x: add helper get_machine_class
s390x: add css_migration_enabled to machine class s390x/css: add missing css state conditionally s390x/css: add ORB to SubchDev
s390x/css: activate ChannelSubSys migration s390x/css: use SubchDev.orb

Quoted 11 lines
 hw/intc/s390_flic.c                |  48 ++++
 hw/s390x/ccw-device.c              |  10 +
 hw/s390x/ccw-device.h              |   4 +
 hw/s390x/css.c                     | 494 +++++++++++++++++++++++++------------
 hw/s390x/s390-virtio-ccw.c         |  58 +++--
 hw/s390x/virtio-ccw.c              | 155 ++++++------
 include/hw/s390x/css.h             |  17 +-
 include/hw/s390x/s390-virtio-ccw.h |   7 +
 include/hw/s390x/s390_flic.h       |   5 +
 9 files changed, 544 insertions(+), 254 deletions(-)

This patch set looks good to me, just some comments on the individual patches.

#11 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

In reply to Halil Pasic
Quoted 11 lines · Halil Pasic
Quoted 7 lines · Cornelia Huck
Quoted 3 lines · On Thu, 1 Jun 2017 11:35:27 +0200 Halil Pasic <[email protected]> wrote:
Quoted 3 lines

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is

#define MAX_CSSID 255
("include/hw/s390x/css.h" line 23)

I have to grep better O:-)

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Or I am missunderstanding something?

I think you are misunderstanding. Sparse arrays of pointers were not supported in the first place. Support was added by me recentily (patch 07d4e69 "migration/vmstate: fix array of ptr with nullptrs"). For a null pointer just a single byte is transmitted. So we should be more like around 64KB, given that it is really sparse. Bottom line, the in stream

Quoted 3 lines

Given that my calculation is also wrong. The overhead is below 255 bytes (overhead compared to not transferring anything for null pointers, which is clearly an unrealistic lower bound case).

Yeap, I greeped wrong. 255 x 255 makes no sense to optimize at all. Sorry for the noise.

Quoted 25 lines
Quoted 25 lines
Quoted 5 lines

representation is at least as efficient as the in memory representation.

Of course we could do something special for sparse arrays of pointers in general, and indeed, one of the possibilities is a list/vector of non null indexes.

Just as discussion fodder: For a run-of-the-mill qemu guest, I'd expect a low double-digit number of subchannels in css 0xfe, in subchannel set 0, which are clustered right at the beginning, and one chpid (0) in css 0xfe.

As the subchannel id is autogenerated based upon the devno (if provided), it is easy to have subchannels in an arbitrary subchannel set (of which there are only four), but to get high subchannel ids with a lot of empty slots before, you'd have to create a lot (really a lot) of devices and then detach most of them again - not a very likely pattern.

The 3270 support does not really change much: one additional subchannel (with the same characteristics) and one further chpid. But I don't expect many people to use 3270, and it is not (yet) migratable anyway.

vfio-ccw devices will be in another css (possibly mapped), but they are not migrateable either.

Quoted 7 lines
Quoted 2 lines

So if we want to optimize, some "nothing of interest beyond that point" marker might be useful - but not very.

Thus I do not think we need extra sparse array handling for this.

(Nevertheless an extra sparse array handling might make sense for vmstate core, provided there is an use case).

So, I retire all my objections.

Again, sorry for the noise.

Thanks, Juan.

#12 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] s390x/css: add missing css state conditionally

Quoted 70 lines · Juan Quintela
Quoted 11 lines · Halil Pasic
Quoted 7 lines · Cornelia Huck
Quoted 3 lines · On Thu, 1 Jun 2017 11:35:27 +0200 Halil Pasic <[email protected]> wrote:
Quoted 3 lines

I was about to suggest to move css from pointer to an embedded struct, and then noticed that MAX_CSSID is .... 65535. I guess that this is

#define MAX_CSSID 255
("include/hw/s390x/css.h" line 23)

I have to grep better O:-)

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

going to be sparse, very sparse. Perhaps there is an easier way to transmit it?

You are transmiting:

65000 structs each of size MAX_CHPID (255) and each element is byte + byte +byte = 65000 * 255 * 3 = 47 MB.

If it is really sparse, I think that sending something like a list of <index in array> <contents> could make sense, no?

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Or I am missunderstanding something?

I think you are misunderstanding. Sparse arrays of pointers were not supported in the first place. Support was added by me recentily (patch 07d4e69 "migration/vmstate: fix array of ptr with nullptrs"). For a null pointer just a single byte is transmitted. So we should be more like around 64KB, given that it is really sparse. Bottom line, the in stream

Quoted 3 lines

Given that my calculation is also wrong. The overhead is below 255 bytes (overhead compared to not transferring anything for null pointers, which is clearly an unrealistic lower bound case).

Yeap, I greeped wrong. 255 x 255 makes no sense to optimize at all. Sorry for the noise.

Quoted 28 lines
Quoted 27 lines
Quoted 5 lines

representation is at least as efficient as the in memory representation.

Of course we could do something special for sparse arrays of pointers in general, and indeed, one of the possibilities is a list/vector of non null indexes.

Just as discussion fodder: For a run-of-the-mill qemu guest, I'd expect a low double-digit number of subchannels in css 0xfe, in subchannel set 0, which are clustered right at the beginning, and one chpid (0) in css 0xfe.

As the subchannel id is autogenerated based upon the devno (if provided), it is easy to have subchannels in an arbitrary subchannel set (of which there are only four), but to get high subchannel ids with a lot of empty slots before, you'd have to create a lot (really a lot) of devices and then detach most of them again - not a very likely pattern.

The 3270 support does not really change much: one additional subchannel (with the same characteristics) and one further chpid. But I don't expect many people to use 3270, and it is not (yet) migratable anyway.

vfio-ccw devices will be in another css (possibly mapped), but they are not migrateable either.

So if we want to optimize, some "nothing of interest beyond that point" marker might be useful - but not very.

Quoted 8 lines
Quoted 4 lines

Thus I do not think we need extra sparse array handling for this.

(Nevertheless an extra sparse array handling might make sense for vmstate core, provided there is an use case).

So, I retire all my objections.

Again, sorry for the noise.

No problem. Actually, it's appreciated! Better have some false positives than having something stupid slipping in and having to live with it.

Thanks for your review!

Regards,
Halil