From patchwork Fri Jun 6 16:44:14 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: 894463 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:ecd:b0:3a4:ee3f:8f15 with SMTP id ea13csp614761wrb; Fri, 6 Jun 2025 09:46:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXOEzqznN9PCeBjUNwnhe7K/lDB2K7AWbz2ebeifbZfr6eqHnT7EqUuschwmsUlB9kkjx2nQg==@linaro.org X-Google-Smtp-Source: AGHT+IFv38bYv8cNq0z1Pjdhi03T7/465ACqyzWFaAvR7LHkc5/SEq/gbSAVGP4OKZhK6Gj/lL4t X-Received: by 2002:a05:622a:4d85:b0:494:993d:ec2f with SMTP id d75a77b69052e-4a5b9e18965mr66611091cf.12.1749228400772; Fri, 06 Jun 2025 09:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749228400; cv=none; d=google.com; s=arc-20240605; b=Z4tq/ZyV09GGNQvW6nC/4RIKD9khVco0ff9CDbRHjdGPWFzHPjTdeU+innpmEa6aFH G+fY+Y7JjFnbEqZQ7sJwlHOA7ue/FIrJ8qT8Jsg+ghmtcD0KLOCZTDWnUGRa2WTuGwmr ayjnM00DJW2Sch5j3VKVBwBeTaJHgfI10aWabj2C7OMk+o6gKMk7wZsgsYQ/xGGsmCVN 1A2VdtqSVNCjOAawUVAdPX2f5TIiQxY9jMlbId7joCTnn98KDhfxVNv5sJYY4wnPJr2P 2KTVEFbnZJR9koeJvnXxQY01Pm8PnaS4IaxHCG7hUH4QHZTF/NvH2f0T3b0gPphTopyk 0pUw== 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=u4qlPyVP19TOs/IkzQVFEBQPCs8QxMwe6aQWLV0wFtw=; fh=t8eU813ECvXfe9r8ZA9SxVxC1Zyy8joF+mf6kT3Em/U=; b=DWzvQDuFGsU6knLXza/6vB+GZvwnDv64H6V+5hWkvG7OYBiVTSamXKFLWUpuEYbOZL I7K5kk635LM0cZc7PnaJAMRpRLDbSwydvIZsCSKmLIHNLYYrstqyI9PdiFFYURTXtwtj jDB3gaMeQMb3M619Ekj/S9/r5Lz9U+52fOFn0/6s4Kz5en64dokfqHFX/eMcGsudeise tYBn9WGF5mvmW9M379BCrUlhBlbcDj4LQeCIp1kFAnM+GXrdIrskiXqfiPZpJgGldWUY 9W5T+gh+Re+WW0llEzpVuQV1m+B/1QELxhc7UmrGHIEKG/ugJOaUKqfhzediox6c2nnI zsMw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N4Ye0nXQ; 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 d75a77b69052e-4a61116b1d0si20164401cf.61.2025.06.06.09.46.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jun 2025 09:46:40 -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=N4Ye0nXQ; 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 1uNaDB-0006fG-Gl; Fri, 06 Jun 2025 12:46:36 -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 1uNaCw-0006Hx-5B for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:46:20 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uNaCt-0003Sa-M2 for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:46:17 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-451d3f72391so29934005e9.3 for ; Fri, 06 Jun 2025 09:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749228374; x=1749833174; 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=u4qlPyVP19TOs/IkzQVFEBQPCs8QxMwe6aQWLV0wFtw=; b=N4Ye0nXQeR035nDvUHQWs+lGh5qx7PKXKvu03yT3NMCoFc5y54QlUH7btIQ1T10leF NV7uUO4c1D8dqvZwYmnjfSGw/waL4fLNMySw0qsr6Szlmd/y749khoDWFIUYaCMKPHu5 LqnOhszswPC52dVRt/fp32f2TEi44lzgj1oMuSiRbwD8uxnzuJanYsbnilNv25l55gsa tfkw6hNayefNPUvU+hVqzkCkKqN2H1Kago8qruZoY2+KIObh7w83IeQtfpZ1urBddcI4 SeL5Mf4yah2JA314GnJFlqcKGlcpzVs9iDofrX3zKfZsMCODr8G+NYVZzbo+DFt59SzL NYgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749228374; x=1749833174; 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=u4qlPyVP19TOs/IkzQVFEBQPCs8QxMwe6aQWLV0wFtw=; b=YjfHHvaYDLRR9QcXEBZgkp3tY5qiCQ+/FyiU7+tVjGJjWdmdnkVdk9vJyPtOExlukj CgbcmXfTTuzxBqzGln9jCsCwefeCBqnj5RFu01+++AZ0o9zXK2yKCAD1mgugWPvTP/hy 0VgBI5/rQEpsIepKWJEhyy5z8IeQHcAhbXI3mwDyQb5VZr90U+Euflz/iu2T1GopJdmV 7OUQZF7ZRZLaw00fV/9IZ0DIRM0g06SgF/EHz9l+JOFlVAlyw1/Ugk1WcKRgjiW6vDLO VXalsaYpnNQN0urvmikNzcCur1+ImhtBQX6cKstg5gV0Q/3eZwYScCWpsHlILobGO/Db 96/g== X-Gm-Message-State: AOJu0YwTWTWEXoYAdCZp+KZxpCgRaAyjaHsg/uE4AftEbv07E7wJhOGb Q031RztmNAhlLXGeR12RRJWts4CSY6C+3wphKXyGEPxA5BimhwSNCI8g7s2nYWhd5Fv1syQSx9X aTA9St/h/tA== X-Gm-Gg: ASbGncv06l+m6QrMsDKj1RwQqPG6oPIlyZ084cRCfLpwaYP4+g50emuWQx7uW5A1kE6 5+GP2lIO5dUx5k+T5/tGM1E9llONH0+8QTGHk4R5zUMlCooOzhwrUtY0zrSpPSJPq/voG4qYbGQ Dux7aZQkPGLnRLz95qJIhAXRiirKY4AoBx3iqOFvVePSkflCNolLWV0iqQ4XnFrkIR1niUuHHDx w2MfAeP2TiYqwBFpByNaBZrYAfHJwz7JHYsaoaekxIxRUmn/S9cj4JpBwzTnDm9HRj6BtrNrrI4 0/fgrPKo1AnLa/LOFo2Q0uaYZMdqhldcXvA/YscGQ90OLSqE7jLz6m5CYtNTWxA5TehICtTSlu2 TLXKhxL69sbSNcLElhV5IGhdyVBAmnxKfLs7LG9JBg3CaVSb+ X-Received: by 2002:a05:600c:3ba1:b0:44a:b478:1387 with SMTP id 5b1f17b1804b1-4520147ea0amr46702795e9.17.1749228373574; Fri, 06 Jun 2025 09:46:13 -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-452137281b0sm30312505e9.29.2025.06.06.09.46.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Jun 2025 09:46:13 -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 15/19] accel/tcg: Convert to AccelOpsClass::cpu_thread_routine Date: Fri, 6 Jun 2025 18:44:14 +0200 Message-ID: <20250606164418.98655-16-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::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 By converting to AccelOpsClass::cpu_thread_routine we can let the common accel_create_vcpu_thread() create the thread. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops-mttcg.h | 3 +-- accel/tcg/tcg-accel-ops-mttcg.c | 16 +--------------- accel/tcg/tcg-accel-ops.c | 3 ++- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttcg.h index 8ffa7a9a9fe..8bf2452c886 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.h +++ b/accel/tcg/tcg-accel-ops-mttcg.h @@ -13,7 +13,6 @@ /* kick MTTCG vCPU thread */ void mttcg_kick_vcpu_thread(CPUState *cpu); -/* start an mttcg vCPU thread */ -void mttcg_start_vcpu_thread(CPUState *cpu); +void *mttcg_cpu_thread_routine(void *arg); #endif /* TCG_ACCEL_OPS_MTTCG_H */ diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c index 462be7596b9..96ce065eb59 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -61,7 +61,7 @@ static void mttcg_force_rcu(Notifier *notify, void *data) * current CPUState for a given thread. */ -static void *mttcg_cpu_thread_fn(void *arg) +void *mttcg_cpu_thread_routine(void *arg) { MttcgForceRcuNotifier force_rcu; CPUState *cpu = arg; @@ -128,17 +128,3 @@ void mttcg_kick_vcpu_thread(CPUState *cpu) { cpu_exit(cpu); } - -void mttcg_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - tcg_vcpu_thread_precreate(cpu); - - /* create a thread per vCPU with TCG (MTTCG) */ - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG", - cpu->cpu_index); - - qemu_thread_create(cpu->thread, thread_name, mttcg_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -} diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index e58e1c3738f..954e85dc13c 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -210,7 +210,7 @@ static void tcg_accel_ops_init(AccelClass *ac) AccelOpsClass *ops = ac->ops; if (qemu_tcg_mttcg_enabled()) { - ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->cpu_thread_routine = mttcg_cpu_thread_routine; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt; } else { @@ -226,6 +226,7 @@ static void tcg_accel_ops_init(AccelClass *ac) } } + ops->thread_precreate = tcg_vcpu_thread_precreate; ops->cpu_reset_hold = tcg_cpu_reset_hold; ops->supports_guest_debug = tcg_supports_guest_debug; ops->insert_breakpoint = tcg_insert_breakpoint;