From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQR3M-0006s2-KD for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQR3L-0003tC-87 for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:08 -0400 Date: Fri, 22 Jul 2016 11:35:16 +1000 From: David Gibson Message-ID: <20160722013516.GD15941@voom.fritz.box> References: <1469116479-233280-1-git-send-email-imammedo@redhat.com> <1469116479-233280-4-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AkbCVLjbJ9qUtAXD" Content-Disposition: inline In-Reply-To: <1469116479-233280-4-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/8] exec: set cpu_index only if it's been explictly set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Alexander Graf , Riku Voipio , Bharata B Rao , qemu-ppc@nongnu.org --AkbCVLjbJ9qUtAXD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 21, 2016 at 05:54:34PM +0200, Igor Mammedov wrote: > it keeps the legacy behavior for all users that doesn't care > about stable cpu_index value, but would allow boards that > would support device_add/device_del to set stable cpu_index > that won't depend on order in which cpus are created/destroyed. >=20 > While at that simplify cpu_get_free_index() as cpu_index > generated by USER_ONLY and softmmu variants is the same > since none of the users support cpu-remove so far except > of not yet released spapr/x86 device_add/del. which > will be altered in follow up patches to provide stable > cpu_index. >=20 > Signed-off-by: Igor Mammedov It looks like the 1-line description needs a "not" in it somewhere, but otherwise: Reviewed-by: David Gibson > --- > include/qom/cpu.h | 2 ++ > exec.c | 44 ++++++-------------------------------------- > qom/cpu.c | 2 +- > 3 files changed, 9 insertions(+), 39 deletions(-) >=20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index cbcd64c..ce0c406 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -883,4 +883,6 @@ extern const struct VMStateDescription vmstate_cpu_co= mmon; > .offset =3D 0, = \ > } > =20 > +#define UNASSIGNED_CPU_INDEX -1 > + > #endif > diff --git a/exec.c b/exec.c > index 8c5da32..8e8416b 100644 > --- a/exec.c > +++ b/exec.c > @@ -598,30 +598,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, i= nt asidx) > } > #endif > =20 > -#ifndef CONFIG_USER_ONLY > -static DECLARE_BITMAP(cpu_index_map, MAX_CPUMASK_BITS); > - > -static int cpu_get_free_index(Error **errp) > -{ > - int cpu =3D find_first_zero_bit(cpu_index_map, MAX_CPUMASK_BITS); > - > - if (cpu >=3D MAX_CPUMASK_BITS) { > - error_setg(errp, "Trying to use more CPUs than max of %d", > - MAX_CPUMASK_BITS); > - return -1; > - } > - > - bitmap_set(cpu_index_map, cpu, 1); > - return cpu; > -} > - > -static void cpu_release_index(CPUState *cpu) > -{ > - bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > -} > -#else > - > -static int cpu_get_free_index(Error **errp) > +static int cpu_get_free_index(void) > { > CPUState *some_cpu; > int cpu_index =3D 0; > @@ -632,12 +609,6 @@ static int cpu_get_free_index(Error **errp) > return cpu_index; > } > =20 > -static void cpu_release_index(CPUState *cpu) > -{ > - return; > -} > -#endif > - > void cpu_exec_exit(CPUState *cpu) > { > CPUClass *cc =3D CPU_GET_CLASS(cpu); > @@ -650,8 +621,7 @@ void cpu_exec_exit(CPUState *cpu) > } > =20 > QTAILQ_REMOVE(&cpus, cpu, node); > - cpu_release_index(cpu); > - cpu->cpu_index =3D -1; > + cpu->cpu_index =3D UNASSIGNED_CPU_INDEX; > cpu_list_unlock(); > =20 > if (cc->vmsd !=3D NULL) { > @@ -665,7 +635,7 @@ void cpu_exec_exit(CPUState *cpu) > void cpu_exec_init(CPUState *cpu, Error **errp) > { > CPUClass *cc ATTRIBUTE_UNUSED =3D CPU_GET_CLASS(cpu); > - Error *local_err =3D NULL; > + Error *local_err ATTRIBUTE_UNUSED =3D NULL; > =20 > cpu->as =3D NULL; > cpu->num_ases =3D 0; > @@ -689,11 +659,9 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > #endif > =20 > cpu_list_lock(); > - cpu->cpu_index =3D cpu_get_free_index(&local_err); > - if (local_err) { > - error_propagate(errp, local_err); > - cpu_list_unlock(); > - return; > + if (cpu->cpu_index =3D=3D UNASSIGNED_CPU_INDEX) { > + cpu->cpu_index =3D cpu_get_free_index(); > + assert(cpu->cpu_index !=3D UNASSIGNED_CPU_INDEX); > } > QTAILQ_INSERT_TAIL(&cpus, cpu, node); > cpu_list_unlock(); > diff --git a/qom/cpu.c b/qom/cpu.c > index 42b5631..2553247 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -340,7 +340,7 @@ static void cpu_common_initfn(Object *obj) > CPUState *cpu =3D CPU(obj); > CPUClass *cc =3D CPU_GET_CLASS(obj); > =20 > - cpu->cpu_index =3D -1; > + cpu->cpu_index =3D UNASSIGNED_CPU_INDEX; > cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_regs; > qemu_mutex_init(&cpu->work_mutex); > QTAILQ_INIT(&cpu->breakpoints); --=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 --AkbCVLjbJ9qUtAXD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkXhUAAoJEGw4ysog2bOS4hYQAKfs/+5yx7WKDSPzNYJfo80X hvSYBBonSlVlv2ltEZgqlBlfmNeNi9Nh+yBr1PAA/7XvISL2aghoCaGySJ39itb/ oA4L0u7g04FD3whul4GOLrrSLhoEHN7UQGbh4NTohaU2kBN3BbtDtAfeQ1m6C40S VcNOTsJTjRaHIAnAT3IypQdnjLar7up8EIBow5C65dBzNLHoC4aw29edx0cATUIl hk1gFiqjLb89RrE3ybgFxQBtYat9BgtxoZCHaC4n8sqm22OjMVBpuZ/TvpWod/S2 pCwtmdJznBeLEMcGod7LFGtI9pm1JHrSKJRwbppuikuJ7HoL7qcxlcPYNa7XdLYf Z5gpkdjlQRRKmtdOoVi2gIswOghlBLt8ODTVyNAmeuat+Rs/9TIHFgvzFc7SfXe5 GRnJYpYop0jgtKnfTg/76JWkubqIMHpjWS+SbFz73C1UK6+HKgM28rSz9Ofn2VuL e2ros6zhKnZucTNGXcjI1roykajXW2lWcunTGw0MwK6Rzr7AwVvl+rydInhxrGll bfDIR41XQqQSf/Ywx4gWJGEqnr4mJJBd9xlZDCpCT2EG5vhNGURtz35K+DlKLnzQ gy7x3CFDA8vhvWUCng5Q9aD4UgYbIuIZyryX+OOgsOKubCBwDZ2o1to4mKgktilc Pn79ebe+QajqqbL3jFwu =CD6E -----END PGP SIGNATURE----- --AkbCVLjbJ9qUtAXD--