From patchwork Tue Jan 23 08:54:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 125490 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1635784ljf; Tue, 23 Jan 2018 01:09:58 -0800 (PST) X-Google-Smtp-Source: AH8x227nbcEJ62vQpyOC4Ab7PF9bHhNwa2hJTCx9ZgSFp5KLySOHN80fvOaBpHkuApP3CRbgWOjV X-Received: by 10.13.221.211 with SMTP id g202mr1744382ywe.134.1516698598083; Tue, 23 Jan 2018 01:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516698598; cv=none; d=google.com; s=arc-20160816; b=d47ew3HvhIkoJcQ3sw/SeHxZYZOixTVgJGhuVm8UNHhl+HQ2UANwoTFoBoto8Ydom3 oTKsNK0Yy3JgNkC4TyI/eb3BXg5CEbks67VHtqA4FlnfYLP+BhpPa/+Ihq1v37hsHn6I OwbIoVMTtVCcKhicaqfPLOlpoenDBUFAdyc/4hd5FdfpNDMa533mQG75E0I+n8s1AVS3 mxLuNPe7MO0vVrkb62DwMBbkrmZLktMMcColnSz1vOThCRxBvEmbR0m/vhg0MvpN8SVx EWdTS+3Mp3kujCVoUakk0NA1OzxNJyUMdFsoIcb4Y+iIjve7vKNxKNeQ1dQIXeJxoGp4 QnTg== 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=ojZ3xwW7SZ3qXlFlE9UIGPYeYK0OwSzlNRlNQlIVsDw=; b=SOl9zGsy/OuTiBLsBUV+aJNaoPaCcRRqW6gJsXvJu4jifQdwer+c90Kv3KBBUtdY7q auP5OzUcowHfBWYWDVws021pSD23LZkhZ3zF+7BpWWkUa6JNJfCR8WZ8CMqAXREfDiu0 l0SxoktltYd7a/4311wAT7mYjVuDTnSNImf3ccZIa/4hzU4L/bE3jn9iC+NWrQAYi8DX xbuF1GVMggoPtfhaVbhn2mRzo7TScC0frneekjgfV5w8egJrNY1KPjbsSdMTTPtaj0cD hr1iA8RcMK+bQBaLXRGV5oc26rYJqJEu/jgoOjhPg/PFIAoQmjFJ6et7x3TzfV4zPypM j+tg== 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 b69si3935253ywe.676.2018.01.23.01.09.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 23 Jan 2018 01:09:58 -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]:46170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eduab-0006eD-GZ for patch@linaro.org; Tue, 23 Jan 2018 04:09:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eduLs-00023L-CB for qemu-devel@nongnu.org; Tue, 23 Jan 2018 03:54:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eduLr-0000Gj-Le for qemu-devel@nongnu.org; Tue, 23 Jan 2018 03:54:44 -0500 Received: from mail.ispras.ru ([83.149.199.45]:57310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eduLr-0000GQ-Bi for qemu-devel@nongnu.org; Tue, 23 Jan 2018 03:54:43 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 5B15054006A; Tue, 23 Jan 2018 11:54:42 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 23 Jan 2018 11:54:43 +0300 Message-ID: <20180123085443.3419.1663.stgit@pasha-VirtualBox> In-Reply-To: <20180123085319.3419.97865.stgit@pasha-VirtualBox> References: <20180123085319.3419.97865.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 v5 15/24] 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, pavel.dovgaluk@ispras.ru, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, zuban32s@gmail.com, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, kraxel@redhat.com, boost.lists@gmail.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..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); }