From patchwork Fri Jan 19 08:44:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 125124 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp199537ljf; Fri, 19 Jan 2018 01:05:42 -0800 (PST) X-Google-Smtp-Source: ACJfBotiszLQl8hT+nuGy0iD+CDrEs3TrfXI5ZW5opuNx64fDqXsO+lt0W0UXTjHOmjpEGHQLCx3 X-Received: by 10.129.91.84 with SMTP id p81mr8564224ywb.278.1516352742221; Fri, 19 Jan 2018 01:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516352742; cv=none; d=google.com; s=arc-20160816; b=YKUcdS1DD2tMpEiTPwKP1USjImWMi5qKDl1/ENq5QjZytniWe03/JNPmhaarmYWhma 0bqh5ZF0RGmmkTfhwRDmKgkNjuPqQwdCvIHCP8qt3FFgpTBx0q44J0QetCMKbin/+ja7 c7qiJfPVmDSSpqkzpzXBDt8Rux46qqo1MJ42s6TVngX4EQXr+I8R+UF5vAV391/Y4/66 jfeNuJCHED/quKTwhvchF6Z/LhPsYjNjZQAOU11QldI+bzIyBYlq8CVYeeG3WCt4d7se ZmSi1HnPiJ9rFRdu6YuNzdXGakLOzK3yfMaBhtKWX4+V35/zEGsrIQO/sd7sxx5CvZH9 zp+A== 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=Jgd6CitYF78f9/UC1SYrD3L8QE+BrEhug2J8OKUl2H815yEtLr5XZ37zFgg2oNCyLW RE/XQQf2YW7osQegKjjAuolweTaV13dcqytvPxJgmaDaSUWKL4fMUQT7CMftFrCJrWac zOsCR0J6VvZCOuTp0OozvVQRbuL/Uy04eeR3gza4T5AMsWsIizcHcJHDM7BmyG7Dti8E TbRYzehIkaccXaZr2sZdjwJHta6CqdCMBNCI8z9fWf1NJnytmFNuUAovAtPJuPB1zjJH LInip6gl7FGjdAij3fdpIU2H7VVJP9c6DdDxZD+zAiTbCEXGZBvAKE6E5nG80lb32m3B udvw== 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 v68si530570ybc.230.2018.01.19.01.05.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Jan 2018 01:05:42 -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]:36118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecScH-0001lX-LT for patch@linaro.org; Fri, 19 Jan 2018 04:05:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecSHo-0001bH-Ag for qemu-devel@nongnu.org; Fri, 19 Jan 2018 03:44:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecSHj-0005cr-FB for qemu-devel@nongnu.org; Fri, 19 Jan 2018 03:44:32 -0500 Received: from mail.ispras.ru ([83.149.199.45]:53754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecSHj-0005ce-7F for qemu-devel@nongnu.org; Fri, 19 Jan 2018 03:44:27 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id D41EC54006A; Fri, 19 Jan 2018 11:44:25 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 11:44:30 +0300 Message-ID: <20180119084430.7100.10004.stgit@pasha-VirtualBox> In-Reply-To: <20180119084235.7100.98318.stgit@pasha-VirtualBox> References: <20180119084235.7100.98318.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 v4 15/23] 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); }