From patchwork Tue Feb 27 09:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 129752 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1198003lja; Tue, 27 Feb 2018 01:54:46 -0800 (PST) X-Google-Smtp-Source: AG47ELs/rxgR40FYOyotbjspgV3jzhw+K9p7CBt95/Yzu9jNYdCXt0QXY+KDPMp8G3OMRoe2bsKw X-Received: by 2002:a25:dcc5:: with SMTP id y188-v6mr8876588ybe.385.1519725286492; Tue, 27 Feb 2018 01:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519725286; cv=none; d=google.com; s=arc-20160816; b=s13POkWa1xKydeNsR1nZAUjDrZTtWmzOGEpGCqLkVafntm9K64wgaY5xRWGh+W6WSr 6Ix/DwK4ZECffwqkauBuofQESTmSOzIoI7OSvbkF3BNHqS5QJex4cfIebVlN9vzSKCtM Cz6+AXYnsabsP8XH3LsvBhfZoEKnYgqBQtF91BcmYIRc9aecqR+DCCVgOSrgM0Z58DyD K7f07bLhT64XxI6saN/0PS63lMJvjDIGewuktolaRA/GI2+nbYv2DEZCyJsSVZQ02t5K vsCVSHhvBpt9rRXcOCNy2AwNGO1SvUaC6NSICZa2090k4nZqw+xAKukBYVq4vadO0sNe 0gNg== 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=NxMPn59v/BPXue/8zD6loH8ClpLPxi3WzX9vp/j/45w=; b=ZY9byAibtJXKgqu4GZRGemlhLkYK+zvF6JTR/ckuA4rX1XfrS73CIwWDGWlQLGFuDm 6RaqaAE9EVE5A1UfDqfXTBzML8Cu5nMuFHZ1ZyPIZk9MVAONHUEDJjheg9atgdGM/j6e VXYqEAujWU4gtsn6Xz1Q2BxP++mxVyYha0D9gkToqfLN1tfsOHG8KkmCQS+q+PJZACpn +g/h0BauGzo1/c+DSOhJfZQZdwhrOH2JYRzpxOCQ5izvzfjp7ryxEnjjVNiMkEobrR0N I+otQwY8e2Jwzcr0l9s/uVZCBRBuWE5NeNo85REwtmLNYyZ7JNbk2pA/L38ouHgU+j7R c2ig== 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 d4-v6si1861008ybo.281.2018.02.27.01.54.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 01:54:46 -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]:35817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqby9-0002sU-Sg for patch@linaro.org; Tue, 27 Feb 2018 04:54:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqbw6-0001Cy-12 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqbw5-0004tS-4M for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:38 -0500 Received: from mail.ispras.ru ([83.149.199.45]:57432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqbw4-0004tB-Sd for qemu-devel@nongnu.org; Tue, 27 Feb 2018 04:52:37 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id DC27754006B; Tue, 27 Feb 2018 12:52:35 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 27 Feb 2018 12:52:37 +0300 Message-ID: <20180227095237.1060.44661.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 11/22] replay/replay-internal.c: track holding of replay_lock 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 This is modelled after the iothread mutex lock. We keep a TLS flag to indicate when that thread has acquired the lock and assert we don't double-lock or release when we shouldn't have. Signed-off-by: Alex Bennée Tested-by: Pavel Dovgalyuk --- replay/replay-internal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index fca8514..0d7e1d6 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -169,6 +169,8 @@ void replay_finish_event(void) replay_fetch_data_kind(); } +static __thread bool replay_locked; + void replay_mutex_init(void) { qemu_mutex_init(&lock); @@ -179,13 +181,22 @@ void replay_mutex_destroy(void) qemu_mutex_destroy(&lock); } +static bool replay_mutex_locked(void) +{ + return replay_locked; +} + void replay_mutex_lock(void) { + g_assert(!replay_mutex_locked()); qemu_mutex_lock(&lock); + replay_locked = true; } void replay_mutex_unlock(void) { + g_assert(replay_mutex_locked()); + replay_locked = false; qemu_mutex_unlock(&lock); }