From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKIQV-0001No-KG for qemu-devel@nongnu.org; Tue, 05 Jul 2016 00:57:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKIQR-000868-Sj for qemu-devel@nongnu.org; Tue, 05 Jul 2016 00:57:38 -0400 Date: Tue, 5 Jul 2016 14:56:53 +1000 From: David Gibson Message-ID: <20160705045653.GF2251@voom.fritz.box> References: <1467693772-7391-1-git-send-email-bharata@linux.vnet.ibm.com> <1467693772-7391-3-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wtjvnLv0o8UUzur2" Content-Disposition: inline In-Reply-To: <1467693772-7391-3-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0 2/5] cpu: Optionally use arch_id instead of cpu_index in cpu vmstate_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, imammedo@redhat.com, groug@kaod.org, nikunj@linux.vnet.ibm.com, pbonzini@redhat.com --wtjvnLv0o8UUzur2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 05, 2016 at 10:12:49AM +0530, Bharata B Rao wrote: > Introduce CPUState.prefer_arch_id_over_cpu_index and > MachineClass.prefer_arch_id_over_cpu_index that allow target > machines to optionally switch to using arch_id instead of cpu_index > as instance_id in vmstate_register(). This will help allow successful > migration in cases where holes are introduced in cpu_index range > after CPU hot removals. >=20 > Whether to use arch_id or cpu_index is based on machine type version > and hence added MachineClass.prefer_arch_id_over_cpu_index. However the > enforcement is via and during CPU creation and hence added > CPUState.prefer_arch_id_over_cpu_index. So it becomes a two step > process for the target to enable the use of arch_id: >=20 > 1. Set MachineClass.prefer_arch_id_over_cpu_index. > 2. Ensure CPUState.prefer_arch_id_over_cpu_index is set for all CPUs > based on 1. above. >=20 > Suggested-by: Igor Mammedov > Signed-off-by: Bharata B Rao How is migration between a version with this flag and a version without this flag handled? > --- > exec.c | 10 ++++++++-- > include/hw/boards.h | 1 + > include/qom/cpu.h | 4 ++++ > 3 files changed, 13 insertions(+), 2 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 8ce8e90..7cc1d06 100644 > --- a/exec.c > +++ b/exec.c > @@ -616,15 +616,21 @@ static void cpu_release_index(CPUState *cpu) > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > } > =20 > +/* > + * TODO: cpu_index and instance_id are of type int while .get_arch_id()is > + * of type int64_t. What is the consequence of changing instance_id to i= nt64_t ? > + */ > static void cpu_vmstate_register(CPUState *cpu) > { > CPUClass *cc =3D CPU_GET_CLASS(cpu); > + int instance_id =3D cpu->prefer_arch_id_over_cpu_index ? > + cc->get_arch_id(cpu) : cpu->cpu_index; > =20 > if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > - vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); > + vmstate_register(NULL, instance_id, &vmstate_cpu_common, cpu); > } > if (cc->vmsd !=3D NULL) { > - vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); > + vmstate_register(NULL, instance_id, cc->vmsd, cpu); > } > } > =20 > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 3ed6155..decabba 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -123,6 +123,7 @@ struct MachineClass { > ram_addr_t default_ram_size; > bool option_rom_has_mr; > bool rom_file_has_mr; > + bool prefer_arch_id_over_cpu_index; > =20 > HotplugHandler *(*get_hotplug_handler)(MachineState *machine, > DeviceState *dev); > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 32f3af3..1f1706e 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -273,6 +273,9 @@ struct qemu_work_item { > * @kvm_fd: vCPU file descriptor for KVM. > * @work_mutex: Lock to prevent multiple access to queued_work_*. > * @queued_work_first: First asynchronous work pending. > + * @prefer_arch_id_over_cpu_index: Set to enforce the use of > + * CPUClass.get_arch_id() over cpu_index during vmstate registra= tion > + * and any other uses by target machine where arch_id is preferr= ed. > * > * State of one CPU core or thread. > */ > @@ -360,6 +363,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; > + bool prefer_arch_id_over_cpu_index; > }; > =20 > QTAILQ_HEAD(CPUTailQ, CPUState); --=20 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 --wtjvnLv0o8UUzur2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXez4VAAoJEGw4ysog2bOS15EP/0391+ac9aMD0qg34k+a4+7S K7RWoCZRPIdn78S86Y9uKk/HmjEAQ+766al1jtbFz/WWJxZ+YtIVOowLWNDGgcR3 imj+X4RDVaskiUqYCMM2wFWhoc+E8fq7oKX/CNZCWZpmZt6fe68W6i0al33gzckJ DDwfEhstwCcWnJteGIwMnir/f+SD8kbbpR8YtBHqXRbYSPEM6/tLIRxYXwchZmPN BJ81GCP/ecaleG4v3NbcjNGzawKy/493+UzI6LLWnt9YXIBOlRrSmtXRAZkvaetr qcCj2nM4r1G4moKLaKGJJPFM1D3tA3VarQe57Bms2xEhin6vx8qmKDbUKWlA9cxE nNCh+gKXtGdxDICiF+ZGb00ygi1Wpe2dz5Nr3k3r6k9Q20rZLPaAiDm0GiuYjU2O aAW1GFWqa2sAYrqIUWg92izbOla2pCznrN5n24bdRmnHKyYvyevf0yfqjjRMG5+i T2X+ZHRL9oJ7AY9k7uUqxaKJdqbrUYWbqKLcDddTfOrJchBLDdM8odPsBu1XlLW0 igje/jS40pDPnyEiRd7ED+YmuBahiXLan5KGZ9Ra8w+UzzbL82eI0r9yI5qCRDg/ LlgegVFa6HrmACVmdddUY6qc9lQkLIsKacmz1oK03+GEuloj9V/2D+MbzpUqh6JQ tMca/uXtoreU5rTLPE0A =8ClZ -----END PGP SIGNATURE----- --wtjvnLv0o8UUzur2--