From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V46vF-00062F-15 for qemu-devel@nongnu.org; Tue, 30 Jul 2013 06:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V46v9-0000oH-1j for qemu-devel@nongnu.org; Tue, 30 Jul 2013 06:12:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V46v8-0000oA-QZ for qemu-devel@nongnu.org; Tue, 30 Jul 2013 06:12:46 -0400 Message-ID: <51F7917E.5050709@redhat.com> Date: Tue, 30 Jul 2013 12:12:14 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1375067768-11342-1-git-send-email-pingfank@linux.vnet.ibm.com> <1375067768-11342-4-git-send-email-pingfank@linux.vnet.ibm.com> <51F60C02.6020008@redhat.com> <51F65044.4040706@redhat.com> <51F78491.708@redhat.com> <363032E79978D01AEAB1A5AE@Ximines.local> In-Reply-To: <363032E79978D01AEAB1A5AE@Ximines.local> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Stefan Hajnoczi , Jan Kiszka , liu ping fan , qemu-devel@nongnu.org, Anthony Liguori Il 30/07/2013 11:51, Alex Bligh ha scritto: > As far as walking the QEMUTimerList itself is concerned, this is > something which is 99.999% done by the thread owning the AioContext. > qemu_clock_enable should not even be walking this list. So I don't > see why the protection here is needed. The protection is needed not because of qemu_clock_enable, but rather because of code in qemu_clock_enable's caller. Such code likely expects not to run concurrently with timers. qemu_clock_enable however can be called from other threads than the one owning the AioContext. Furthermore, it can happen while timer callbacks are being called, because callbacks are called without holding any lock. If you put together these conditions, qemu_clock_enable has to wait for timer callbacks to finish running before returning. Paolo