Received: from eggs.gnu.org ([2001:4830:134:3::10]:55982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKIQV-0001Np-KN 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-000862-LP for qemu-devel@nongnu.org; Tue, 05 Jul 2016 00:57:38 -0400 Date: Tue, 5 Jul 2016 14:56:13 +1000 From: David Gibson Message-ID: <20160705045613.GE2251@voom.fritz.box> References: <1467693772-7391-1-git-send-email-bharata@linux.vnet.ibm.com> <1467693772-7391-2-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tVmo9FyGdCe4F4YN" Content-Disposition: inline In-Reply-To: <1467693772-7391-2-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0 1/5] cpu: Factor out cpu vmstate_[un]register into separate routines 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 --tVmo9FyGdCe4F4YN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 05, 2016 at 10:12:48AM +0530, Bharata B Rao wrote: > Consolidates cpu vmstate_[un]register calls into separate routines. > No functionality change except that vmstate_unregister calls are > now done under !CONFIG_USER_ONLY to match with vmstate_register calls. >=20 > Signed-off-by: Bharata B Rao Reviewed-by: David Gibson > --- > exec.c | 47 ++++++++++++++++++++++++++++------------------- > 1 file changed, 28 insertions(+), 19 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 0122ef7..8ce8e90 100644 > --- a/exec.c > +++ b/exec.c > @@ -594,9 +594,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, in= t asidx) > /* Return the AddressSpace corresponding to the specified index */ > return cpu->cpu_ases[asidx].as; > } > -#endif > =20 > -#ifndef CONFIG_USER_ONLY > static DECLARE_BITMAP(cpu_index_map, MAX_CPUMASK_BITS); > =20 > static int cpu_get_free_index(Error **errp) > @@ -617,6 +615,31 @@ static void cpu_release_index(CPUState *cpu) > { > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > } > + > +static void cpu_vmstate_register(CPUState *cpu) > +{ > + CPUClass *cc =3D CPU_GET_CLASS(cpu); > + > + if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > + vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); > + } > + if (cc->vmsd !=3D NULL) { > + vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); > + } > +} > + > +static void cpu_vmstate_unregister(CPUState *cpu) > +{ > + CPUClass *cc =3D CPU_GET_CLASS(cpu); > + > + if (cc->vmsd !=3D NULL) { > + vmstate_unregister(NULL, cc->vmsd, cpu); > + } > + if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > + vmstate_unregister(NULL, &vmstate_cpu_common, cpu); > + } > +} > + Given you're factoring this out, would it make sense to defined no-op versions for CONFIG_USER_ONLY, to reduce the amount of ifdefs at the call site? > #else > =20 > static int cpu_get_free_index(Error **errp) > @@ -638,8 +661,6 @@ static void cpu_release_index(CPUState *cpu) > =20 > void cpu_exec_exit(CPUState *cpu) > { > - CPUClass *cc =3D CPU_GET_CLASS(cpu); > - > #if defined(CONFIG_USER_ONLY) > cpu_list_lock(); > #endif > @@ -656,19 +677,13 @@ void cpu_exec_exit(CPUState *cpu) > cpu->cpu_index =3D -1; > #if defined(CONFIG_USER_ONLY) > cpu_list_unlock(); > +#else > + cpu_vmstate_unregister(cpu); > #endif > - > - if (cc->vmsd !=3D NULL) { > - vmstate_unregister(NULL, cc->vmsd, cpu); > - } > - if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > - vmstate_unregister(NULL, &vmstate_cpu_common, cpu); > - } > } > =20 > void cpu_exec_init(CPUState *cpu, Error **errp) > { > - CPUClass *cc =3D CPU_GET_CLASS(cpu); > Error *local_err =3D NULL; > =20 > cpu->as =3D NULL; > @@ -705,15 +720,9 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > } > QTAILQ_INSERT_TAIL(&cpus, cpu, node); > #if defined(CONFIG_USER_ONLY) > - (void) cc; > cpu_list_unlock(); > #else > - if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > - vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); > - } > - if (cc->vmsd !=3D NULL) { > - vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); > - } > + cpu_vmstate_register(cpu); > #endif > } > =20 --=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 --tVmo9FyGdCe4F4YN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXez3tAAoJEGw4ysog2bOS1TkP/j7Y+DfIAvaMh+Oe/3qgxLbQ x3MxgQln8574qcQrXoi0DuX/Pj8Z2TNlY4JYCARFMgl29mgxK6aNyw0Tg1iBLTNj LyX+rAhU7al+dEgc0CsgjzoqNE3OwVV6ZSNsWiAmHhhJr4qyawEqKu5U1OKuhET1 EC2GtIBdv6kjeyALZVnsQo97FJLn33QHuziyZz0smYtRJh5ZjddkUGATKmJRsPh9 MTX4Pyv7j+c1ntlrBUbY3ueKEPpChLuZ+QKMXHhh3vuod518J23k4P4S4x7SYsi/ tp+2KX/FNTffzdhM6V6IYhKf/DsybY5rVQD130ckJnPxzS9IodP+x6ULWXI4XcsP XgNixaJf4MNhndbkYZrNpj45l2G7N/Sfnqp0fikPQXkCqMJt8jHqEabiWryuLfzb MwC2oy3U8FaPW6gN6T1QcVCyp8WigGLMLzZti1jshbOytB1kEiYgqr/YZ0ehMjUb 3e3dK7qml8rewU5TrV0uwpQnCOcXjM9E5SiXXXA0X0USYZ3MAtqZicVhLQ5yG5gE rLJOPvwHYKVLVildND31SZ8SRmwLF53tFcmn2btCRJP95yo5nCLm6f819gTzVE28 1p+a5EtmFeYXEGJotewBIa1HWJLjhy60Qp5JdUv1OcXWKsPj/x5Uy8Y65JgLED8C 58ef6nFFVAdQFLt5Uxup =KMJ0 -----END PGP SIGNATURE----- --tVmo9FyGdCe4F4YN--