From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVNTA-0005DW-Nv for qemu-devel@nongnu.org; Thu, 25 Apr 2013 10:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVNT4-0006vf-FS for qemu-devel@nongnu.org; Thu, 25 Apr 2013 10:48:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38865 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVNT4-0006vM-5x for qemu-devel@nongnu.org; Thu, 25 Apr 2013 10:48:14 -0400 Message-ID: <51794229.3040503@suse.de> Date: Thu, 25 Apr 2013 16:48:09 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1366705795-24732-1-git-send-email-imammedo@redhat.com> <1366705795-24732-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1366705795-24732-9-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, ehabkost@redhat.com, gleb@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, quintela@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, blauwirbel@gmail.com, anthony.perard@citrix.com, alex.williamson@redhat.com, kraxel@redhat.com, yang.z.zhang@intel.com, pbonzini@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, rth@twiddle.net Am 23.04.2013 10:29, schrieb Igor Mammedov: > wrapper will help to remove open-coded loops >=20 > Signed-off-by: Michael S. Tsirkin > Signed-off-by: Igor Mammedov > --- > Note: > Will be used by ACPI table generation and cpu_exists() > --- > cpus.c | 13 +++++++------ > exec.c | 10 ++++++++++ > include/qom/cpu.h | 8 ++++++++ > 3 files changed, 25 insertions(+), 6 deletions(-) Thanks, split in two and applied to qom-cpu (with changes below): https://github.com/afaerber/qemu-cpu/commits/qom-cpu >=20 > diff --git a/cpus.c b/cpus.c > index 1d88761..5850151 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -812,6 +812,12 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > =20 > static void tcg_exec_all(void); > =20 > +static void signal_cpu_creation(CPUState *cpu, void *data) > +{ > + cpu->thread_id =3D qemu_get_thread_id(); > + cpu->created =3D true; > +} > + > static void *qemu_tcg_cpu_thread_fn(void *arg) > { > CPUState *cpu =3D arg; > @@ -820,13 +826,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > qemu_tcg_init_cpu_signals(); > qemu_thread_get_self(cpu->thread); > =20 > - /* signal CPU creation */ > qemu_mutex_lock(&qemu_global_mutex); > - for (env =3D first_cpu; env !=3D NULL; env =3D env->next_cpu) { > - cpu =3D ENV_GET_CPU(env); > - cpu->thread_id =3D qemu_get_thread_id(); > - cpu->created =3D true; > - } > + qemu_for_each_cpu(signal_cpu_creation, NULL); > qemu_cond_signal(&qemu_cpu_cond); > =20 > /* wait for initial kick-off after machine start */ We figured on IRC that TCG was not reflected in the function name, so I changed as follows: diff --git a/cpus.c b/cpus.c index 5850151..2e7bbad 100644 --- a/cpus.c +++ b/cpus.c @@ -812,7 +812,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) static void tcg_exec_all(void); -static void signal_cpu_creation(CPUState *cpu, void *data) +static void signal_tcg_cpu_creation(CPUState *cpu, void *data) { cpu->thread_id =3D qemu_get_thread_id(); cpu->created =3D true; @@ -827,7 +827,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) qemu_thread_get_self(cpu->thread); qemu_mutex_lock(&qemu_global_mutex); - qemu_for_each_cpu(signal_cpu_creation, NULL); + qemu_for_each_cpu(signal_tcg_cpu_creation, NULL); qemu_cond_signal(&qemu_cpu_cond); /* wait for initial kick-off after machine start */ > diff --git a/exec.c b/exec.c > index fa1e0c3..19725db 100644 > --- a/exec.c > +++ b/exec.c > @@ -265,6 +265,16 @@ CPUState *qemu_get_cpu(int index) > return env ? cpu : NULL; > } > =20 > +void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *= data) > +{ > + CPUArchState *env =3D first_cpu; > + > + while (env) { > + func(ENV_GET_CPU(env), data); > + 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 639b436..d4a21f4 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -215,6 +215,14 @@ bool cpu_is_stopped(CPUState *cpu); > */ > void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data); > =20 > +/** qemu_for_each_cpu: Moved to next line. > + * @func: The function to be executed. > + * @data: Data to pass to the function. > + * > + * Executes @func on all CPUs Changed to "for each CPU" to distinguish from run_on_cpu(). > + */ > +void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *= data); > + > /** > * qemu_get_cpu: > * @index: The CPUState@cpu_index value of the CPU to obtain. Andreas --=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