From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUEjZ-00080j-KV for qemu-devel@nongnu.org; Mon, 22 Apr 2013 07:16:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUEjX-0004lC-DL for qemu-devel@nongnu.org; Mon, 22 Apr 2013 07:16:33 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51641 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUEjX-0004d9-3V for qemu-devel@nongnu.org; Mon, 22 Apr 2013 07:16:31 -0400 Message-ID: <51751BE0.20407@suse.de> Date: Mon, 22 Apr 2013 13:15:44 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1366063976-4909-1-git-send-email-imammedo@redhat.com> <1366063976-4909-9-git-send-email-imammedo@redhat.com> <20130422102812.GD3808@redhat.com> In-Reply-To: <20130422102812.GD3808@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 08/16] cpu: add helper cpu_exists(), to check if CPU with specified id exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, jfrei@linux.vnet.ibm.com, pbonzini@redhat.com, yang.z.zhang@intel.com, Igor Mammedov , lig.fnst@cn.fujitsu.com, rth@twiddle.net Am 22.04.2013 12:28, schrieb Michael S. Tsirkin: > On Tue, Apr 16, 2013 at 12:12:48AM +0200, Igor Mammedov wrote: >> ... it should be used only on slow path since it does recursive search >> on /machine QOM tree for objects of TYPE_CPU >> >> Signed-off-by: Igor Mammedov >> Reviewed-by: Paolo Bonzini >=20 > I would prefer qemu_for_each_cpu, that is also useful for ACPI. And do > we need to scan all QOM? This will take a while to repeat if there are > many devices. > How about the below? You can add a wrapper that sets > a bit if CPU exists. I really like it! Didn't get around to writing such a helper myself yet - this will allow us to drop quite some CPUArchState usages in the tree. If you can submit this as a proper patch (git-send-email, with a gtk-doc comment, is the spacing intentional?) along with a trivial loop -> helper conversion as proof of concept I'll queue it immediately. Toda, Andreas > commit 4ff1332ff56069574f450bb44819156bd91bd105 > Author: Michael S. Tsirkin > Date: Sun Apr 21 15:44:47 2013 +0300 >=20 > exec: add qemu_for_each_cpu > =20 > Will be used by ACPI table generation. > =20 > Signed-off-by: Michael S. Tsirkin >=20 > diff --git a/exec.c b/exec.c > index fa1e0c3..2b44cbe 100644 > --- a/exec.c > +++ b/exec.c > @@ -265,6 +265,19 @@ CPUState *qemu_get_cpu(int index) > return env ? cpu : NULL; > } > =20 > +void qemu_for_each_cpu( void (*func)( CPUState *c, void *arg), void *a= rg) > +{ > + CPUArchState *env =3D first_cpu; > + CPUState *cpu; > + > + while (env) { > + cpu =3D ENV_GET_CPU(env); > + func(cpu, arg); > + env =3D env->next_cpu; > + } > +} > + > + > void cpu_exec_init(CPUArchState *env) > { > CPUState *cpu =3D ENV_GET_CPU(env); > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 3664a1b..db857e3 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -223,6 +223,8 @@ void run_on_cpu(CPUState *cpu, void (*func)(void *d= ata), void *data); > */ > CPUState *qemu_get_cpu(int index); > =20 > +void qemu_for_each_cpu( void (*func)( CPUState *c, void *arg), void *a= rg); > + > #ifndef CONFIG_USER_ONLY > =20 > typedef void (*CPUInterruptHandler)(CPUState *, int); >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg