From patchwork Tue Oct 31 11:08:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 117573 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3815452edm; Tue, 31 Oct 2017 04:12:25 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QGPWjpClOvkGD4VWfHyU+FwwHu9V6YQ9jloLYzZZ+O5+ijYR+bygHBCQR2wQ0upeqFmCxD X-Received: by 10.37.216.208 with SMTP id p199mr850333ybg.429.1509448345833; Tue, 31 Oct 2017 04:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509448345; cv=none; d=google.com; s=arc-20160816; b=Ok8ngM/Xatw4HXbI3p6klqZT6EP/L9xhVQLE47h8uuOFD4yjny7VMRVIhFWkooh2GN 3O05i1RaofrYYLTdNlKYcwhJ8s7VE9yvykjNzSfYeanEzmbKqEot7iET/CjB61/eJ5iL wz7Mx1kUOuQhjwv/OTnUE4z78NYcRVDPFS6roNnFS4nrNiPpUjaeBi6h/MXaDws2kQae y47p5oObo85FR90qd5sNsNgTXajX9UhmVuOqTWwkZOeMw1mS82/7fUsYgfBW9oQ6p7mc MBQ+Z3F1WcbT0hbx14QZhCbkW7nzbcdvhLD6mrkeVJp28Y/oSA6EEfdtCmhC2tO6GJ9/ CKHg== 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=pF0QrcMOQzBo8+2c/JnytGGHLAaegxxMsZDOaVmEl2M=; b=Gblr2U24vIYpcduXAU1I0UL4Jzo6PQSkToI7jVDSgnHaDrgfUA558cuSQeavju+OMs EGLtVR3ubZDN0mYpzKICZLmiQnoJ9bGAA6L3xz2eb3m6s5Na8ARssf23PXZdoaCuFIYX /j4Cw7BzCIFWhJ/w6uFQgmcmpMAI10UyM8YZ6MxU0Go3lewdXF6oPLfYBCg/VIPnzjOQ S6DOjXmnI4sjcWqm1M7HHusIqRaMrJYhZosuyPqbZNO5fuSTQ5oVtlp0xmHw5Fs9d4Vn nT2mXnakiN2leswKFTGDfpaDBEXo20wZpPCchOsB79Kez6+e2KmrYbzonKhDYrQxi6aw 0SZA== 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 s7si330275ywd.729.2017.10.31.04.12.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 Oct 2017 04:12:25 -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; 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]:44805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UT3-0008NA-5Q for patch@linaro.org; Tue, 31 Oct 2017 07:12:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UOs-0004sc-4z for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9UOo-00075g-CK for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:06 -0400 Received: from mail.ispras.ru ([83.149.199.45]:42330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UOo-00075A-4K for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:02 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 79CC854006A; Tue, 31 Oct 2017 14:08:01 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 31 Oct 2017 14:08:02 +0300 Message-ID: <20171031110802.5836.80558.stgit@pasha-VirtualBox> In-Reply-To: <20171031110641.5836.43266.stgit@pasha-VirtualBox> References: <20171031110641.5836.43266.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] [RFC PATCH 15/26] 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: dovgaluk@ispras.ru 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 --- replay/replay-internal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index fca8514..157c863 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); }