From patchwork Wed Apr 2 21:23:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 877737 Delivered-To: patch@linaro.org Received: by 2002:a5d:6dae:0:b0:38f:210b:807b with SMTP id u14csp2967062wrs; Wed, 2 Apr 2025 14:24:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTjIaaRpIR/8GPBDl629LeI5EF2dfe10Joo1hyV7/W6NQGG7vjstHExpIybaHdwuQwDoH9dw==@linaro.org X-Google-Smtp-Source: AGHT+IEJKvj5pJ31AvNom/NvtLV6nFDJeV2mr8/Mu9uIij/AJnpYJgm8mZAx32anlpvRXaKe34Ul X-Received: by 2002:a05:620a:2995:b0:7c5:4788:a160 with SMTP id af79cd13be357-7c7664c21c6mr560452285a.44.1743629055343; Wed, 02 Apr 2025 14:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1743629055; cv=none; d=google.com; s=arc-20240605; b=PfaaloKjwI+YhedDrndLBsJmsRA+9g0cOnoPrPzXKB7URZMekduyiEtFG+mu6daxRY n9y1bJhxi9aQHS6SVkEXgdgYg1gLL8mAZLKMRqzJuPv2gTLn4D1N/5K1RfM3YouEHdbE sXfaZXhLpqeyecyoLCH6AYg6ighVoTpXeiAUVkje/1u1B5OnjdgkJ8gNKutwHvADA8T8 Pdo83MfOh/bdm5ywb1xMqrW7tD1FvV+MH3eFfvyXTcGclFMhSz9niI1k0j4p7ZAsV7bn jFuOBQUnWwdiymzgoxNF8RJwEEohQeBQEEX5KfJaYLX4yns+pO5vYhQu6cquzbtr7XrY 834g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WxLf1qzYlIt55rERNGlTsLbACYfcGvHkqll/jBxBAw0=; fh=2WsjhQWI4lQgYgc4VV8bbFA9ixJvTm6B39az9SeRSzU=; b=hYd8Gb+gMXLircSXGEeRHfu6H1kLjXfPM33Z8do1BXDpnINsYg/UmI+LKD/8NUeuTs UOUmQYp6a5TFURJGDC5AGSUu5kJhZVW0U8ccjGWqjNUD4lEd2P01Nyo8tRBvEH1omYBD LZlheuEgSAWZdEgaLG7JsCZERUDOk3CYK5kOyNLdACo6ETU9YoXXZWjKJtGtEVo0wFK/ 6OT7rGGUMaaWJ47bjLGt+7udwobB4296Xkqax8OVxoszGnQu7xxU3lRF+legPi61e7XR FZe9x07LHc2cfW1WuaGwIJc5CIk4s8zYAEWPc6Pr5p0ySDpZxGkE8nvD5U4tXDa3cUXP hgmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fIBI7JHX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c5f76abe13si1177445185a.169.2025.04.02.14.24.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Apr 2025 14:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fIBI7JHX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u05Yr-0007hw-9B; Wed, 02 Apr 2025 17:23:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u05Yj-0007bW-2x for qemu-devel@nongnu.org; Wed, 02 Apr 2025 17:23:42 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u05Yf-00047E-Vx for qemu-devel@nongnu.org; Wed, 02 Apr 2025 17:23:39 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-43cf0d787eeso1742015e9.3 for ; Wed, 02 Apr 2025 14:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743629016; x=1744233816; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WxLf1qzYlIt55rERNGlTsLbACYfcGvHkqll/jBxBAw0=; b=fIBI7JHX9aw4l46E742fvelieY7vOIHfsz4EM0Nwzmo77TgDkURAqs06fFX3qivW2X Sm8eqGihKjVxxji+ZD5MkArxfijJisRtcV8lpk9HmHbthSlGTLKTbhBQiA69j2yVqOSl WhkpxNYrFhddFH1dstYvacWbUACZ6HOIYZYBMvzsdHTtujl7rDu3OizGVNynLyWqxqH1 Y8bNpZ2GWqP9jTpM1rwoSTU8Z6nPPzDPP7i/NRhR2a0/z9dnodTO7vo7L4gnIt67SB7o Vswc497GOq9dQuKqgpitq6U6XnvpT9kPtp/MW9hMfMwdBUli3poKSL24HNO+rUQm6Go2 Vxxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743629016; x=1744233816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WxLf1qzYlIt55rERNGlTsLbACYfcGvHkqll/jBxBAw0=; b=k0ZBuW583K98BU0wbZGi+hsQbqj+mSrBD4wAc3id4+F7h0EGYQcwtScYxs/NOitOkV jEG9t6sqs8gluRe9MIF190wxnOrr7XIIAd4v6RemtYAIJXCbvZsIU9Kb4+O3q0qGREdF srJ8JmXKfmuJj+fmgRHXCB9Rndr7Qfnwd/SDGdcz3/FtNyQZhnu7dj0PhmFwBi77yZmy 5aPsdoFM9knFEtAXnm8G4JHhaFBKXPG253T/P3JqjrXN3iuVYpXXcpi2pDD+92sY0sdn 6M4T3tyUmYE+jBz0ZPy+2mX/IsNi07IGbyZiZDFn9GjkCDZpFr5f3YRUmS7GecWtp7RX Abbw== X-Gm-Message-State: AOJu0Yx17MYpGKpI/7Tysd4TL1YzGBPZgQF9WM/a56uWshHgKs4G6vq9 00kPNZUaBpOmcjSsp9hOxoYzLeQ8b1dt+P53ElD0+FInX1RR3fRflx30SaILPshvIVRMimSSN0y / X-Gm-Gg: ASbGncv2wZPp4D7ObXTQSXINDuUaNTZymodbNYC6IZaXbA/2UR4k8OGyuKqT5gN6U/m ne10y5SyO7Wic5lKKu0gl1xD9n0nylO3c65XE1D9b91dFTtLrDqeXa1s4LbeT38Nv2ZaM4ycUAj QRgTcz0V228Z04GR+i+oRPF36jtpsK4aSKBg6zuls5vVbZQtwSNip8Ii9s3wTM2JCWspekWQ7a2 D1elpqEit5/3fCjAihy2qt3HXOHC37w7AghSyZj98lGsmUhfUPHbMYDAnO1MUBrpAAwDwf6m2yU BpdnsRjsoJ6e/MO1r3nM6YU4FQtYeb3FBz/hrOfRI0AD5rKs3tMg4sP2iuBzozOFF4d242jUzGc Gdz6GquHj1xFK2RPWYok= X-Received: by 2002:a05:600c:1f17:b0:439:643a:c8d5 with SMTP id 5b1f17b1804b1-43e99ab533cmr160367475e9.0.1743629015915; Wed, 02 Apr 2025 14:23:35 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ec16313edsm2515875e9.6.2025.04.02.14.23.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Apr 2025 14:23:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Subject: [PATCH-for-10.1 v2 40/43] tcg: Convert TCGState::mttcg_enabled to TriState Date: Wed, 2 Apr 2025 23:23:16 +0200 Message-ID: <20250402212319.58349-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250402212319.58349-1-philmd@linaro.org> References: <20250402212319.58349-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use the OnOffAuto type as 3-state. Since the TCGState instance is zero-initialized, the mttcg_enabled is initialzed as AUTO (ON_OFF_AUTO_AUTO). In tcg_init_machine(), if mttcg_enabled is still AUTO, set a default value (effectively inlining the default_mttcg_enabled() method content). In the tcg_get_thread() getter, consider AUTO / OFF states as "single", otherwise ON is "multi". Reviewed-by: Anton Johansson Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-all.c | 60 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index b8874430d30..15d4e9232ae 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -32,6 +32,7 @@ #include "qemu/error-report.h" #include "qemu/accel.h" #include "qemu/atomic.h" +#include "qapi/qapi-types-common.h" #include "qapi/qapi-builtin-visit.h" #include "qemu/units.h" #if defined(CONFIG_USER_ONLY) @@ -47,7 +48,7 @@ struct TCGState { AccelState parent_obj; - bool mttcg_enabled; + OnOffAuto mttcg_enabled; bool one_insn_per_tb; int splitwx_enabled; unsigned long tb_size; @@ -70,37 +71,10 @@ bool qemu_tcg_mttcg_enabled(void) #endif /* !CONFIG_USER_ONLY */ -/* - * We default to false if we know other options have been enabled - * which are currently incompatible with MTTCG. Otherwise when each - * guest (target) has been updated to support: - * - atomic instructions - * - memory ordering primitives (barriers) - * they can set the appropriate CONFIG flags in ${target}-softmmu.mak - * - * Once a guest architecture has been converted to the new primitives - * there is one remaining limitation to check: - * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) - */ - -static bool default_mttcg_enabled(void) -{ - if (icount_enabled()) { - return false; - } -#ifdef TARGET_SUPPORTS_MTTCG - return true; -#else - return false; -#endif -} - static void tcg_accel_instance_init(Object *obj) { TCGState *s = TCG_STATE(obj); - s->mttcg_enabled = default_mttcg_enabled(); - /* If debugging enabled, default "auto on", otherwise off. */ #if defined(CONFIG_DEBUG_TCG) && !defined(CONFIG_USER_ONLY) s->splitwx_enabled = -1; @@ -118,7 +92,31 @@ static int tcg_init_machine(MachineState *ms) unsigned max_cpus = 1; #else unsigned max_cpus = ms->smp.max_cpus; +#ifdef TARGET_SUPPORTS_MTTCG + bool mttcg_supported = true; +#else + bool mttcg_supported = false; +#endif + if (s->mttcg_enabled == ON_OFF_AUTO_AUTO) { + /* + * We default to false if we know other options have been enabled + * which are currently incompatible with MTTCG. Otherwise when each + * guest (target) has been updated to support: + * - atomic instructions + * - memory ordering primitives (barriers) + * they can set the appropriate CONFIG flags in ${target}-softmmu.mak + * + * Once a guest architecture has been converted to the new primitives + * there is one remaining limitation to check: + * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) + */ + if (icount_enabled()) { + s->mttcg_enabled = ON_OFF_AUTO_OFF; + } else { + s->mttcg_enabled = mttcg_supported; + } + } mttcg_enabled = s->mttcg_enabled; #endif @@ -147,7 +145,7 @@ static char *tcg_get_thread(Object *obj, Error **errp) { TCGState *s = TCG_STATE(obj); - return g_strdup(s->mttcg_enabled ? "multi" : "single"); + return g_strdup(s->mttcg_enabled == ON_OFF_AUTO_ON ? "multi" : "single"); } static void tcg_set_thread(Object *obj, const char *value, Error **errp) @@ -162,10 +160,10 @@ static void tcg_set_thread(Object *obj, const char *value, Error **errp) warn_report("Guest not yet converted to MTTCG - " "you may get unexpected results"); #endif - s->mttcg_enabled = true; + s->mttcg_enabled = ON_OFF_AUTO_ON; } } else if (strcmp(value, "single") == 0) { - s->mttcg_enabled = false; + s->mttcg_enabled = ON_OFF_AUTO_OFF; } else { error_setg(errp, "Invalid 'thread' setting %s", value); }