From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF4I6-0007I5-Tz for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:37:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF4I0-0008Ad-VP for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:37:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF4I0-0008AU-M2 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:37:40 -0400 Date: Thu, 29 Aug 2013 17:37:29 +0200 From: Stefan Hajnoczi Message-ID: <20130829153729.GA27529@stefanha-thinkpad.redhat.com> References: <1377591839-2743-1-git-send-email-stefanha@redhat.com> <1377591839-2743-3-git-send-email-stefanha@redhat.com> <521F1BAC.902@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <521F1BAC.902@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Ping Fan Liu , qemu-devel@nongnu.org, Alex Bligh On Thu, Aug 29, 2013 at 12:00:12PM +0200, Paolo Bonzini wrote: > Il 27/08/2013 10:23, Stefan Hajnoczi ha scritto: > > /* modify the current timer so that it will be fired when current_time > > >= expire_time. The corresponding callback will be called. */ > > void timer_mod_ns(QEMUTimer *ts, int64_t expire_time) > > { > > + QEMUTimerList *timer_list = ts->timer_list; > > QEMUTimer **pt, *t; > > > > timer_del(ts); > > > > /* add the timer in the sorted list */ > > - pt = &ts->timer_list->active_timers; > > + qemu_mutex_lock(&timer_list->active_timers_lock); > > + pt = &timer_list->active_timers; > > I think deletion and modification of the list should happen without > releasing the lock in the middle. Thanks for explaining the race between two timer_mod_ns() calls to me on IRC. I have sent a new revision of this series with your fixes included. Stefan