From patchwork Fri Jun 6 16:44:10 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: 894471 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:ecd:b0:3a4:ee3f:8f15 with SMTP id ea13csp615116wrb; Fri, 6 Jun 2025 09:47:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdrIIl1szwwTYT+Oyl5ttNPpIfYd70F0ScldIxp/BO439wFBYKypxuSMChicrVqMQZDzqCPA==@linaro.org X-Google-Smtp-Source: AGHT+IEpkldjXvkaTol4EKXu2Kbq5fiJXbCMm9TGzlTHj4EoEr+ij1wx5wfbiLX36efzDPVWhkAq X-Received: by 2002:a05:620a:3948:b0:7ce:e916:c953 with SMTP id af79cd13be357-7d229fa66c9mr620927985a.5.1749228453088; Fri, 06 Jun 2025 09:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749228453; cv=none; d=google.com; s=arc-20240605; b=Kq+J/fxZ/3lNTDGG+DFRDQ/JmkNlcmmNM4E4VumcJpcgm8HlQvjzbXq1kVAZYPbxvk aKqHK8QInPjo38myXK3WKP7cewjR2yWeRSSCRcTtqPEuxcuW/sPagl3lb5H2HiQFy9ZJ 0JLi29jK2ln+a5NWG6VjgLKZ4rvH0IJx/7O8M2gwfigqLo8yUbxE/SAIbd/DIdc3y6vv vIjOZm4iR750rFQaQG0iEiI9rXAUONKl7QP/+mXmGSu92aSVamkdRmES+cvSJRnSzW48 l8DcWt1WdM10GCYMy523UOu/gFfI/ivJbyzzuBb9SoAe31SuET64xoRqN6OFlemRVbVZ siCQ== 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:cc:to :from:dkim-signature; bh=JIuklLgT7yxDr5xUfy1gGIRFVc8VIMyOClNRwci8w2E=; fh=t8eU813ECvXfe9r8ZA9SxVxC1Zyy8joF+mf6kT3Em/U=; b=VGjBqvUDDoqxHCJ3KitccVkN8+VAx/EDvQyVW8PspsnW6QEkwZwmx0bGHcyw2geLnh KuHQjkGa67wY6MsrdYGLbuK4KiR8wmrXhOhiH9DoTJvp2mYprL+BijJCyOnN238rGLvc 4APu+Mu9Ozv0b9ctA/LgHsegOQwJ/pQGZL2/UOA5rSeJZrPGdAGyaJgUVbBo8hQ9anmH ve8HfOkf8/k5XIXQsUyOd7XsF+GEVlsTX+7KqCuBOtLN6Y+8Lew9YDkj2QhPTf2e3+pv s4R1m8aP5AVF9dI0kPYZa1kBHlzno9dE12Lky34S9AdHUtvH2TvfLCQwzh15cI0Vr2Ir ZeYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="c/Xcs4xj"; 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-7d25a5336cfsi206693385a.140.2025.06.06.09.47.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jun 2025 09:47:33 -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="c/Xcs4xj"; 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 1uNaCi-0005xv-0t; Fri, 06 Jun 2025 12:46:04 -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 1uNaCR-0005XD-VZ for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:45:49 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uNaCP-0003Qd-NJ for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:45:47 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-442fda876a6so19365765e9.0 for ; Fri, 06 Jun 2025 09:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749228344; x=1749833144; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JIuklLgT7yxDr5xUfy1gGIRFVc8VIMyOClNRwci8w2E=; b=c/Xcs4xjeEG/V/CEggSm4wtZHaosVaCBDWRKYS/d5cN/BchFpR54Cfqo32eLcdtcH8 Ocb7I35iciCwoz4X96aoYFLpXScMThPaXD8HSU9bFZkvU6/6NMFpImRxcSawNshGcl/k ORg8REzC6RFGWpn16hnTYNk0d6g26+DOgQFkIEdCPkK0RXp/U6mJqh6OJvBqFtiANWkg SeswCruf+1Lhi4jhUxCm0yke5lP21gxXsG/c0vRivQfeEGF1Rpb97Pzd9b+T64UOkg0N GrdrddTDU/YeyT9phq44g6sXCKjlkI8jWXw9jhGAI8BvIvK36l7Q9CrAS6V7eIbpOwS9 TsGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749228344; x=1749833144; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JIuklLgT7yxDr5xUfy1gGIRFVc8VIMyOClNRwci8w2E=; b=Kl59q0+LM/yJjKJ5zg95z0L2GpaIK3oXFcWRXx3BqTq2+KZWLDValFkw60XwiPLcmO riEZ0MSPjm8ZhBrbEV1FAExn3JAT+sbTem3Kg4QStVNYZAxde60zpc4Gzt8Q/aAWFTi0 gQF/BqRoQ7qnkx1Ksf+E5yKSz1Bbn4GJUHIghfGmj0f4GEvRKSOO1Kq/hSfAVsGctxla J9vJddwkQeeouNs/AfPP3tdL7erAB6/qawhBlR5RLk1OXWIE5mcmN1DVAt3wyKS9GQrQ hqJZ5qwDP37du0Pcy8wTMNC+DeVbEhtaVJEDk1mmCPwqKNG04gA8a/OWsBWGO4yr1HN+ CP8g== X-Gm-Message-State: AOJu0YzFlGsUDJFV0sznHXzCb0gJWCbgaXnQmZVwQPoAmGMP/gMJ5XH1 2IFwj16RTYx5gFT5kcC5bJd+G9TAt902AqWPK4yMSz0Iku6QeJYeWnnFZ8NzZrif+UDDYK/3hcT bjUEhrvUalg== X-Gm-Gg: ASbGncv0/hbvRk/KETXmBwtQzMhBX0IqBtf30/hr3+6n8Dum33rYaN5lQdR2rIbUMze yAeg9fFKq2u/Z6TzjPqPnLdAjI/DuOzU1SSWE/c9n5whPWgoqme+2npqBlXrNlVNJ5L4lLgQOBV doFeMwuikzpgCmp1EjNZ7SRy1gqwRQOPvqzzPgqK3vYLrdLK2NVr3WEgNv0VmJ/rWkamJYkH28F K0vwxNUImuDDkwH8UpLx56UtLTf1xz/a0gQJdTU5oUBizKXM/naFIKJWKTlCJcD6z2Z7TLFXm5x MRrjKbM+kgcW+aztD/C75MnubE2pyylMBkONyguXkrGa7CZvzIRzQLoziQ5r9gT460Vo3kt6VeV 9xRNMAsAO70Ew9Yb/FI2Sb9fIr0pxu9eDvlMx5Q== X-Received: by 2002:a05:600c:5492:b0:442:ccfa:1461 with SMTP id 5b1f17b1804b1-45201357413mr44755445e9.13.1749228343874; Fri, 06 Jun 2025 09:45:43 -0700 (PDT) Received: from localhost.localdomain (59.red-95-127-62.dynamicip.rima-tde.net. [95.127.62.59]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4526e163113sm27660095e9.18.2025.06.06.09.45.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Jun 2025 09:45:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Pierrick Bouvier Subject: [RFC PATCH 11/19] accel/dummy: Factor tcg_vcpu_thread_precreate() out Date: Fri, 6 Jun 2025 18:44:10 +0200 Message-ID: <20250606164418.98655-12-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250606164418.98655-1-philmd@linaro.org> References: <20250606164418.98655-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 Factor tcg_vcpu_thread_precreate() out for re-use. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops.h | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 3 +-- accel/tcg/tcg-accel-ops-rr.c | 3 +-- accel/tcg/tcg-accel-ops.c | 7 +++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h index 6feeb3f3e9b..129af89c3e7 100644 --- a/accel/tcg/tcg-accel-ops.h +++ b/accel/tcg/tcg-accel-ops.h @@ -14,6 +14,7 @@ #include "system/cpus.h" +void tcg_vcpu_thread_precreate(CPUState *cpu); void tcg_cpu_destroy(CPUState *cpu); int tcg_cpu_exec(CPUState *cpu); void tcg_handle_interrupt(CPUState *cpu, int mask); diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c index dfcee30947e..462be7596b9 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -133,8 +133,7 @@ void mttcg_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - g_assert(tcg_enabled()); - tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); + tcg_vcpu_thread_precreate(cpu); /* create a thread per vCPU with TCG (MTTCG) */ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG", diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 6eec5c9eee9..fc33a13e4e8 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -311,8 +311,7 @@ void rr_start_vcpu_thread(CPUState *cpu) static QemuCond *single_tcg_halt_cond; static QemuThread *single_tcg_cpu_thread; - g_assert(tcg_enabled()); - tcg_cpu_init_cflags(cpu, false); + tcg_vcpu_thread_precreate(cpu); if (!single_tcg_cpu_thread) { single_tcg_halt_cond = cpu->halt_cond; diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index da2e22a7dff..e58e1c3738f 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -41,6 +41,7 @@ #include "gdbstub/enums.h" #include "hw/core/cpu.h" +#include "hw/boards.h" #include "tcg-accel-ops.h" #include "tcg-accel-ops-mttcg.h" @@ -68,6 +69,12 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) tcg_cflags_set(cpu, cflags); } +void tcg_vcpu_thread_precreate(CPUState *cpu) +{ + g_assert(tcg_enabled()); + tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); +} + void tcg_cpu_destroy(CPUState *cpu) { cpu_thread_signal_destroyed(cpu);