From patchwork Fri May 5 10:38:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 98612 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp50152qge; Fri, 5 May 2017 03:40:32 -0700 (PDT) X-Received: by 10.200.52.157 with SMTP id w29mr7177124qtb.161.1493980832497; Fri, 05 May 2017 03:40:32 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m33si4507408qta.202.2017.05.05.03.40.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 May 2017 03:40:32 -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=@linaro.org; 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=linaro.org Received: from localhost ([::1]:46180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6af0-0003wW-5h for patch@linaro.org; Fri, 05 May 2017 06:40:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6acO-0001kM-Ow for qemu-devel@nongnu.org; Fri, 05 May 2017 06:37:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6acN-0006i3-Fb for qemu-devel@nongnu.org; Fri, 05 May 2017 06:37:48 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d6acN-0006hm-8m for qemu-devel@nongnu.org; Fri, 05 May 2017 06:37:47 -0400 Received: by mail-wm0-x22d.google.com with SMTP id 142so2194341wma.1 for ; Fri, 05 May 2017 03:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1WFbFJNSotD2gTXV1zW0vWegCKhbzIF0g3lK6fXNy1Q=; b=aS3KR0Jl2GevSgXBSaKiPCcP5E0N8qbfSp13J/Nt1aho0JoEjrH9rCTqNIbI4UIG97 eyiAGZ/275/0CHHvzHslduvigz7vkTRmnt6lxjHw3Y9c0w0SSUHoxrFpuw9kjDYKJLLx vkLBmSWnhxopnYCoqIo5qTgrFw2maFsbUprnM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1WFbFJNSotD2gTXV1zW0vWegCKhbzIF0g3lK6fXNy1Q=; b=FEvFVTjTiDu+bLWN90jvEzmQBt36YSlsQV6VUdx6qzcCu6PKkDfyPr5S/pMlY1CugY mwRwP5/0iQKT1y6z2C96vpa0omOPEUPCrSFtUqbeYF2m/9b1xfg8fnijVAZkGsHmchp1 PVH35ZRV11aoN/gt9OsgYBKWfXaxgqS9+S12Efwfsl+cv2iTAhFY7Lop8Cz9IAlScswb 16/fiSVsyEOLXO3lbdNP3H65B3eKiM98dPmDL/v3W1rNuWOmit+qY6GOx95qxwCQVVeG Kr2mU/aJbJtMLOVwf9mQH1fXwlJ5UAhV8l23pVfNG6lppQLE4Mg2G4Fh2MkOh5iie10U SuSA== X-Gm-Message-State: AN3rC/5Hf6DihN1SoHaqZudfAZKxy0Bv2TnKvGj/0RNR9xIDO8hTqIBF 8caYNPvXS9JE95Ho X-Received: by 10.28.16.212 with SMTP id 203mr4479186wmq.26.1493980666192; Fri, 05 May 2017 03:37:46 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t26sm5136118wra.43.2017.05.05.03.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 03:37:43 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id EFFBE3E01C6; Fri, 5 May 2017 11:38:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com, boost.lists@gmail.com, pavel.dovgaluk@ispras.ru Date: Fri, 5 May 2017 11:38:17 +0100 Message-Id: <20170505103822.20641-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170505103822.20641-1-alex.bennee@linaro.org> References: <20170505103822.20641-1-alex.bennee@linaro.org> 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::22d Subject: [Qemu-devel] [RFC PATCH v1 4/9] 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: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- replay/replay-internal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.11.0 diff --git a/replay/replay-internal.c b/replay/replay-internal.c index fca8514012..157c863e25 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -179,13 +179,24 @@ void replay_mutex_destroy(void) qemu_mutex_destroy(&lock); } +static __thread bool replay_locked; + +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); }