From nobody Tue Dec 16 07:07:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520984426061140.33766044932167; Tue, 13 Mar 2018 16:40:26 -0700 (PDT) Received: from localhost ([::1]:43569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtWr-0000Oo-5s for importer@patchew.org; Tue, 13 Mar 2018 19:40:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsij-0006Ne-Eo for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsii-0004AK-HW for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:37 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:33977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsii-00049c-9l for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:36 -0400 Received: by mail-wr0-x243.google.com with SMTP id o8so2599343wra.1 for ; Tue, 13 Mar 2018 15:48:36 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id x107sm1557951wrb.97.2018.03.13.15.48.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XTH1yi6oxPFB16KTQCK1koIP4f8avjYkPChlxnpddOA=; b=cJ6FIVJ+fhKeV7kjG7yyEPKJES+y/Yl10e//L4/EX3J65EJUeouUMohAcD49yPBH1w lrznMQ5fvqtz5ifKAcm7XhB88zUTpRjCPyXOUiQUTquWHvqyVYxr0rG+NQAfAd/aDzwu aD+WXPJzNKNMthuBk+J+O6JyG1umtdyZXZuQyx8GMlWBJ8QisukgJDxb6nAmGeQhz1YX yQGh4fdUQ9NPKppc/AXYc5BT/k+D1jHZrwgLmkkF0kv3xL33Zazy1dkkst5rlxHUN7Mw sYGPjva/7+pxh5Qja3qYq2zP44prMjqWdrB4OEADkdslsLutUTPJ6HLIs/Gox2Lmfh64 bsKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XTH1yi6oxPFB16KTQCK1koIP4f8avjYkPChlxnpddOA=; b=Am0inZ9SkDrcmOM5WALDSjrF0Y2zc+uXqqtfVRRJBUah1MgL2V1Y9+ke/g5PFp7sp3 CceNxUhtYUVBBo8xsYzVC5vuSbu1Ir1ENuBt9O/ua/mzJkFukVy2k6+jUw/0WXkHYxjg Ua+TEqvQiukdKyT5l6TCrZBdCVyomvt0Oqf8++KDdB8qYNoi3s1qxkUp/u6DYVbNgg4r PW0/jRWpayXYK9f5KSgg+qtoBVZ9LaJbk+tveORTdbu4UYADenHfYo/BVFmgZ3ezDyPX IKearLibCKBb0WQqh0QFtZSdnhiFYuiv6n3bhhzbX4AaLNOZDLObh7gs/1kQcOXSvJj0 WItg== X-Gm-Message-State: AElRT7FUQqHFNdrB3KcGZPLrD5/Gawbd+Feug66xOknrQqHAu87Ja5Fi C472DhXgKapsGWrV4tHwYxL/wr62 X-Google-Smtp-Source: AG47ELtEKfuKzzMzh4BSdNRDcFiwhwp0sxN7LUUrkHzrWZhDXSJrr7ru4qT1SCEBKpXLwfiu9Mb95g== X-Received: by 10.223.135.26 with SMTP id a26mr1986792wra.211.1520981314827; Tue, 13 Mar 2018 15:48:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:10 +0100 Message-Id: <20180313224719.4954-61-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313224719.4954-1-pbonzini@redhat.com> References: <20180313224719.4954-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 60/69] replay: make locking visible outside replay code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e The replay_mutex_lock/unlock/locked functions are now going to be used for ensuring lock-step behaviour between the two threads. Make them public API functions and also provide stubs for non-QEMU builds on common paths. Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Pavel Dovgalyuk Message-Id: <20180227095242.1060.16601.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- include/sysemu/replay.h | 13 +++++++++++++ replay/replay-internal.c | 2 +- replay/replay-internal.h | 6 +++--- stubs/replay.c | 8 ++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 401de12130..3ced6bc231 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -48,6 +48,19 @@ extern ReplayMode replay_mode; /* Name of the initial VM snapshot */ extern char *replay_snapshot; =20 +/* Replay locking + * + * The locks are needed to protect the shared structures and log file + * when doing record/replay. They also are the main sync-point between + * the main-loop thread and the vCPU thread. This was a role + * previously filled by the BQL which has been busy trying to reduce + * its impact across the code. This ensures blocks of events stay + * sequential and reproducible. + */ + +void replay_mutex_lock(void); +void replay_mutex_unlock(void); + /* Replay process control functions */ =20 /*! Enables recording or saving event log with specified parameters */ diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 0d7e1d6bc4..7cdefeaa04 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -181,7 +181,7 @@ void replay_mutex_destroy(void) qemu_mutex_destroy(&lock); } =20 -static bool replay_mutex_locked(void) +bool replay_mutex_locked(void) { return replay_locked; } diff --git a/replay/replay-internal.h b/replay/replay-internal.h index 8e4c701751..41eee66e9b 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -100,12 +100,12 @@ int64_t replay_get_qword(void); void replay_get_array(uint8_t *buf, size_t *size); void replay_get_array_alloc(uint8_t **buf, size_t *size); =20 -/* Mutex functions for protecting replay log file */ +/* Mutex functions for protecting replay log file and ensuring + * synchronisation between vCPU and main-loop threads. */ =20 void replay_mutex_init(void); void replay_mutex_destroy(void); -void replay_mutex_lock(void); -void replay_mutex_unlock(void); +bool replay_mutex_locked(void); =20 /*! Checks error status of the file. */ void replay_check_error(void); diff --git a/stubs/replay.c b/stubs/replay.c index 9c8aa48c9c..04279abb2c 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -72,3 +72,11 @@ uint64_t blkreplay_next_id(void) { return 0; } + +void replay_mutex_lock(void) +{ +} + +void replay_mutex_unlock(void) +{ +} --=20 2.14.3