From patchwork Thu Jan 11 08:26: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: 124154 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp366251qgn; Thu, 11 Jan 2018 00:32:13 -0800 (PST) X-Google-Smtp-Source: ACJfBosTDQaTv2KcF8aHgVc5z5E3PbSLgUWlyQJleJXiOiOCKSHd35HQhOsCUl9izWf3icMadlvv X-Received: by 10.129.108.216 with SMTP id h207mr9406919ywc.163.1515659533942; Thu, 11 Jan 2018 00:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515659533; cv=none; d=google.com; s=arc-20160816; b=0PC7PNv8DJd1DRuhbGoEQJaZ9pR+YD6l4kYTtNJbfIyBApRFWRnpIp3QmBc6UXgsqW EOgR3CMmBnPVJ5LSC+OQNnYvDzB12w0L6IaQSOmmDDS3EvYCE9lDgL3XYpa/obAR0kgL wLXNbeNuD+pXmpQvJKxZDG4aqdWMwhrRa8O3VMGCQAgGfgWph1ewAVM9pjFllxaS96LM T0EtoSZwtKK4MPP8IuDeNbulBA+qmJ5f6/o8KthJZqhmZFVKC06ElN/XG9HXmZN7xlT1 Hx2Mt9CL+I8Oncps7XxMmNI0GaRcZ9HSHbl4yiOzquDNtlrPLchUbs5NDcfV1cGlXIzf 7agQ== 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=rN8Aroa+6YbkCTzAOPk81AReJSPW+j/3jDOGxZO2wS/taXLDy4ZRph77aJkKIlJFrq ZdvABc9XkE120UpEn/khQIKxXuzQgxSTXsqdKh7yLVIZwmmtCAgsY1z4CEm+F3Bo+p/p zPUkc4aFuM4SfAJb1yiOTWAfdrxy/KYt6jPMO7Tn5r0sad9NpmSF5KztXZ5DAqPmcd0z jk89L3ig5daaU3/px4ZyOCLCx2foVPX7JUC6C+uy9+fn/5aanNJJd2CXW7pNJz2oh/78 g2WnijITaiwfYqomF0QUSeP+196anClU2JK73TX8dQR7CvS3LBTySYN03X+TPSaQlBiA Y5uA== 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 f4si3838252ybn.386.2018.01.11.00.32.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 11 Jan 2018 00:32:13 -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]:53018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYHV-0005Hf-Ck for patch@linaro.org; Thu, 11 Jan 2018 03:32:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYC5-0000mI-SY for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:26:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZYC5-0001ZW-2Z for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:26:37 -0500 Received: from mail.ispras.ru ([83.149.199.45]:41836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYC4-0001ZB-RM for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:26:37 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id EEF8054006A; Thu, 11 Jan 2018 11:26:35 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 11:26:37 +0300 Message-ID: <20180111082637.27295.78763.stgit@pasha-VirtualBox> In-Reply-To: <20180111082452.27295.85707.stgit@pasha-VirtualBox> References: <20180111082452.27295.85707.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 v3 18/30] 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); }