From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWKhv-000479-7U for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWKhp-0006sk-Rk for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:12:35 -0400 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]:44090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWKhp-0006sf-L3 for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:12:29 -0400 Received: by wesp10 with SMTP id p10so21524397wes.11 for ; Fri, 13 Mar 2015 01:12:29 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <55029BE9.2050700@redhat.com> Date: Fri, 13 Mar 2015 09:12:25 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1426210723-16735-1-git-send-email-famz@redhat.com> <1426210723-16735-4-git-send-email-famz@redhat.com> In-Reply-To: <1426210723-16735-4-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/4] exec: Notify cpu_register_map_client caller if the bounce buffer is available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org 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 > --- > 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; > } > >