From nobody Mon Dec 15 21:42: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=1751540913; cv=none; d=zohomail.com; s=zohoarc; b=Wo2i36Rt80c38zj95XZyl/myKL5BNp3JUywJ5GOgnRTm68fNkGciNbioBrPvgVVjZcxJBzYc8TXcRdvxo7MInU3XQ0b7cT7ShJ4+OdDE76zF7/uTGJuhTjS/FarXM66pvk0LhcebqzobOLCrStqqfOlKqgEc/ek13Zr2tWt87Nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751540913; 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=iN3GSis3XxGCVojsU1rOHjRci0jqM86dFRSWRb618OL8ClTNpQ9lRwxt0tfoVyIxY7MIzVZBMiXNAg+a8zc0AkvMtTPuiNUDfLUejfsMztYTVUZ9ytl7QBXQ+9nFbuaYZ7Agmv8UlWDlgBQhtJBgPbJCsOBhnBXHw/SyVFlovbs= 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 1751540913422341.1180433585664; Thu, 3 Jul 2025 04:08:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uXHiq-0005VC-7g; Thu, 03 Jul 2025 07:03:20 -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 1uXHg2-0007HK-3B for qemu-devel@nongnu.org; Thu, 03 Jul 2025 07:00:29 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uXHfv-0003eZ-06 for qemu-devel@nongnu.org; Thu, 03 Jul 2025 07:00:24 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3a6cdc27438so4657179f8f.2 for ; Thu, 03 Jul 2025 04:00:17 -0700 (PDT) Received: from localhost.localdomain ([83.247.137.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a892e52addsm18165861f8f.47.2025.07.03.04.00.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 04:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1751540416; x=1752145216; 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=DfpvvGd++UmcgOTQ/saawpNc301mtrknPU9zWYtUJuoFD+P/mFda3jtq3jBnfPzcl/ uKpAm5peOSNaKrx55u5fuGq1z7qvLA4GD2b5GYFAAHjOw3n9hp6FdGvt93EU4OAlZuKh fahqXqdwdVs42V/p7+6Vf1ty4Unq1vhcPB0u9luoXhixn64dhyGCuBoQUae/3Eegj8Js kG6S0kKEPnVnfJmf3MirxGJLD2+jDAkJd9HA7Yt2acMOY0zxhAqK3wcN/18Lzd0wjzev kIUoZVwhNzrTt94RSfTgZ0IlHCrR0oPodVbCXxJ/vsk5cpr0zFNjrR3YjSCqxym0onH0 46JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751540416; x=1752145216; 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=oeAWioKvAPAGi2b3jYPzsUd9OxuBYylIkSLnnDoATDbz5ZGqJDK7fjS8jjKR3BHZ+m m3wXiVPCmXqCK5Suejykn0NnO887xLP9EoESwVTRv7GJwYTEA7Y6DkG11x8EgNYD78SH Y1UOycNkkuaJM3l6mdosZrDcEuMrkyMe7BZXDdIbrCU4SF/8YETuz6igimEO75aKlsOA T2bttxb/xIps0yhjyN2C43W6bI9L3WuERaYwVZgI0HPHCw4Fx929s2y4aqk1aqpYGwd1 yc39O5SKkzoKmA35gzVm+3vyF5TBIXVjDJi+MuLLFUm6dD6z/dP/4RkhRlWwfiOTP4ii QQbQ== X-Gm-Message-State: AOJu0YzTCqlTGqdgSop0lAvrK394JlR0v4RT0ISzVLKyQf78c4lTmNde Ujzplg4aydyuH3f9s7W7z2VzbVuBJ+rlq0bOb6P27V9nViOK1YG+AEC3IMwORzU1MucALaePEhs zMSE3KeY= X-Gm-Gg: ASbGncuoIvpqlahuziLqz/BrDMoqoif5a+mTGdzKrVuHFzvcWH+zK3Qga15fYEa89wz 0pQU/FZ/pCpMIfs/9gy9NWkLqutaXaqvDi3IqLcVu9fbjw3g8ZdP5xJUG7lRxAOjVrqNy2ObpYG MBe06RL71ixPjJTnxvDhKgbc+QhAlmFIS4YnmXgziYR7RzIpuSn1O/bP0MSmrZO/lJQ80r/eI0a kJsAFHTsQZe50yeG/WQ2ma3rULl5db948JgPlX60iW/Orlv7c0koUfLQbGgA1mQAANqiGGtu8VP XSfgb53+H85H3QRpMqDknHtDmRtDvQ2j/5rVoQD1uRvqWMo3m6XQbCKBNwWUJrRLOZ3N3Bdlym2 /5yrTVc0aCq65DPo5PbdFFQ== X-Google-Smtp-Source: AGHT+IFhk+dJX89aeL6Cw0AQ89dfOnSUw7mCET4TWkmrNY6d5nurBwjiVVzjmOBE6Tzod4CCSgM23Q== X-Received: by 2002:a05:6000:2f86:b0:3a4:e740:cd72 with SMTP id ffacd0b85a97d-3b1fe6b4e63mr4918822f8f.13.1751540416475; Thu, 03 Jul 2025 04:00:16 -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 , Pierrick Bouvier , kvm@vger.kernel.org, Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 52/69] accel: Introduce AccelOpsClass::cpu_thread_routine handler Date: Thu, 3 Jul 2025 12:55:18 +0200 Message-ID: <20250703105540.67664-53-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250703105540.67664-1-philmd@linaro.org> References: <20250703105540.67664-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::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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: 1751540914963116600 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 --- 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