From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpFPo-0006hf-IW for qemu-devel@nongnu.org; Thu, 12 Jul 2012 05:10:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpFPm-0000AT-V1 for qemu-devel@nongnu.org; Thu, 12 Jul 2012 05:10:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpFPm-00008j-Nr for qemu-devel@nongnu.org; Thu, 12 Jul 2012 05:10:26 -0400 Message-ID: <4FFE9471.1060305@redhat.com> Date: Thu, 12 Jul 2012 12:10:09 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1341501390-797-1-git-send-email-pbonzini@redhat.com> <1341501390-797-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1341501390-797-3-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH uq/master 2/9] event_notifier: remove event_notifier_test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kvm@vger.kernel.org, mst@redhat.com, jan.kiszka@siemens.com, mtosatti@redhat.com, qemu-devel@nongnu.org, anthony.perard@citrix.com, stefano.stabellini@eu.citrix.com On 07/05/2012 06:16 PM, Paolo Bonzini wrote: > This is broken; since the eventfd is used in nonblocking mode there > is a race between reading and writing. > > diff --git a/event_notifier.c b/event_notifier.c > index 2b210f4..c339bfe 100644 > --- a/event_notifier.c > +++ b/event_notifier.c > @@ -51,18 +51,3 @@ int event_notifier_test_and_clear(EventNotifier *e) > int r = read(e->fd, &value, sizeof(value)); > return r == sizeof(value); > } > - > -int event_notifier_test(EventNotifier *e) > -{ > - uint64_t value; > - int r = read(e->fd, &value, sizeof(value)); > - if (r == sizeof(value)) { > - /* restore previous value. */ > - int s = write(e->fd, &value, sizeof(value)); > - /* never blocks because we use EFD_SEMAPHORE. > - * If we didn't we'd get EAGAIN on overflow > - * and we'd have to write code to ignore it. */ > - assert(s == sizeof(value)); > - } > - return r == sizeof(value); > -} I don't see the race. Mind explaining? It does however require than a poller be extra careful when reading; and the function is silly anyway. -- error compiling committee.c: too many arguments to function