[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu |
Date: |
Thu, 25 Apr 2013 16:48:09 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
Am 23.04.2013 10:29, schrieb Igor Mammedov:
> wrapper will help to remove open-coded loops
>
> Signed-off-by: Michael S. Tsirkin <address@hidden>
> Signed-off-by: Igor Mammedov <address@hidden>
> ---
> 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
>
> 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)
>
> static void tcg_exec_all(void);
>
> +static void signal_cpu_creation(CPUState *cpu, void *data)
> +{
> + cpu->thread_id = qemu_get_thread_id();
> + cpu->created = true;
> +}
> +
> static void *qemu_tcg_cpu_thread_fn(void *arg)
> {
> CPUState *cpu = 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);
>
> - /* signal CPU creation */
> qemu_mutex_lock(&qemu_global_mutex);
> - for (env = first_cpu; env != NULL; env = env->next_cpu) {
> - cpu = ENV_GET_CPU(env);
> - cpu->thread_id = qemu_get_thread_id();
> - cpu->created = true;
> - }
> + qemu_for_each_cpu(signal_cpu_creation, NULL);
> qemu_cond_signal(&qemu_cpu_cond);
>
> /* 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 = qemu_get_thread_id();
cpu->created = 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;
> }
>
> +void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *data)
> +{
> + CPUArchState *env = first_cpu;
> +
> + while (env) {
> + func(ENV_GET_CPU(env), data);
> + env = env->next_cpu;
> + }
> +}
> +
> void cpu_exec_init(CPUArchState *env)
> {
> CPUState *cpu = 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);
>
> +/** 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 address@hidden value of the CPU to obtain.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- Re: [Qemu-devel] [PATCH 02/21] cpu: call cpu_synchronize_post_init() from CPUClass.realize() if hotplugged, (continued)
[Qemu-devel] [PATCH 07/21] cpu: introduce get_arch_id() method and override it for target-i386, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 03/21] introduce cpu_resume(), for single CPU, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 09/21] cpu: add helper cpu_exists(), to check if CPU with specified id exists, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 12/21] target-i386: introduce ICC bus/device/bridge, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu, Igor Mammedov, 2013/04/23
- Re: [Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu,
Andreas Färber <=
[Qemu-devel] [PATCH 13/21] target-i386: cpu: attach ICC bus to CPU on its creation, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 11/21] target-i386: introduce apic-id property, Igor Mammedov, 2013/04/23
[Qemu-devel] [PATCH 10/21] acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest, Igor Mammedov, 2013/04/23
Re: [Qemu-devel] [PATCH 10/21] acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest, Juan Quintela, 2013/04/23
Re: [Qemu-devel] [PATCH 10/21] acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest, Juan Quintela, 2013/04/23