From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQdco-0007X4-3C for qemu-devel@nongnu.org; Mon, 30 Sep 2013 09:34:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQdcm-000055-GV for qemu-devel@nongnu.org; Mon, 30 Sep 2013 09:34:58 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:41655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQdcm-00004u-Ae for qemu-devel@nongnu.org; Mon, 30 Sep 2013 09:34:56 -0400 Date: Mon, 30 Sep 2013 14:34:42 +0100 From: Alex Bligh Message-ID: <73208DCACC5648DDB3E030CD@Ximines.local> In-Reply-To: References: <1378976540-10812-1-git-send-email-stefanha@redhat.com> <1378976540-10812-3-git-send-email-stefanha@redhat.com> <877gdy4gwj.fsf@pixel.localdomain> <4C38C504-350E-4492-89A9-AFF84BAE9836@alex.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH v4 2/3] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe Reply-To: Alex Bligh List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mike Day Cc: Ping Fan Liu , Stefan Hajnoczi , qemu-devel@nongnu.org, Alex Bligh , Anthony Liguori , Paolo Bonzini Mike, >> > void qemu_clock_notify(QEMUClockType type) ... >> > int64_t qemu_clock_deadline_ns_all(QEMUClockType type) ... >> > I think these functions are always called now with the BQL held, so I >> > wonder if they are good candidates for RCU? >> >> These routines iterate through the list of timerlists held by >> a clock. >> >> They do not iterate through the list of active timers in a timer >> list. I believe the latter is what active_timers_lock protects. >> >> The list of timers attached to a clock is only modified when timers >> are created and deleted which is (currently) under the BQL. >> > > > > Sorry, and thanks for the correction re: active_timers_lock. I should > have said that clock->timerlists may need its own mutex if and when we > remove the BQL from the timer code. Correct. The list of timerlists is only modified when a QEMUTimerListGroup is created or destroyed (currently when an AioContext is created or destroyed), and that is done with the BQL held. As you point out, it's currently walked by a couple of functions that also have the BQL held. I think the most likely change here is that the walkers might move outside the BQL. Given modification of this list is so rare, the lock would be very very read heavy, so RCU is probably a sensible option. This link may (or may not) help in understanding: http://blog.alex.org.uk/2013/08/24/changes-to-qemus-timer-system/ -- Alex Bligh