From nobody Tue Apr 23 10:04:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1590129389; cv=none; d=zohomail.com; s=zohoarc; b=R845DwCBr31e+jDGYwI9TUyAo76Wn+Xk5m+PuOGdRfvaIo0cisgmLdC2OBpHQsyGn8Nod/gM8ZxTMJ678//Rpfoupqkk98+78+sqtcIv59CYCUIO29YIp2to55/L8nLyzguI5mPjV20WuS5+DGvrm0WwXwb42uTxQRysehbF6tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590129389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9brl2MiGo15ILi5XoRHmM08CyuhK9lyv8eyAjz3Y8HU=; b=SKxTYjHiVA5Mx58EeA5onwDz1MGYyh4D3za1+xhwU3vXyDYEfEmMPqod5jo8onWLI8UgFL4mNYETvNoPqyyf3aNibHkg+/6Qp9utvCYFBPhplgotEoV4Y4hUZ97BLFlRkKLaqV1l1O/bEpqSJvzvuYDxZS89yB90nw8Mt3rxik8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590129389096464.23101299617485; Thu, 21 May 2020 23:36:29 -0700 (PDT) Received: from localhost ([::1]:47824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc1IB-0001zI-Ef for importer@patchew.org; Fri, 22 May 2020 02:36:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc1HK-0000Xb-Ga for qemu-devel@nongnu.org; Fri, 22 May 2020 02:35:34 -0400 Received: from mail.ispras.ru ([83.149.199.45]:38440) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc1HG-0007ck-AK for qemu-devel@nongnu.org; Fri, 22 May 2020 02:35:34 -0400 Received: from [127.0.1.1] (unknown [62.118.151.149]) by mail.ispras.ru (Postfix) with ESMTPSA id 9E375CD46A; Fri, 22 May 2020 09:35:27 +0300 (MSK) Subject: [PATCH v2] replay: synchronize on every virtual timer callback From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Fri, 22 May 2020 09:35:27 +0300 Message-ID: <159012932716.27256.8854065545365559921.stgit@pasha-ThinkPad-X280> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=83.149.199.45; envelope-from=Pavel.Dovgaluk@gmail.com; helo=mail.ispras.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 02:35:28 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: 7 X-Spam_score: 0.7 X-Spam_bar: / X-Spam_report: (0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org, pavel.dovgaluk@ispras.ru, dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Sometimes virtual timer callbacks depend on order of virtual timer processing and warping of virtual clock. Therefore every callback should be logged to make replay deterministic. This patch creates a checkpoint before every virtual timer callback. With these checkpoints virtual timers processing and clock warping events order is completely deterministic. Signed-off-by: Pavel Dovgalyuk Acked-by: Alex Benn=C3=A9e -- v2: - remove mutex lock/unlock for virtual clock checkpoint since it is not process any asynchronous events (commit ca9759c2a92f528f256fef0e392= 2416f7bb47bf9) - bump record/replay log file version --- 0 files changed diff --git a/replay/replay.c b/replay/replay.c index 706c7b4f4b..53edad1377 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe02009 +#define REPLAY_VERSION 0xe0200a /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 diff --git a/util/qemu-timer.c b/util/qemu-timer.c index b6575a2cd5..f62b4feecd 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -501,7 +501,6 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) bool progress =3D false; QEMUTimerCB *cb; void *opaque; - bool need_replay_checkpoint =3D false; =20 if (!atomic_read(&timer_list->active_timers)) { return false; @@ -517,16 +516,6 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) break; default: case QEMU_CLOCK_VIRTUAL: - if (replay_mode !=3D REPLAY_MODE_NONE) { - /* Checkpoint for virtual clock is redundant in cases where - * it's being triggered with only non-EXTERNAL timers, because - * these timers don't change guest state directly. - * Since it has conditional dependence on specific timers, it = is - * subject to race conditions and requires special handling. - * See below. - */ - need_replay_checkpoint =3D true; - } break; case QEMU_CLOCK_HOST: if (!replay_checkpoint(CHECKPOINT_CLOCK_HOST)) { @@ -559,19 +548,16 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) */ break; } - if (need_replay_checkpoint - && !(ts->attributes & QEMU_TIMER_ATTR_EXTERNAL)) { - /* once we got here, checkpoint clock only once */ - need_replay_checkpoint =3D false; + /* Checkpoint for virtual clock is redundant in cases where + * it's being triggered with only non-EXTERNAL timers, because + * these timers don't change guest state directly. + */ + if (replay_mode !=3D REPLAY_MODE_NONE + && timer_list->clock->type =3D=3D QEMU_CLOCK_VIRTUAL + && !(ts->attributes & QEMU_TIMER_ATTR_EXTERNAL) + && !replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) { qemu_mutex_unlock(&timer_list->active_timers_lock); - if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) { - goto out; - } - qemu_mutex_lock(&timer_list->active_timers_lock); - /* The lock was released; start over again in case the list was - * modified. - */ - continue; + goto out; } =20 /* remove timer from the list before calling the callback */