From: Orit Wasserman <owasserm@redhat.com>
To: Chegu Vinod <chegu_vinod@hp.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org,
anthony@codemonkey.ws, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH v8 1/3] Introduce async_run_on_cpu()
Date: Sat, 13 Jul 2013 12:15:26 +0300 [thread overview]
Message-ID: <51E11AAE.9030805@redhat.com> (raw)
In-Reply-To: <1372067382-141082-2-git-send-email-chegu_vinod@hp.com>
On 06/24/2013 12:49 PM, Chegu Vinod wrote:
> Introduce an asynchronous version of run_on_cpu() i.e. the caller
> doesn't have to block till the call back routine finishes execution
> on the target vcpu.
>
> Signed-off-by: Chegu Vinod <chegu_vinod@hp.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> cpus.c | 29 +++++++++++++++++++++++++++++
> include/qemu-common.h | 1 +
> include/qom/cpu.h | 10 ++++++++++
> 3 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index c8bc8ad..c7c90d0 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -653,6 +653,7 @@ void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
>
> wi.func = func;
> wi.data = data;
> + wi.free = false;
> if (cpu->queued_work_first == NULL) {
> cpu->queued_work_first = &wi;
> } else {
> @@ -671,6 +672,31 @@ void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
> }
> }
>
> +void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
> +{
> + struct qemu_work_item *wi;
> +
> + if (qemu_cpu_is_self(cpu)) {
> + func(data);
> + return;
> + }
> +
> + wi = g_malloc0(sizeof(struct qemu_work_item));
> + wi->func = func;
> + wi->data = data;
> + wi->free = true;
> + if (cpu->queued_work_first == NULL) {
> + cpu->queued_work_first = wi;
> + } else {
> + cpu->queued_work_last->next = wi;
> + }
> + cpu->queued_work_last = wi;
> + wi->next = NULL;
> + wi->done = false;
> +
> + qemu_cpu_kick(cpu);
> +}
> +
> static void flush_queued_work(CPUState *cpu)
> {
> struct qemu_work_item *wi;
> @@ -683,6 +709,9 @@ static void flush_queued_work(CPUState *cpu)
> cpu->queued_work_first = wi->next;
> wi->func(wi->data);
> wi->done = true;
> + if (wi->free) {
> + g_free(wi);
> + }
> }
> cpu->queued_work_last = NULL;
> qemu_cond_broadcast(&qemu_work_cond);
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 3c91375..9834dcb 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -291,6 +291,7 @@ struct qemu_work_item {
> void (*func)(void *data);
> void *data;
> int done;
> + bool free;
> };
>
> #ifdef CONFIG_USER_ONLY
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index a5bb515..b555c22 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -288,6 +288,16 @@ bool cpu_is_stopped(CPUState *cpu);
> void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
>
> /**
> + * async_run_on_cpu:
> + * @cpu: The vCPU to run on.
> + * @func: The function to be executed.
> + * @data: Data to pass to the function.
> + *
> + * Schedules the function @func for execution on the vCPU @cpu asynchronously.
> + */
> +void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
> +
> +/**
> * qemu_for_each_cpu:
> * @func: The function to be executed.
> * @data: Data to pass to the function.
>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
next prev parent reply other threads:[~2013-07-13 9:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 9:49 [Qemu-devel] [PATCH v8 0/3] Throttle-down guest to help with live migration convergence Chegu Vinod
2013-06-24 9:49 ` [Qemu-devel] [PATCH v8 1/3] Introduce async_run_on_cpu() Chegu Vinod
2013-07-12 11:54 ` Juan Quintela
2013-07-13 9:15 ` Orit Wasserman [this message]
2013-06-24 9:49 ` [Qemu-devel] [PATCH v8 2/3] Add 'auto-converge' migration capability Chegu Vinod
2013-07-12 11:56 ` Juan Quintela
2013-07-13 9:17 ` Orit Wasserman
2013-07-18 6:24 ` [Qemu-devel] [PATCH v8 0/3] Throttle-down guest to help with live migration convergence Peter Lieven
2013-07-18 17:42 ` Vinod, Chegu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51E11AAE.9030805@redhat.com \
--to=owasserm@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=chegu_vinod@hp.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).