From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V99T5-0006fT-4W for qemu-devel@nongnu.org; Tue, 13 Aug 2013 03:56:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V99Sx-0005C6-QX for qemu-devel@nongnu.org; Tue, 13 Aug 2013 03:56:39 -0400 Received: from goliath.siemens.de ([192.35.17.28]:15533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V99Sx-0005B5-Fx for qemu-devel@nongnu.org; Tue, 13 Aug 2013 03:56:31 -0400 Message-ID: <5209E6A1.6060308@siemens.com> Date: Tue, 13 Aug 2013 09:56:17 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Using aio_poll for timer carrier threads List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , qemu-devel , liu ping fan , Alex Bligh , Paolo Bonzini , MORITA Kazutaka , Richard Henderson 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? Our iothread mainloop more or less open-codes aio_poll and is, thus, able to drop its lock before falling asleep while still holding it during event dispatching. Obviously, I need the same when processing timer lists of an AioContext, protecting them against concurrent modifications over VCPUs or other threads. So I'm thinking of adding a block notification callback to aio_poll, to be called before/after qemu_poll_ns so that any locks can be dropped / reacquired as needed. Or am I missing some magic interface / pattern? Jan -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux