From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UobLv-0001OL-Qh for qemu-devel@nongnu.org; Mon, 17 Jun 2013 11:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UobLu-0007kz-Do for qemu-devel@nongnu.org; Mon, 17 Jun 2013 11:28:19 -0400 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:41458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UobLu-0007kr-7f for qemu-devel@nongnu.org; Mon, 17 Jun 2013 11:28:18 -0400 Received: by mail-wg0-f52.google.com with SMTP id b12so2539468wgh.7 for ; Mon, 17 Jun 2013 08:28:17 -0700 (PDT) Date: Mon, 17 Jun 2013 17:28:14 +0200 From: Stefan Hajnoczi Message-ID: <20130617152814.GB31444@stefanha-thinkpad.redhat.com> References: <1371381681-14252-1-git-send-email-pingfanl@linux.vnet.ibm.com> <1371381681-14252-3-git-send-email-pingfanl@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1371381681-14252-3-git-send-email-pingfanl@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Paolo Bonzini , qemu-devel@nongnu.org, Anthony Liguori On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: > @@ -47,8 +47,12 @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) > bh->ctx = ctx; > bh->cb = cb; > bh->opaque = opaque; > + qemu_mutex_lock(&ctx->bh_lock); > bh->next = ctx->first_bh; > + /* Make sure the memebers ready before putting bh into list */ s/memebers/members/ > + smp_wmb(); Why lock bh_lock before assigning bh->next? Could you lock the mutex here and then drop the smp_wmb() since the pthread function already does that? http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11