From patchwork Fri Jun 20 17:13:25 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: 898353 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f54:0:b0:3a4:ee3f:8f15 with SMTP id cm20csp1454645wrb; Fri, 20 Jun 2025 10:21:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVxQYp17VzXPkdyGhApTRk/ODLvnQl+82e8uNxf1mWTKYBHo4gIo/H2bLkYb7PiYNCtSzjNJw==@linaro.org X-Google-Smtp-Source: AGHT+IE/8+Rpkz92oFRKxOOAIzV8dpDfaOcj5IekRZ3LeQF8hIRi8rU1lQGHa32i9LpDXUtx+WM9 X-Received: by 2002:a05:622a:6182:b0:494:993d:ec30 with SMTP id d75a77b69052e-4a77a209431mr60723041cf.16.1750440060346; Fri, 20 Jun 2025 10:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1750440060; cv=none; d=google.com; s=arc-20240605; b=S6gUXGn6XrsVFs6dQrCuki9edfHp/tovbsfKlkAWTlOa6AeWVmKlH/ILGOthCty6Wb crRqDn6uSdBpnGM+2QYZUv8EBX2fZntSGjjn6csfBjL3xLe/HvpB2alswpPL57voCE8v wQBTypeOeInvMWF0MEORByXeo2Nck7c6+IdSTF9xJT3Dvor07aaOQzdORDOs/a5hR9xa POJauECydqovmyYMktmFtl+pb5htgufsL52Y1CPlonT5vQHkTafWE3cXtXF6nVLMbx2J gnmpzYnF2FgYVUxzgCsP3g9ysaaQ68BvttGUGKYXCXxyGFBmU2IygfjakHvVH67rXGPw wqag== 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=OeMttFNHwCeQPAcqGb56M6LDjrMo8+04+qvCxL+KWeo=; fh=8f2AL0Su0K9UlZksY2EEcc9O+An+AQ/T/SEdbs2pdSA=; b=BNmsSrU6ji0SrLQRJMx2N2u+hhdkh2bxu+hTCJkTddP76rSj6tERcY5u+5q32+mKxc fHomBbfUKnRakK/jcGaegKQcGyCCe+CUYR6bae+j2EP59FbAzUFcdz0YdgSo1EbIK+87 8WbDDwEhLdocPSi4j8FkFKDDKe5mDgiUyiElS3flZ70mMdlR3EiiTjg5hgJbwVnQRq4D 81uIsMi5RmtTxqAVC1YJRPDNGWeAiR1oimHzs0II9lHTqBNKON5P6MjjQloOMgo4F1ED F3LjcM4oHS8P7XB76bfxsc5iETgguRE5S4qQ1FwvtvEsgMmRVjuWuzIdG4KLwNsCnrLd 7MNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NwG5zyvm; 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-4a779e992a3si21347441cf.259.2025.06.20.10.20.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Jun 2025 10:21:00 -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=NwG5zyvm; 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 1uSfOh-0007pm-Ql; Fri, 20 Jun 2025 13:19:30 -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 1uSfLk-00032E-UP for qemu-devel@nongnu.org; Fri, 20 Jun 2025 13:16:28 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uSfLj-0004dM-8H for qemu-devel@nongnu.org; Fri, 20 Jun 2025 13:16:24 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-451d6ade159so16731745e9.1 for ; Fri, 20 Jun 2025 10:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1750439781; x=1751044581; 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=OeMttFNHwCeQPAcqGb56M6LDjrMo8+04+qvCxL+KWeo=; b=NwG5zyvmOUubSF3HucZX2+lA8537sGMUX1W0UVXD6zlTI+F9MUdkceB1z4BwFFGZdr Gye5NyDSKGLPst0kSzOsxgDpzRCf1hDpVemjAozULd/73V6KnfUJayhU8D7weihyFYBv gDopU9uooU2f9RBvHD2nb3qJG0xf5JDZF5YBdGJmrZQgi5OsK4ZHAvp8bTwTMg9UynZj zYNwDKP3grWWo61WDFs04bkBUwau+Q4EmhXu6W8bS6Z+n+Co2SC8pLrl+Th53yp35SSv gwBajGyNPyr/8hiZYSn1Gq6Wqhgc65ANqh58he3IzMKfieFO0mvoU3/Xkp2qqWf4v7kY Vjaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750439781; x=1751044581; 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=OeMttFNHwCeQPAcqGb56M6LDjrMo8+04+qvCxL+KWeo=; b=n3uEQhngwdfhRYe4wELkBkdFI/b6Mcqe9PdLk4PEnGwkNyLleAEYrglgPnwCTaZBlU B5iiC84i7XBKnfE2mJiRGlVVs75NAoC38XrsfeNMNE511q4gBLqQwQOatow8WO/egz9A qQCH2JUM8GJc0qbC+6vHEJgYYyTYohs4YjPt1jJZaf9QQAPaexY4HGSG+KJgKtScjrCW W2isD6fg8tOK3qUMHxbPKB6RG15ITUjvgR/QproiE4pFznYSzpJr2VsyUiVb8zEdjnRA ED06X6hdEBKcC23kMyKDfs19oJmjMacpFR6jOKGdiEHF9yCy4yh3GOlo1XQG/hbZhBeU NjoQ== X-Gm-Message-State: AOJu0YySDgmmYJg7jBPDcce0JgZrUDryXOqRfmNQnN8p9nRqj8YZyIMT lsLBEiBdM5eXpAm5RAnhQPVBwnObifcP7aElXEwv3p5dp3/U7j8G004naWY4Px9WKRlDRDdOA3T 0cqT9qPk= X-Gm-Gg: ASbGncu/olLyOLCvs4gmDf8IM3aDMQN3imnBjf+AOtA0y8ewLz0g1WRydP3NW08p8OJ rudtcM/ePQKFGPVI9kxx1Vh9SRlorbCvLtlAHWvGESPazTHQrrOE3NXAnwgiyHC0PPbVwzsg02Q 15BXxCysXrHeYUoT1UaWCfMbihgUSwRDqHpTg/hd2T8j92CvIdIVVrRmtRIXTKLHppNVZUM9Cz6 uwbBXa90gDKzGVNMqU4FEkSfU8YHzGGGbVP/tlY5X0t9VeYmZFxY2PfTc3P6G+NYjNxadnKhWJH XvInsIc7vSDn1CNWFLofaOPOHoIWzyZHRhQDiO7LZDhg7zbbeQbDQUVN/o/QqfzswRJBz5j8RBM aSXKvpdpJ9AetipwmlCJWieLQFWR6pju1mvCY X-Received: by 2002:a05:600c:c103:b0:43c:fffc:786c with SMTP id 5b1f17b1804b1-45368787924mr13935475e9.19.1750439781406; Fri, 20 Jun 2025 10:16:21 -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-4536470903asm31693965e9.40.2025.06.20.10.16.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Jun 2025 10:16:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexander Graf , Richard Henderson , Pierrick Bouvier , Peter Maydell , Thomas Huth , Cameron Esfahani , Julian Armistead , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [RFC PATCH v2 32/48] accel/tcg: Convert to AccelOpsClass::cpu_thread_routine Date: Fri, 20 Jun 2025 19:13:25 +0200 Message-ID: <20250620171342.92678-33-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620171342.92678-1-philmd@linaro.org> References: <20250620171342.92678-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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é Reviewed-by: Richard Henderson --- 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 861996649b7..4931e536beb 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -204,7 +204,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 { @@ -222,6 +222,7 @@ static void tcg_accel_ops_init(AccelClass *ac) ops->cpu_common_realize = tcg_exec_realizefn; ops->cpu_common_unrealize = tcg_exec_unrealizefn; + ops->thread_precreate = tcg_vcpu_thread_precreate; ops->cpu_reset_hold = tcg_cpu_reset_hold; ops->insert_breakpoint = tcg_insert_breakpoint; ops->remove_breakpoint = tcg_remove_breakpoint;