From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFvNe-0004L1-9a for qemu-devel@nongnu.org; Thu, 16 Jul 2015 22:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFvNb-00071e-3Z for qemu-devel@nongnu.org; Thu, 16 Jul 2015 22:28:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFvNa-00071a-Tt for qemu-devel@nongnu.org; Thu, 16 Jul 2015 22:28:03 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9309F3173F1 for ; Fri, 17 Jul 2015 02:28:02 +0000 (UTC) References: <1437040609-9878-1-git-send-email-pbonzini@redhat.com> <1437040609-9878-4-git-send-email-pbonzini@redhat.com> <20150717022525.GA13284@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55A8682E.5090609@redhat.com> Date: Fri, 17 Jul 2015 04:27:58 +0200 MIME-Version: 1.0 In-Reply-To: <20150717022525.GA13284@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, rjones@redhat.com On 17/07/2015 04:25, Fam Zheng wrote: > What if aio_notify happens after the previous aio_dispatch() but before the > next necessary atomic_add? The aio_notify would still skip the > event_notifier_set(), and the next ppoll() will not return. For example: > > Thread A Thread B > ------------------------------------------------------------------------ > aio_poll(blocking=true) > aio_notify() > smp_mb() > if (ctx->notify_me) /* false! */ > atomic_add(ctx->notify_me, 2) > ppoll() > atomic_sub(ctx->notify_me, 2) event_notifier_set() /* not run */ It's not a problem because ppoll() has exited. The next call to aio_poll or aio_ctx_prepare will notice the bottom half, do a non-blocking ppoll(), and then service the bottom half. > > And if that's not a problem, why don't we need something like ACCESS_ONCE in > aio_noitfy()? Because there's already a smp_mb() which is stronger. Paolo