From: David Gibson <david@gibson.dropbear.id.au>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com,
ehabkost@redhat.com, marcel@redhat.com, pbonzini@redhat.com,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] VARIANT 1: reuse device compat logic to pick preffered CPU's migration instance_id
Date: Wed, 13 Jul 2016 11:39:16 +1000 [thread overview]
Message-ID: <20160713013916.GB14615@voom.fritz.box> (raw)
In-Reply-To: <20160712101158.3c7cd947@nial.brq.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 7148 bytes --]
On Tue, Jul 12, 2016 at 10:11:58AM +0200, Igor Mammedov wrote:
> On Tue, 12 Jul 2016 15:07:09 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > On Mon, Jul 11, 2016 at 03:42:29PM +0200, Igor Mammedov wrote:
> > > this approach i I preffer as it uses less per machine migration glue
> > > and follows typical compat pattern for devices
> > >
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> >
> > After our IRC discussion last night, I prefer this version as well.
> > We can definitely work with this on Power as well.
> >
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> Bharata,
>
> Could you take this patch but strip out PC parts which were meant
> as usage example only?
>
> I'll post a separate PC patch on top of it as part of or on top of
> cpu-hotplug for PC, as that series changes pc.c significantly and
> resulting PC part of patch will look a bit simpler/different.
>
> >
> > One query regarding the x86 specific implementation below, though.
> >
> > > ---
> > > exec.c | 7 +++++--
> > > hw/i386/pc.c | 10 +++++++---
> > > include/hw/compat.h | 6 +++++-
> > > include/qom/cpu.h | 3 +++
> > > qom/cpu.c | 13 +++++++++++++
> > > 5 files changed, 33 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/exec.c b/exec.c
> > > index 0122ef7..79e1dcb 100644
> > > --- a/exec.c
> > > +++ b/exec.c
> > > @@ -670,6 +670,7 @@ void cpu_exec_init(CPUState *cpu, Error **errp)
> > > {
> > > CPUClass *cc = CPU_GET_CLASS(cpu);
> > > Error *local_err = NULL;
> > > + int migration_id;
> > >
> > > cpu->as = NULL;
> > > cpu->num_ases = 0;
> > > @@ -708,11 +709,13 @@ void cpu_exec_init(CPUState *cpu, Error **errp)
> > > (void) cc;
> > > cpu_list_unlock();
> > > #else
> > > + migration_id = cc->use_migration_id > 0 ?
> > > + cpu->migration_id : cpu->cpu_index;
> > > if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
> > > - vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu);
> > > + vmstate_register(NULL, migration_id, &vmstate_cpu_common, cpu);
> > > }
> > > if (cc->vmsd != NULL) {
> > > - vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu);
> > > + vmstate_register(NULL, migration_id, cc->vmsd, cpu);
> > > }
> > > #endif
> > > }
> > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > > index cd1745e..f041279 100644
> > > --- a/hw/i386/pc.c
> > > +++ b/hw/i386/pc.c
> > > @@ -1040,9 +1040,10 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
> > > }
> > >
> > > static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
> > > - Error **errp)
> > > + Error **errp, int migration_id)
> > > {
> > > X86CPU *cpu = NULL;
> > > + CPUState *cs = CPU(cpu);
> > > Error *local_err = NULL;
> > >
> >
> > Any reason not to re-use the apic_id as the migration_id? It's 64-bit
> > here which is no good, but apic_id_t is defined as uint32_t elsewhere,
> > so is that just a bug with the function signature?
> It could be apic_id but I chose to use possible_cpus index to make code
> similar as much as possible so that when I start adding cpu-hotplug to ARM
> it would be possible to reuse some of x86 code that could be generalized
> shared between both archs.
Ok.
> > > cpu = cpu_x86_create(cpu_model, &local_err);
> > > @@ -1050,6 +1051,7 @@ static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
> > > goto out;
> > > }
> > >
> > > + cs->migration_id = migration_id;
> > > object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
> > > object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
> > >
> > > @@ -1093,7 +1095,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
> > > return;
> > > }
> > >
> > > - cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err);
> > > + cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err, id);
> > > if (local_err) {
> > > error_propagate(errp, local_err);
> > > return;
> > > @@ -1137,7 +1139,7 @@ void pc_cpus_init(PCMachineState *pcms)
> > > pcms->possible_cpus->len++;
> > > if (i < smp_cpus) {
> > > cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
> > > - &error_fatal);
> > > + &error_fatal, i);
> > > pcms->possible_cpus->cpus[i].cpu = CPU(cpu);
> > > object_unref(OBJECT(cpu));
> > > }
> > > @@ -2012,7 +2014,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
> > > PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
> > > HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
> > > NMIClass *nc = NMI_CLASS(oc);
> > > + CPUClass *cc = CPU_CLASS(object_class_by_name(TYPE_CPU));
> > >
> > > + cc->use_migration_id = true;
> > > pcmc->get_hotplug_handler = mc->get_hotplug_handler;
> > > pcmc->pci_enabled = true;
> > > pcmc->has_acpi_build = true;
> > > diff --git a/include/hw/compat.h b/include/hw/compat.h
> > > index 636befe..a66e80d 100644
> > > --- a/include/hw/compat.h
> > > +++ b/include/hw/compat.h
> > > @@ -2,7 +2,11 @@
> > > #define HW_COMPAT_H
> > >
> > > #define HW_COMPAT_2_6 \
> > > - /* empty */
> > > + { \
> > > + .driver = TYPE_CPU, \
> > > + .property = "use-migration-id", \
> > > + .value = "off", \
> > > + },
> > >
> > > #define HW_COMPAT_2_5 \
> > > {\
> > > diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> > > index 32f3af3..a29a2c9 100644
> > > --- a/include/qom/cpu.h
> > > +++ b/include/qom/cpu.h
> > > @@ -177,6 +177,8 @@ typedef struct CPUClass {
> > > void *opaque);
> > >
> > > const struct VMStateDescription *vmsd;
> > > + int use_migration_id;
> > > +
> > > int gdb_num_core_regs;
> > > const char *gdb_core_xml_file;
> > > gchar * (*gdb_arch_name)(CPUState *cpu);
> > > @@ -360,6 +362,7 @@ struct CPUState {
> > > (absolute value) offset as small as possible. This reduces code
> > > size, especially for hosts without large memory offsets. */
> > > uint32_t tcg_exit_req;
> > > + int migration_id;
> >
> > Not really in scope for this patch, but I do wonder if
> > vmstate_register() should actually take a uint32_t instead of an int,
> > since that's what it is on the wire, IIUC.
> I think vmstate_register() uses -1 as a way to detect if it should
> do instance_id auto assignment.
> Any way I'll leave answer to this this question to migration
> > experts.
Ah, good point.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-07-13 1:40 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 14:50 [Qemu-devel] [RFC PATCH v2 0/5] sPAPR: Fix migration when CPUs are removed in random order Bharata B Rao
2016-07-07 14:50 ` [Qemu-devel] [RFC PATCH v2 1/5] cpu, target-ppc: Move cpu_vmstate_[un]register calls to cpu_common_[un]realize Bharata B Rao
2016-07-07 14:50 ` [Qemu-devel] [RFC PATCH v2 2/5] cpu: Introduce CPUState::stable_cpu_id Bharata B Rao
2016-07-07 17:52 ` Greg Kurz
2016-07-08 5:21 ` David Gibson
2016-07-08 5:19 ` David Gibson
2016-07-08 11:11 ` Igor Mammedov
2016-07-11 3:22 ` David Gibson
2016-07-11 3:35 ` Bharata B Rao
2016-07-11 7:42 ` Igor Mammedov
2016-07-11 13:42 ` [Qemu-devel] [PATCH] VARIANT 1: reuse device compat logic to pick preffered CPU's migration instance_id Igor Mammedov
2016-07-11 13:42 ` [Qemu-devel] [PATCH] VARIANT 2: use machine specific callback to pick " Igor Mammedov
2016-07-11 14:15 ` [Qemu-devel] [PATCH] VARIANT 1: reuse device compat logic to pick preffered " Paolo Bonzini
2016-07-12 5:07 ` David Gibson
2016-07-12 8:11 ` Igor Mammedov
2016-07-13 1:39 ` David Gibson [this message]
2016-07-12 7:06 ` Bharata B Rao
2016-07-12 8:21 ` Igor Mammedov
2016-07-12 11:08 ` [Qemu-devel] [PATCH v2 1/2] cpu: add migration_id to allow board to provide " Igor Mammedov
2016-07-12 11:08 ` [Qemu-devel] [PATCH v2 2/2] pc: fix migration failure after cpu hot-unplung Igor Mammedov
2016-07-11 7:58 ` [Qemu-devel] [RFC PATCH v2 2/5] cpu: Introduce CPUState::stable_cpu_id Igor Mammedov
2016-07-12 5:09 ` David Gibson
2016-07-07 14:50 ` [Qemu-devel] [RFC PATCH v2 3/5] spapr: Set stable_cpu_id for threads of CPU cores Bharata B Rao
2016-07-07 16:11 ` Greg Kurz
2016-07-08 5:25 ` David Gibson
2016-07-08 7:46 ` Greg Kurz
2016-07-08 7:59 ` David Gibson
2016-07-08 15:24 ` Greg Kurz
2016-07-11 3:23 ` David Gibson
2016-07-08 5:24 ` David Gibson
2016-07-08 6:41 ` Bharata B Rao
2016-07-08 7:39 ` David Gibson
2016-07-08 10:59 ` Igor Mammedov
2016-07-11 3:12 ` Bharata B Rao
2016-07-11 3:26 ` David Gibson
2016-07-11 8:15 ` Igor Mammedov
2016-07-12 4:41 ` David Gibson
2016-07-07 14:50 ` [Qemu-devel] [RFC PATCH v2 4/5] xics: Use stable_cpu_id instead of cpu_index in XICS code Bharata B Rao
2016-07-08 5:32 ` David Gibson
2016-07-07 14:50 ` [Qemu-devel] [RFC PATCH v2 5/5] spapr: Enable the use of stable_cpu_id from pseries-2.7 onwards Bharata B Rao
2016-07-07 16:04 ` [Qemu-devel] [RFC PATCH v2 0/5] sPAPR: Fix migration when CPUs are removed in random order Greg Kurz
2016-07-08 5:34 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160713013916.GB14615@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=bharata@linux.vnet.ibm.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).