From patchwork Tue Mar 13 22:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 131542 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp204761ljb; Tue, 13 Mar 2018 17:13:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELsPCYfzCEVyqBEMkIAPqNsZ/Fy9IDD2lUhoxOId8kXO8e3KOdqVy3FXDZKvSgDuOlAjifi+ X-Received: by 10.200.112.91 with SMTP id y27mr4042883qtm.295.1520986410204; Tue, 13 Mar 2018 17:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520986410; cv=none; d=google.com; s=arc-20160816; b=JnQs8x4AMUrxdsTYojCFuDymqy1uqKAmd1EtYWRkJcGsegclij5p3uRRQr9cXd5Mcj JtjCB2jrQh15srGcz4afA2e7Ebo4rXx2k9ILM4yZutlVTGXaguCFp4Ha9Fa8ywkr83ff Ec3LW557Ok8MRoX6y2FwILtjNynh0c9SKt9Z5gUkPzWO5U1Ij9fRcAEOXfoxl05MUByf nb8Yu8x0yQp10/SkZhOsgIDvg/1fsFoMqLnDwaZvfveR52Cpf9YJZ3J1g8RsRF5fPmUD E/QSESrGPgGbTLK84zCK2OHxIEjGwb6ofS9gO9GzeE/K22nEjqZ8rrYAITF7S0qOXtVA J+bw== 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=Kwu9R4Oqu/XdgRnje5Q8FcF8hFd8m9i/JhVoPskPzvQ=; b=wSemOA3VtCAYIpDPbUnCgc57Q6nndKGEm7ILHoLm4YkjfHJ0n04EdzBYdEPkBr9GVs N1ceahsuXO+aQgZshAfZ91tbSXm/ZCUUPYXb9//nWod66mdreCL1GCXpbWcImYxqzEPD F/ueqlQfpkGumf1Y3+GAZAWxlf2t0HF2cEUxTMJeMgQbdXwoCxr6xR4/b0mOGxKlnCED bXoD5G9OZQqLeCnn0HgAORiF+WaJ0V2wbMYSJ7SWeaPZhrVsYjdfwL1cT0WE38D7Os6A 6BOlTQe6LxJy6BSrj8JcwuNX9xK2ZaN2ONjKw4z61hbYqQPL6TxB5Ggz1Zt3/M3pxPXQ N7qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jepM2SVe; 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 6si1412664qto.475.2018.03.13.17.13.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 13 Mar 2018 17:13:30 -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=jepM2SVe; 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]:43507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtMi-0000c7-Qf for patch@linaro.org; Tue, 13 Mar 2018 19:29:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsii-0006Mh-Cn for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsih-00049M-Bw for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:36 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:37059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsih-00048O-6J for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:35 -0400 Received: by mail-wm0-x244.google.com with SMTP id 139so881430wmn.2 for ; Tue, 13 Mar 2018 15:48:35 -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=Kwu9R4Oqu/XdgRnje5Q8FcF8hFd8m9i/JhVoPskPzvQ=; b=jepM2SVe01KD/NOj0IQ6G4vnE5Joqti+6K5tT7WuQ++XgCN2rW7hgujMiVN5NjYAov 9sHlGpHFxgyHmLwW9W77P3I0x6uv+Np9GeCn5tPW7peIQl19K1IodkAqlTfDIhAKJvKL 9OWR4jpVonw9Pduf2XS0B7ibBMdYPtNrnP9Ded1vYTOxaFHPceYCun3XeYmV8fGAUPwg iIXCQbKqLFDYtd10AhM1HLokUCTpVhjEIAam0GEOkTCwDs0aWDUBjRje1pjmQCM3eG0Q JkLBrNGtAlncs0PPXutFbLVJARcgJyyqISc2Z9/4AWuE4cSrZV7QwUPvM4ePsBspgIKm pMsg== 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=Kwu9R4Oqu/XdgRnje5Q8FcF8hFd8m9i/JhVoPskPzvQ=; b=SPAItG5r07TxvrHIbPovY3Z/7/dCKjJ4BaGhR14InKv5R0+llzDreXDowTT/Bjh8+o oyAGlcr4biscp73+9rS165WfGOzZDK1ZaK8KBG+udaEMkYkqtdwNUoIbDxLxILlDoa8q Vv3uZteVUvXTod2ddPD9DSKMG8nx9hlCIcToNaho+u8iiMc1BM/Wvo4urpwRorf13rcw GZNyBnAbHARgvE58tEI2K20s+Gavz230D1+0G+fG5X+/WD3DvHgcZ8SwLNv5AtAP6SyP MC8meK3m0lnFvtXa/bLMD27qL9encvBuxa3zUFdRueCJc0REvBjib2a8xYRgofch2snu zgpA== X-Gm-Message-State: AElRT7F3/G+O6Vi14RFeCvLd2+Ul157wR0x1RWW5xs7OyZepHyggKNkR JO9A1lEYL4itip7odOerSgFW6glC X-Received: by 10.28.144.5 with SMTP id s5mr2084180wmd.98.1520981313802; Tue, 13 Mar 2018 15:48:33 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:09 +0100 Message-Id: <20180313224719.4954-60-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:c09::244 Subject: [Qemu-devel] [PULL 59/69] 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: =?utf-8?q?Alex_Benn=C3=A9e?= 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 Message-Id: <20180227095237.1060.44661.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- replay/replay-internal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.14.3 diff --git a/replay/replay-internal.c b/replay/replay-internal.c index fca8514012..0d7e1d6bc4 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); }