From patchwork Tue Mar 13 22:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 131540 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp178711ljb; Tue, 13 Mar 2018 16:38:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELvtncn98cnZYlA1CrEAkCoLCPnZuHVwh97fIZ+ABL4A+JI96WnX6nrTf9SvCIBnD2fxHQ2j X-Received: by 10.55.134.135 with SMTP id i129mr3544710qkd.177.1520984326513; Tue, 13 Mar 2018 16:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520984326; cv=none; d=google.com; s=arc-20160816; b=Of7K7ljWN6Ytsb9FelwVj2UpwLJk91MaYqSRat0RNBrpG0vsthLMtbUPpYke2aHVIQ Bmato5sHRUcFE0GiM3s6zLdZYaNnrZHM+BGs3EpwVkUWcXTF0LQaJ6AUe7En03KL/wHw nFpvFPmgtoogSRQuRQsw3K8dKnZC1KY/OH423f7hoyCLMFJf/6iic8QivsUjosviI0mM mboc9AN5/rfs9DCP+g+NTK9zSQU8f3kcdE+yNqm+NRUiReZWLujETn1MVFxp3pDkPFy1 suNoB2/bLjqSdJXA27PgY6+RmE+XeK0ulFGHE+Ee4egfDuijJMdpWlOChSha0/P8ZD1Q +Nkw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=XTH1yi6oxPFB16KTQCK1koIP4f8avjYkPChlxnpddOA=; b=WDOqsFvSWE25om05FraUBHzVM3Oq9FEFN2D+BTfk5JsEEdOP3CCheQYGVFJO5JsR4m dmgDUDpRhY/5UCPME6q9gANFYhgOG9riADKZd37yIoG0oZEEdqIGqRTdffCcVy0Lr5fd 2DhNMTC9ghl2ORLVRNbbFqzqAVyI575gSO+gnBGfRjLQcc8fhklsqoyUbzCDxsK+NOzi S3nzyRNvl+27dqmycLaav2u0WOz/dJ0ggdFHedKmLreKjORbbL42xlszpPkeqqUUPGfF /UHjvlEO8HN1GmVd71LpO8GpjYf4l/r74UpV1Cgt6HOhcUIwPTiLW1kWYUxu3dctdmg7 TFow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cJ6FIVJ+; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n30si1417249qtb.398.2018.03.13.16.38.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 13 Mar 2018 16:38:46 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cJ6FIVJ+; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:43562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtVF-0007g0-UN for patch@linaro.org; Tue, 13 Mar 2018 19:38:45 -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) 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-Received: by 10.223.135.26 with SMTP id a26mr1986792wra.211.1520981314827; Tue, 13 Mar 2018 15:48:34 -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) 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 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_Benn=C3=A9e?= , Pavel Dovgalyuk 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 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(-) -- 2.14.3 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; +/* 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 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); } -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); -/* 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 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) +{ +}