Received: from eggs.gnu.org ([2001:4830:134:3::10]:44447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAxfl-0007q4-KY for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:22:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAxfh-00037V-HE for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:22:01 -0500 Received: from mail.ispras.ru ([83.149.199.45]:34417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAxfh-00037H-98 for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:21:57 -0500 From: "Pavel Dovgaluk" References: <20150112115944.3504.66763.stgit@PASHA-ISP> <20150112120054.3504.35220.stgit@PASHA-ISP> <54B3BA89.6080705@redhat.com> In-Reply-To: <54B3BA89.6080705@redhat.com> Date: Tue, 13 Jan 2015 12:21:57 +0300 Message-ID: <000501d02f12$61177b30$23467190$@Dovgaluk@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-Language: ru 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: 'Paolo Bonzini' , 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 > From: Paolo Bonzini [mailto:pbonzini@redhat.com] > On 12/01/2015 13:00, Pavel Dovgalyuk wrote: > > +/*! Reads next clock event from the input. */ > > +int64_t replay_read_clock(unsigned int kind) > > +{ > > + if (kind >= REPLAY_CLOCK_COUNT) { > > + fprintf(stderr, "invalid clock ID %d for replay\n", kind); > > + exit(1); > > + } > > + > > + replay_exec_instructions(); > > + > > + if (replay_file) { > > + if (skip_async_events(EVENT_CLOCK + kind)) { > > + replay_read_next_clock(kind); > > + } > > + int64_t ret = replay_state.cached_clock[kind]; > > + > > + return ret; > > + } > > + > > + fprintf(stderr, "REPLAY INTERNAL ERROR %d\n", __LINE__); > > + exit(1); > > +} > > Is this thread safe? It is, because order of main_loop and cpu_exec executions is protected by global mutex. > Please introduce the record/replay QemuMutex in > patch 4, and all along the series document which variables it protects. record/replay only uses mutex for events queue, because events may be added to the queue by the different threads. Pavel Dovgalyuk