All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 3/4] exec: Notify cpu_register_map_client caller if the bounce buffer is available
Date: Fri, 13 Mar 2015 09:12:25 +0100	[thread overview]
Message-ID: <55029BE9.2050700@redhat.com> (raw)
In-Reply-To: <1426210723-16735-4-git-send-email-famz@redhat.com>



On 13/03/2015 02:38, Fam Zheng wrote:
> The caller's workflow is like
> 
>     if (!address_space_map()) {
>         ...
>         cpu_register_map_client();
>     }
> 
> If bounce buffer became available after address_space_map() but before
> cpu_register_map_client(), the caller could miss it and has to wait for the
> next bounce buffer uesr to release, which may never happen in the worse case.
> 
> Just notify the caller with the passed callback in cpu_register_map_client().
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  exec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/exec.c b/exec.c
> index 93ccd5a..82781e4 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2502,6 +2502,9 @@ void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque))
>      client->opaque = opaque;
>      client->callback = callback;
>      QSLIST_INSERT_HEAD_ATOMIC(&map_client_list, client, link);
> +    if (!atomic_read(&bounce.in_use)) {
> +        callback(opaque);

This should call cpu_notify_map_clients instead, otherwise you get two
calls.

Paolo

> +    }
>      return client;
>  }
>  
> 

  reply	other threads:[~2015-03-13  8:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13  1:38 [Qemu-devel] [PATCH v2 0/4] exec: Make bounce buffer thread safe Fam Zheng
2015-03-13  1:38 ` [Qemu-devel] [PATCH v2 1/4] exec: Atomic access to bounce buffer Fam Zheng
2015-03-13  8:09   ` Paolo Bonzini
2015-03-13  8:16     ` Fam Zheng
2015-03-13  8:32       ` Paolo Bonzini
2015-03-13  8:38         ` Fam Zheng
2015-03-13  8:41         ` Paolo Bonzini
2015-03-13  1:38 ` [Qemu-devel] [PATCH v2 2/4] exec: Atomic access to map_client_list Fam Zheng
2015-03-13  8:11   ` Paolo Bonzini
2015-03-13  1:38 ` [Qemu-devel] [PATCH v2 3/4] exec: Notify cpu_register_map_client caller if the bounce buffer is available Fam Zheng
2015-03-13  8:12   ` Paolo Bonzini [this message]
2015-03-13  1:38 ` [Qemu-devel] [PATCH v2 4/4] dma-helpers: Move reschedule_dma BH to blk's AioContext Fam Zheng
2015-03-13  8:13   ` Paolo Bonzini
2015-03-13  8:58     ` Fam Zheng
2015-03-13 10:48       ` Paolo Bonzini
2015-03-13 12:33         ` Paolo Bonzini

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=55029BE9.2050700@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=famz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.