From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAdt0-0005hs-Bs for qemu-devel@nongnu.org; Mon, 12 Jan 2015 07:14:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAdsv-0004Ta-Bg for qemu-devel@nongnu.org; Mon, 12 Jan 2015 07:14:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAdsv-0004TP-2F for qemu-devel@nongnu.org; Mon, 12 Jan 2015 07:14:17 -0500 Message-ID: <54B3BA89.6080705@redhat.com> Date: Mon, 12 Jan 2015 13:14:01 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150112115944.3504.66763.stgit@PASHA-ISP> <20150112120054.3504.35220.stgit@PASHA-ISP> In-Reply-To: <20150112120054.3504.35220.stgit@PASHA-ISP> 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 Dovgalyuk , 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 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? Please introduce the record/replay QemuMutex in patch 4, and all along the series document which variables it protects. Paolo > diff --git a/replay/replay.h b/replay/replay.h > index 90a949b..1c18c0e 100755 > --- a/replay/replay.h > +++ b/replay/replay.h > @@ -16,6 +16,16 @@ > #include > #include "qapi-types.h" > > +/* replay clock kinds */ > +/* rdtsc */ > +#define REPLAY_CLOCK_REAL_TICKS 0 > +/* host_clock */ > +#define REPLAY_CLOCK_HOST 1 > +/* virtual_rt_clock */ > +#define REPLAY_CLOCK_VIRTUAL_RT 2 > + > +#define REPLAY_CLOCK_COUNT 3 > + > extern ReplayMode replay_mode; > extern char *replay_image_suffix; > > @@ -47,6 +57,19 @@ bool replay_interrupt(void); > Returns true, when interrupt request is pending */ > bool replay_has_interrupt(void); > > +/* Processing clocks and other time sources */ > + > +/*! Save the specified clock */ > +int64_t replay_save_clock(unsigned int kind, int64_t clock); > +/*! Read the specified clock from the log or return cached data */ > +int64_t replay_read_clock(unsigned int kind); > +/*! Saves or reads the clock depending on the current replay mode. */ > +#define REPLAY_CLOCK(clock, value) \ > + (replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock)) \ > + : replay_mode == REPLAY_MODE_RECORD \ > + ? replay_save_clock((clock), (value)) \ > + : (value)) > + Inline functions please, not macros.