From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Pavel Dovgalyuk 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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC PATCH v4 15/23] replay/replay-internal.c: track holding of replay_lock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, boost.lists@gmail.com, quintela@redhat.com, jasowang@redhat.com, mst@redhat.com, zuban32s@gmail.com, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, kraxel@redhat.com, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, alex.bennee@linaro.org From: Alex Benn=C3=A9e 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=C3=A9e 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); } =20 +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 =3D true; } =20 void replay_mutex_unlock(void) { + g_assert(replay_mutex_locked()); + replay_locked =3D false; qemu_mutex_unlock(&lock); } =20