From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9Fsh-0003ic-6h for qemu-devel@nongnu.org; Tue, 13 Aug 2013 10:47:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9FsY-0001v6-Or for qemu-devel@nongnu.org; Tue, 13 Aug 2013 10:47:31 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:40290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9FsY-0001uw-IL for qemu-devel@nongnu.org; Tue, 13 Aug 2013 10:47:22 -0400 Received: by mail-wi0-f175.google.com with SMTP id hq12so723518wib.14 for ; Tue, 13 Aug 2013 07:47:21 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <520A467E.6000406@redhat.com> Date: Tue, 13 Aug 2013 16:45:18 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <5209E6A1.6060308@siemens.com> In-Reply-To: <5209E6A1.6060308@siemens.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Using aio_poll for timer carrier threads List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , qemu-devel , liu ping fan , Alex Bligh , MORITA Kazutaka , Richard Henderson Il 13/08/2013 09:56, Jan Kiszka ha scritto: > Hi Stefan, > > in the attempt to use Alex' ppoll-based timer rework for decoupled, > real-time capable timer device models I'm now scratching my head over > the aio_poll interface. I'm looking at dataplane/virtio-blk.c, just finding > > static void *data_plane_thread(void *opaque) > { > VirtIOBlockDataPlane *s = opaque; > > do { > aio_poll(s->ctx, true); > } while (!s->stopping || s->num_reqs > 0); > return NULL; > } > > wondering where the locking is. Or doesn't this use need any at all? Are > all data structures that this thread accesses exclusively used by it, or > are they all accessed in a lock-less way? There is some locking in aio_bh_poll. It is pretty lightweight because adding elements and deleting them is done under a lock, while the list is walked without taking it (because deletion is only done by the thread that walks). We could do something similar for file descriptors; timers are more complicated because insertions happen for every mod_timer. Using an AioContext lock for timers is somewhat complicated for lock ordering, because context A could try to modify a timer from context B, at the same time when context B is modifying a timer from context A. This would cause a deadlock. So I agree with Stefan's usage of a finer-grain lock for timer lists. Paolo