From patchwork Tue Feb 27 09:52:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 129756 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1208207lja; Tue, 27 Feb 2018 02:05:59 -0800 (PST) X-Google-Smtp-Source: AH8x224hOqrWKfMAiC5AcgoS6hqXMHvXG4FEuZwZTG6590RZKzu7cvvnlx0WG0ab8x4kx6cHhTWS X-Received: by 10.129.156.204 with SMTP id t195mr8647704ywg.48.1519725959214; Tue, 27 Feb 2018 02:05:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519725959; cv=none; d=google.com; s=arc-20160816; b=M29Z7KpGwTiMDax1Iq+fkHcp8MNRCEbvP76x16EgSAi+HqiVpmLEBHqU1RIKyJXFa/ hIdFO+2Scy0lIgPCIe4fsnD4e7NjDSJOnks6L3yhqZZH4/iBmdq9bYzkxTjGQLUps+kO iGTsHAQRV6UqYTNdCuOSsGYfbxOe705cVAiB0P8NQSpJtKQaYoBO64nR7JVdFIYkMJWp AYyBWcD2juR/pp83U8b6CNNo05Z50Vwq+B9cKa6o9gMRc5qEtxu561TyqXHQ6Q26Oa8x FL1O0eqOYE7afoI5NbY09yZwvBt0ZVPNQAeempQN//LmqLJsV7j7zO7Ru7kKb5T3eXWW dOmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=LfC7D1Wv+O+LGW60lnjmA/sCspRq2IU8r9aj1pRwAuI=; b=o+gZv0bkeGFk4QlKDs8UeS1MTPy3luUe5PT2qgc/7a6TIGMLbF6kC4FZY/eFX/L/VD iSoiZpELHuuimPG/ALE6pKWM1iZh7QmxDTJinWJLwOH+6DU5GkL0CYkMWXbUmANXCZs1 nLK2sE0QbM7xWDxMe3ASb2Nwi1zoQ3wdMOQ12dsGuXhDUVmXlukAI0tHYukXqZLO0Kl3 8E28kP0Gj+hB2FlrHrovczabOxyPJEjR4FfkMY7ORXPVIPUdA22DyFK1NOfSXdnzWKvA WrXZ+KWmGM3ORG0KNAaK0qbtxUxZwpOuHak7lWIiZj/rUMlvhk+uAyrCFlMc5NS6E9r+ fEEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f9-v6si37288ybm.460.2018.02.27.02.05.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 02:05:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:35891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqc90-0004V4-7g for patch@linaro.org; Tue, 27 Feb 2018 05:05:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqbwE-0001LU-QV for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqbwA-00052G-T5 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:46 -0500 Received: from mail.ispras.ru ([83.149.199.45]:57444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqbwA-00051w-Fx for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:42 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 7ECD954006A; Tue, 27 Feb 2018 12:52:41 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 27 Feb 2018 12:52:42 +0300 Message-ID: <20180227095242.1060.16601.stgit@pasha-VirtualBox> In-Reply-To: <20180227095135.1060.36549.stgit@pasha-VirtualBox> References: <20180227095135.1060.36549.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v7 12/22] 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: kwolf@redhat.com, peter.maydell@linaro.org, war2jordan@live.com, pavel.dovgaluk@ispras.ru, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, mst@redhat.com, zuban32s@gmail.com, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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ée Signed-off-by: Pavel Dovgalyuk -- v7: - removed abort() from stubs to allow calling from utils - removed exported replay_mutex_locked() --- 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 5462555..291bcbc 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -46,6 +46,19 @@ extern ReplayMode replay_mode; /* Name of the initial VM snapshot */ extern char *replay_snapshot; +/* 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 */ /*! Enables recording or saving event log with specified parameters */ diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 0d7e1d6..7cdefea 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -181,7 +181,7 @@ void replay_mutex_destroy(void) qemu_mutex_destroy(&lock); } -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 8e4c701..41eee66 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); -/* Mutex functions for protecting replay log file */ +/* Mutex functions for protecting replay log file and ensuring + * synchronisation between vCPU and main-loop threads. */ 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); /*! Checks error status of the file. */ void replay_check_error(void); diff --git a/stubs/replay.c b/stubs/replay.c index 9991ee5..18ba0bb 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -73,3 +73,11 @@ uint64_t blkreplay_next_id(void) { return 0; } + +void replay_mutex_lock(void) +{ +} + +void replay_mutex_unlock(void) +{ +}