From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UovTy-0004wA-PL for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UovTx-00017J-EG for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:57:58 -0400 Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:61606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UovTx-00017B-7W for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:57:57 -0400 Received: by mail-we0-f181.google.com with SMTP id p58so3402229wes.12 for ; Tue, 18 Jun 2013 05:57:56 -0700 (PDT) Date: Tue, 18 Jun 2013 14:57:53 +0200 From: Stefan Hajnoczi Message-ID: <20130618125753.GL7649@stefanha-thinkpad.redhat.com> References: <1371114186-8854-1-git-send-email-qemulist@gmail.com> <1371114186-8854-6-git-send-email-qemulist@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1371114186-8854-6-git-send-email-qemulist@gmail.com> Subject: Re: [Qemu-devel] [PATCH v2 5/6] net: defer nested call to BH List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , mdroth On Thu, Jun 13, 2013 at 05:03:05PM +0800, Liu Ping Fan wrote: > From: Liu Ping Fan > > Nested call caused by ->receive() will raise issue like deadlock, > so postphone it to BH. > > Signed-off-by: Liu Ping Fan > --- > net/queue.c | 40 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 38 insertions(+), 2 deletions(-) Does this patch belong before the netqueue lock patch? The commit history should be bisectable without temporary failures/deadlocks. > diff --git a/net/queue.c b/net/queue.c > index 58222b0..9c343ab 100644 > --- a/net/queue.c > +++ b/net/queue.c > @@ -24,6 +24,8 @@ > #include "net/queue.h" > #include "qemu/queue.h" > #include "net/net.h" > +#include "block/aio.h" > +#include "qemu/main-loop.h" > > /* The delivery handler may only return zero if it will call > * qemu_net_queue_flush() when it determines that it is once again able > @@ -183,6 +185,22 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, > return ret; > } > > +typedef struct NetQueBH { This file uses "Queue" consistently, please don't add "Que" here. > @@ -192,8 +210,17 @@ ssize_t qemu_net_queue_send(NetQueue *queue, > { > ssize_t ret; > > - if (queue->delivering || !qemu_can_send_packet_nolock(sender)) { > + if (queue->delivering || !qemu_can_send_packet_nolock(sender) > + || sender->send_queue->delivering) { Not sure this is safe, we're only holding one NetClientState->peer_lock and one NetQueue->lock. How can we access both queue->delivering and sender->send_queue->delivering safely?