From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAxwA-0005rH-D2 for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:38:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAxw5-0001Fv-AJ for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:38:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAxw5-0001Fp-43 for qemu-devel@nongnu.org; Tue, 13 Jan 2015 04:38:53 -0500 Message-ID: <54B4E79C.5010201@redhat.com> Date: Tue, 13 Jan 2015 10:38:36 +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> In-Reply-To: <000501d02f12$61177b30$23467190$@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 13/01/2015 10:21, Pavel Dovgaluk 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 document exactly which globals are protected by the rr QemuMutex, and which by the global mutex. But I think as many variables as possible should be protected by the rr QemuMutex, for two reasons: 1) people are working on threaded TCG. While SMP record/replay is a whole different story, even UP TCG will be multithreaded. 2) in the end it makes reviewing the code simpler. Paolo