From nobody Sat Nov 15 14:09:47 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1751483031; cv=none; d=zohomail.com; s=zohoarc; b=eR3Z3ImMGurgnVjT1Su4YF6Kw/5/5Y/qH9a+vzVRpgxdE0QI7HZdXp8yU5/W18S56ihztxaIzi7eImNHHYTkb1bU2yNVygVOJsxsj4RZ9dyg/V2Pfdh5886ohGFf/ZJRK4kTYF/X2aD83HWTa7Sa8LZgnvRfjNU4hbzktNydItk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751483031; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rDEWo1rnLUm5BJBdCICU6CLKmSMFjw+gxKuOsuwVDUo=; b=PuYMV/p0oaQY/UQ2+qILeO1vD+Aer1a7KM9axlawZIgXfQB+fg3i+2wT/rOqXCltLWCRoB48vCsi8UfHNgeS9GT83LuM1tFcQQN/kgq3AZX/zpCAhFfJ+2A9evpR6AykamVFLR3bZwAYFiA+0vm/OfK8dGFpsKXiyqv0l7WArvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1751483031425786.5443641967042; Wed, 2 Jul 2025 12:03:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX2h9-00074P-O1; Wed, 02 Jul 2025 15:00:40 -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 1uX2fy-0006MQ-Vl for qemu-devel@nongnu.org; Wed, 02 Jul 2025 14:59:25 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uX2fs-00035S-TH for qemu-devel@nongnu.org; Wed, 02 Jul 2025 14:59:22 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3a52874d593so4062293f8f.0 for ; Wed, 02 Jul 2025 11:59:16 -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-454a9bac9dasm5439955e9.38.2025.07.02.11.59.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Jul 2025 11:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1751482755; x=1752087555; 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=rDEWo1rnLUm5BJBdCICU6CLKmSMFjw+gxKuOsuwVDUo=; b=XQQmg1cqh4CPIMbHnYaXDe91EXPHvOnV/R8GJs5nbs1eNcdQ4cAehBFxvw8k4ZpujB Br1Ob75reT+ukpUkWXmCkTCSsp5QD1s6Q7EEZkGo2VmXccnjZtbp/q1UA+L7VjVjbytM 5oFqPS5Bvv7i5cMpLqxeprUFL5DfQHR5DL/uBfBHTtnp9vThhnJZuGM0THG34+wSZ7pB cLbXgW1Dh2StUOa/tuclzJ51Lf8X+IQFbzVC8x8t3JlZmwdHMPSUP9gjyOY6ot3rlaiB v94RSvfFNfif0qvBIT3cQe+ZMXGOL6LK3jNcdMIfF5jwNRZIdOdhfxX/LwC+MFDbLyC0 lzhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751482755; x=1752087555; 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=rDEWo1rnLUm5BJBdCICU6CLKmSMFjw+gxKuOsuwVDUo=; b=Pu31rnovOUy2nxYjMDuD4oiDvXsqecFfm+1Mpvrc0OdZkiZOUV2MporOO3HZucfuzF dcMoYWuIpZERfaqtTyAQWrJE7dBM15xDpn2l2tRuEc9wG62SSFQ34U4lXAcCE3Lvq5fz VfQPNfsdLd0CSyaNmi8/rM7FOqWD3kv9WxEOhhe5431kbWZnKsNokZ4aPC7qA0/7kYlY twgy0lY0sE8Hb7coTOoV1BHArntgatJcG5IMd4/tsmMyx8QOh2UHGUCiFV34ABYhFXfG T+Fz//JGuFJ5BZKqOu5zxsWqMfCUYYpfZYFcQ0wa43bIvVjnkftHfY8/wKyJV5kFmL2t QQGA== X-Gm-Message-State: AOJu0YzZg8//GxS7L2qqEFl1XJ4VYJPcP6lalIIOZViB1apzVpxVwwud K/+Ff77ykalrlac3Ob9QP3+hDfaHdxA8ogAoG+PIZ4wPSEbdN5rr41nG+t2eZRNnvfVxLDl3JbL PG2Kf X-Gm-Gg: ASbGncula9xj8DD6sbmvNf2E9sY1sVsVshOIGwbTV3U6umA+5exTPd0v02UzXIJSCTQ 6ly9MNmlUBoeIGa/xKSgP66P6iVvOZyQ1Wa0fmzxIZHbq5dmzUosrc3h4bLT+v2nWpQP0CCLPb2 7KLsua4pqU1p30x7TsJ5A1kWckWKWqI6tUNUG9ZWBciQclc1vLhjO0TM8O7+u0eyEU38OXI+Mn2 13Da4LEaVkuA3h4/RvBPWh7kvM1AC1Li+8bqJK3GsYnsKrBjkOfFtAZCITLYK8Gp3tEfB5lPj5m ZEFTlGzj7f1iGqDLivPFr3EQ+Wl0vu8z7pr1oMRSywYiawn6troEsDp/UMGBcGH1DVSFiH2DB6s r+o9SrLGSn42uolykhK6YcrVW/9jM7Fe2KVRO X-Google-Smtp-Source: AGHT+IFG+ZiqxK9Q/VXBexyw78eyCBQcwFTBUPTcjhYWJw9yY8MoUW+JZX3pcl0jG7F5t+n865WyVQ== X-Received: by 2002:a05:6000:4408:b0:3a4:f52f:d4a3 with SMTP id ffacd0b85a97d-3b32d4d0bafmr183882f8f.28.1751482754583; Wed, 02 Jul 2025 11:59:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler Date: Wed, 2 Jul 2025 20:53:09 +0200 Message-ID: <20250702185332.43650-48-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250702185332.43650-1-philmd@linaro.org> References: <20250702185332.43650-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1751483033537116600 In order to have a generic function creating threads, introduce the thread_precreate() and cpu_thread_routine() handlers. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Mads Ynddal --- include/system/accel-ops.h | 5 ++++- accel/accel-common.c | 16 +++++++++++++++- system/cpus.c | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index 77bd3f586bd..d4bd9c02d14 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -39,7 +39,10 @@ struct AccelOpsClass { bool (*cpu_target_realize)(CPUState *cpu, Error **errp); void (*cpu_reset_hold)(CPUState *cpu); =20 - void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ + /* Either cpu_thread_routine() or create_vcpu_thread() is mandatory */ + void *(*cpu_thread_routine)(void *); + void (*thread_precreate)(CPUState *cpu); + void (*create_vcpu_thread)(CPUState *cpu); void (*kick_vcpu_thread)(CPUState *cpu); bool (*cpu_thread_is_idle)(CPUState *cpu); =20 diff --git a/accel/accel-common.c b/accel/accel-common.c index d719917063e..24038acf4aa 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -11,6 +11,7 @@ #include "qemu/accel.h" #include "qemu/target-info.h" #include "system/accel-ops.h" +#include "system/cpus.h" #include "accel/accel-cpu.h" #include "accel-internal.h" =20 @@ -104,7 +105,20 @@ void accel_create_vcpu_thread(AccelState *accel, CPUSt= ate *cpu) if (ac->ops->create_vcpu_thread !=3D NULL) { ac->ops->create_vcpu_thread(cpu); } else { - g_assert_not_reached(); + char thread_name[VCPU_THREAD_NAME_SIZE]; + + assert(ac->name); + assert(ac->ops->cpu_thread_routine); + + if (ac->ops->thread_precreate) { + ac->ops->thread_precreate(cpu); + } + + snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/%s", + cpu->cpu_index, ac->name); + qemu_thread_create(cpu->thread, thread_name, + ac->ops->cpu_thread_routine, + cpu, QEMU_THREAD_JOINABLE); } } =20 diff --git a/system/cpus.c b/system/cpus.c index 6055f7c1c5f..c2ad640980c 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -671,7 +671,7 @@ void cpu_remove_sync(CPUState *cpu) void cpus_register_accel(const AccelOpsClass *ops) { assert(ops !=3D NULL); - assert(ops->create_vcpu_thread !=3D NULL); /* mandatory */ + assert(ops->create_vcpu_thread || ops->cpu_thread_routine); cpus_accel =3D ops; } =20 --=20 2.49.0