From patchwork Tue Jul 5 16:18:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 71401 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp458551qgy; Tue, 5 Jul 2016 11:53:21 -0700 (PDT) X-Received: by 10.55.200.137 with SMTP id t9mr25663092qkl.128.1467744801547; Tue, 05 Jul 2016 11:53:21 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t68si3060361qka.257.2016.07.05.11.53.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Jul 2016 11:53:21 -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; dkim=fail header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKVTE-0002Ll-Mx for patch@linaro.org; Tue, 05 Jul 2016 14:53:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKT3F-00079g-VQ for qemu-devel@nongnu.org; Tue, 05 Jul 2016 12:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKT3D-0001xa-VG for qemu-devel@nongnu.org; Tue, 05 Jul 2016 12:18:20 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:37656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKT3D-0001xM-O3 for qemu-devel@nongnu.org; Tue, 05 Jul 2016 12:18:19 -0400 Received: by mail-wm0-x233.google.com with SMTP id a66so159713475wme.0 for ; Tue, 05 Jul 2016 09:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R3Dw+lGIMobLN1wXlrVVhotVnFx3Z7mjD25DehFdogo=; b=VWNUHs+SwhQs2+uLtPBGw0DNC42Mga+4ZTmFnnP0w2Ojc5i49pJvcEyCnDdZA8Ja5H 8cmAb5FmC25HN4mWQorgEwEEhOg7fcQ1QTbEY917A4bZ3BZCHHjnOFpVm7ihwUF2sits NSbC6wiaLFYg+/8SiNqxpaj+Ai7f1o7NinMuo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R3Dw+lGIMobLN1wXlrVVhotVnFx3Z7mjD25DehFdogo=; b=fCqXZF0xgblxiSEvJhNOTJiQZZZUptwrbahYlCfTawERbYV7yY7hzqmairDyCd6zSn KFC+cbG0Bb2IuJRiH0FJQ89GlIR7yAiK7V7LlwbbKLHKDomy1cawC4c9nfCrm7Cz3DRK gUpzfTbYxSLHaqeVYxscjvzYEqltN8cR0e8DU67hACmfm/w+XBspNHzfJ01B4xV1ZiiE GWXTySvdDWpv+IdM6cQR6bg77l/GyxRiwV6BPynVvdVh8pkFQP1+7aqODGoFc7ZzsYxX JcKuMJBpg65yg/O+P1iKmYfEyZsa/D7flForSAufVJIWkdsdKJiN821D5FxoVW2HG/0w i7nw== X-Gm-Message-State: ALyK8tIXpE81oRD5iGlq0Qi5t8ubr3IUwvWn2Mfz1hTqgBb5SOT/zYM8lbcce3YczlmrGFK1 X-Received: by 10.194.104.134 with SMTP id ge6mr18527799wjb.157.1467735499110; Tue, 05 Jul 2016 09:18:19 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b200sm3431353wmb.9.2016.07.05.09.18.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2016 09:18:18 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id BE2A33E052A; Tue, 5 Jul 2016 17:18:17 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org, bobby.prani@gmail.com, rth@twiddle.net Date: Tue, 5 Jul 2016 17:18:15 +0100 Message-Id: <1467735496-16256-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467735496-16256-1-git-send-email-alex.bennee@linaro.org> References: <1467735496-16256-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::233 Subject: [Qemu-devel] [PATCH v2 5/6] tcg: introduce tb_lock_recursive() 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: peter.maydell@linaro.org, Peter Crosthwaite , claudio.fontana@huawei.com, mark.burton@greensocs.com, jan.kiszka@siemens.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In some cases it is useful to have a recursive lock that can be safely taken when nested in other critical regions. Rather than make all tb_locks() recursive having a separate function serves to notify the reader that it explicitly a possibility in this case. Signed-off-by: Alex Bennée --- tcg/tcg.h | 1 + translate-all.c | 11 +++++++++++ 2 files changed, 12 insertions(+) -- 2.7.4 diff --git a/tcg/tcg.h b/tcg/tcg.h index 66d7fc0..62e4ced 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -647,6 +647,7 @@ void tcg_pool_reset(TCGContext *s); void tcg_pool_delete(TCGContext *s); void tb_lock(void); +bool tb_lock_recursive(void); void tb_unlock(void); void tb_lock_reset(void); diff --git a/translate-all.c b/translate-all.c index 97e834a..414bc7e 100644 --- a/translate-all.c +++ b/translate-all.c @@ -134,6 +134,17 @@ void tb_lock(void) #endif } +bool tb_lock_recursive(void) +{ +#ifdef CONFIG_USER_ONLY + if (have_tb_lock) { + return false; + } + tb_lock(); +#endif + return true; +} + void tb_unlock(void) { #ifdef CONFIG_USER_ONLY