From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDAsL-0006p1-CK for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:52:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDAsF-00063C-8v for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:52:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDAsF-000631-1M for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:52:03 -0500 Message-ID: <54BCEFD1.5040702@redhat.com> Date: Mon, 19 Jan 2015 12:51:45 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150112115944.3504.66763.stgit@PASHA-ISP> <20150112120054.3504.35220.stgit@PASHA-ISP> <54B3BA89.6080705@redhat.com> <000501d02f12$61177b30$23467190$@Dovgaluk@ispras.ru> <54B4E79C.5010201@redhat.com> <000101d03162$f2d2ed50$d878c7f0$@Dovgaluk@ispras.ru> In-Reply-To: <000101d03162$f2d2ed50$d878c7f0$@Dovgaluk@ispras.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v7 12/21] replay: recording and replaying clock ticks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgaluk , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, alex.bennee@linaro.org, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, afaerber@suse.de, fred.konrad@greensocs.com On 16/01/2015 09:03, Pavel Dovgaluk wrote: > There is one problem with protecting log file inside the replay code. > We probably should have the following sequence of calls: > > lock_replay_mutex > replay_save_events > replay_run_event > unlock_replay_mutex > > But replay_run_event can also generate some log events and we will have deadlock here. > That is why we rely on global mutex. I think replay_run_event should run with the lock _not_ taken, that is: qemu_mutex_lock(&lock); while (!QTAILQ_EMPTY(&events_list)) { Event *event = QTAILQ_FIRST(&events_list); QTAILQ_REMOVE(&events_list, event, events); qemu_mutex_unlock(&lock); replay_run_event(event); g_free(event); qemu_mutex_lock(&lock); } qemu_mutex_unlock(&lock); Paolo