From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcvDl-0001FW-2l for qemu-devel@nongnu.org; Thu, 16 May 2013 06:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcvDj-0007uR-SL for qemu-devel@nongnu.org; Thu, 16 May 2013 06:15:37 -0400 Received: from mail-bk0-x232.google.com ([2a00:1450:4008:c01::232]:57742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcvDj-0007uK-LM for qemu-devel@nongnu.org; Thu, 16 May 2013 06:15:35 -0400 Received: by mail-bk0-f50.google.com with SMTP id ik5so1539410bkc.23 for ; Thu, 16 May 2013 03:15:34 -0700 (PDT) Date: Thu, 16 May 2013 12:15:31 +0200 From: Stefan Hajnoczi Message-ID: <20130516101531.GD8853@stefanha-thinkpad.redhat.com> References: <1368632937-32272-1-git-send-email-pbonzini@redhat.com> <1368632937-32272-3-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368632937-32272-3-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 02/12] qemu-thread: add QemuEvent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Jan Kiszka , David Gibson , qemu-devel@nongnu.org, qemulist@gmail.com On Wed, May 15, 2013 at 05:48:47PM +0200, Paolo Bonzini wrote: > This emulates Win32 manual-reset events using futexes or conditional > variables. Typical ways to use them are with multi-producer, > single-consumer data structures, to test for a complex condition whose > elements come from different threads: > > for (;;) { > qemu_event_reset(ev); > ... test complex condition ... > if (condition is true) { > break; > } > qemu_event_wait(ev); > } > > Alternatively: > > ... compute condition ... > if (condition) { > do { > qemu_event_wait(ev); > qemu_event_reset(ev); > ... compute condition ... > } while(condition); > qemu_event_set(ev); > } > > QemuEvent provides a very fast userspace path in the common case when > no other thread is waiting, or the event is not changing state. It > is used to report RCU quiescent states to the thread calling > synchronize_rcu (the latter being the single consumer), and to report > call_rcu invocations to the thread that receives them. It would be nice to describe the need for the Linux futex code. pthread mutex/condvars are implemented in terms of futexes already, so how much benefit is there - I thought they stay in userspace in the non-contended case too? Stefan