From nobody Sun Apr 6 20:58:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736193818; cv=none; d=zohomail.com; s=zohoarc; b=KvCQS5MiAn/196AxZ5aTggcZXlY7lFnH3MaZAUbmHO1goTrY1VmpATomHaq0URGdPmDPMuEtkO4Cn3meq8gOrrDea6sJFPi34YBGbGQL7frPi5JFWF+84pXNPrMBE6mZQXbEGZ8hxXATlpcdqpslWs7MdPfKHiFL6hZiiOF4xBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193818; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Gw/8miEe/PnaBFePSWTnOg3qI2ZvVUjrjdrVrAxgzBI=; b=R9WaNPr+73lSLIwelFAVayLTWs7rlFKtAyvcE0sjaeKp3o/qP6BHCrhuhwYXeUkJ2ZShKku47IiIT4LF/Nz59Js7KFnTL/SDxRM61YhyE2C9NxzlT/z+DZ6pQoknhmQ+gn+3gES+bTj2y3srdD5ZV2AqBBeJsPqkPnC3G5d8H1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736193818117431.18056059948594; Mon, 6 Jan 2025 12:03:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.865900.1277193 (Exim 4.92) (envelope-from ) id 1tUtJg-0002sn-AN; Mon, 06 Jan 2025 20:03:12 +0000 Received: by outflank-mailman (output) from mailman id 865900.1277193; Mon, 06 Jan 2025 20:03:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJg-0002sg-7M; Mon, 06 Jan 2025 20:03:12 +0000 Received: by outflank-mailman (input) for mailman id 865900; Mon, 06 Jan 2025 20:03:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJe-0002s4-VR for xen-devel@lists.xenproject.org; Mon, 06 Jan 2025 20:03:10 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 40584bf3-cc69-11ef-a0df-8be0dac302b0; Mon, 06 Jan 2025 21:03:09 +0100 (CET) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so9136527f8f.0 for ; Mon, 06 Jan 2025 12:03:09 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43665cd9c29sm559552815e9.14.2025.01.06.12.03.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:08 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 40584bf3-cc69-11ef-a0df-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193789; x=1736798589; darn=lists.xenproject.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=Gw/8miEe/PnaBFePSWTnOg3qI2ZvVUjrjdrVrAxgzBI=; b=GpJJjrGhEDpawdBPjjACmpCUFkHH8FrwXHA1FDOcG1DfCYoQvJ7sd7OsxDyLC/NOCK 3i0AtcqPDWHQffFFaTDxmmcMhaTVQfarHruEW5tZAtVGovP6qy9tHMnFWTvgmgiJlSND F82UOzjdOC3Ugdj+m13ayr5SG2HkwEmkXyk8e24A8umZBLfFWIQ0ZDermyxMet+HuAhV cqc7sWecdDJ5SSkt5njszm8OMzvRR+fbajtxA1Ehi54RCG27B9IZ2EeRR5vq7K9ndoeR F+yQaD2DEpSFLbv+fa8Mb5RVhZeWEmrW+LeIVbRwceig6c8CzdxsJMScDsW+plcNcHuZ /lWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193789; x=1736798589; 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=Gw/8miEe/PnaBFePSWTnOg3qI2ZvVUjrjdrVrAxgzBI=; b=rmE8ZhVvPQgif4MkjHcddxr5N26o/JNL6PP0fiGKtyMjQujAUM8n2asEI00EmOwU4m d6V/8JG/2BYagCp2Ze99ix0FOOmZKAOjJp2sOkb+evhMTrCpyVZvwK9Z2doC33Q+1Esm Dqc4yoYSlpU4j6W950SbDRf7lGUhQv2FdazkgkDXuC2TFM2TRavcFMa+/9ID2mO6p3WH zgQaMdNuDL7nLOH9pOwICpb+GrzLBqT56BOSx5PJTFMdT+Q2LKxmKbO3Jur7cKd3QAor 6OaNo2pCQ9EujXWn7AWPnoVmq03IonUFNXuwV0bWUort1my9wTaEMFJSdfMI1d93K9PH m4Jw== X-Forwarded-Encrypted: i=1; AJvYcCVdD9R58Aaq0lgng7AFlXgOKVr6U6nQgqmx9OUd4nHzo49RrrqzAqgdl2wjCwufutH6bwlJ9sYQ+Ow=@lists.xenproject.org X-Gm-Message-State: AOJu0YzvaU9FywNO88ub3tWHClZIxecD9wKJYoZIRizxOINaOz1BiDko 0wkOFaW76dqtiK6unDEwfA4gvsVVfsTjj96nqsQKLvt8zv2mU3wNs2Stct7CCkc= X-Gm-Gg: ASbGncvUgxOsbFNz4qUnfRVLXqMiH2ja6u7aEFSnYpAMk797Au2U2Xo7gBCQIeXOsLy D9iorM633cnwXMqGO9Q7QgOGmPLBOlf2AzPGGlpqxJ2xuLLzTDUagwYTa0OgxEclf0EUfyDxvkv LXm+sRwoNK8OkCRw7DH5qi6iytixU19htgn08D6I61xwuluo0UpYzUtEgKuEIwsX0Z899fQJv36 n2nHXH8TaFxaXx6niqSbkvdcogNNK7SMR72MJ4HCnYsby11oI36YDbL6hAA9weX+9/NEHU4Nx4V LUVz3w4Onj5B/hsxRoPmRgptkbNbUoU= X-Google-Smtp-Source: AGHT+IE81N1RplBD8FCsdoj95sqyVSqitqWpe38bLlQuumoNL1lLDdZMOpwBwgd43Npz//MFxfo/tw== X-Received: by 2002:a5d:64ac:0:b0:38a:4df5:a08 with SMTP id ffacd0b85a97d-38a7923b959mr440924f8f.22.1736193788891; Mon, 06 Jan 2025 12:03:08 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 1/7] cpus: Restrict CPU_FOREACH_SAFE() to user emulation Date: Mon, 6 Jan 2025 21:02:52 +0100 Message-ID: <20250106200258.37008-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1736193820436116600 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel Henrique Barboza --- include/hw/core/cpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c3ca0babcb3..48d90f50a71 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -594,8 +594,11 @@ extern CPUTailQ cpus_queue; #define first_cpu QTAILQ_FIRST_RCU(&cpus_queue) #define CPU_NEXT(cpu) QTAILQ_NEXT_RCU(cpu, node) #define CPU_FOREACH(cpu) QTAILQ_FOREACH_RCU(cpu, &cpus_queue, node) + +#if defined(CONFIG_USER_ONLY) #define CPU_FOREACH_SAFE(cpu, next_cpu) \ QTAILQ_FOREACH_SAFE_RCU(cpu, &cpus_queue, node, next_cpu) +#endif =20 extern __thread CPUState *current_cpu; =20 --=20 2.47.1 From nobody Sun Apr 6 20:58:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736193817; cv=none; d=zohomail.com; s=zohoarc; b=N03JUJfUY2GHs9aJwGblr4/E2Wpy1iKfookt523iO6+bkyOWNwqqMjt18kB7Q10bJxS+BGCaZKV4siJlMxKBX9R7L/AT3KH9OjeT5zqm3QvCBIjwvNi0Nlez2rHWpIkVMOEkkA2fB8Fop47TU0ei8y5KOu1JFv9UZiaPrm+cJ0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193817; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xubr80DdDK1TQnuEw657hT2ILmCSL1Bi/K/I0ME5hpI=; b=Tz9NTNaGWdj3tSR0MXAPuiW59cK4PfPeBKICj/KmLNk+rmWkkIajSTZkpKKx3hu+fp9QY/H1BOtIc1kQ9ZFbiy0vPT9uuqVUfMD19SGE76Nf69fEwEP8JfKyhwKE0MXMrAgndjexE6tzK4V/0EWjzJy73aM+YWaccB5wriag3c0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736193817878565.5328665730214; Mon, 6 Jan 2025 12:03:37 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.865902.1277203 (Exim 4.92) (envelope-from ) id 1tUtJn-0003Bq-Ke; Mon, 06 Jan 2025 20:03:19 +0000 Received: by outflank-mailman (output) from mailman id 865902.1277203; Mon, 06 Jan 2025 20:03:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJn-0003Bd-HJ; Mon, 06 Jan 2025 20:03:19 +0000 Received: by outflank-mailman (input) for mailman id 865902; Mon, 06 Jan 2025 20:03:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJl-0002e6-QF for xen-devel@lists.xenproject.org; Mon, 06 Jan 2025 20:03:17 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 443e5027-cc69-11ef-99a4-01e77a169b0f; Mon, 06 Jan 2025 21:03:16 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43635796b48so89318005e9.0 for ; Mon, 06 Jan 2025 12:03:16 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366128a353sm577748615e9.42.2025.01.06.12.03.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:15 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 443e5027-cc69-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193795; x=1736798595; darn=lists.xenproject.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=xubr80DdDK1TQnuEw657hT2ILmCSL1Bi/K/I0ME5hpI=; b=Z4/zdLcV/crESVhVabhQYBni+lmsiCCndmM88y5yJ7hPu4aaG2wSoyGhbEMxbpk7bv zEE2kpVpJ86cOf+1uUEaKotVnwcu2M7+GlgzUbj9JU1D9h9me+Waw+rMona96fEcvFL/ EtSyKviN0YTJ+CIwKQqEmaIC8xQFCEVFEZxVQ2FgRBTXFYwzhKRtG1VMh5ySR0ThV8J2 6Ap2ZJEDXsx3LetuLd5o5PfmQow3lusntyt3ku55vRWFI47XibE1Mt4ukwp8lSGpKXH8 c8MaK875hig5itxqrhB3Av4tZC8D0QRAVk6BPYdEmkXuMu+tU4dbaJr3P0y4Bbc6QjUr hHOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193795; x=1736798595; 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=xubr80DdDK1TQnuEw657hT2ILmCSL1Bi/K/I0ME5hpI=; b=n0jfWCwazboGTCtrEOQkNjZGVPu1bKEYy9ISmsiIFZxS6DIsmRWjN/PPW7FuZU8uTh LTGqdWyDu+/ykwrr1k9wiJIAsDfb0FVCI+bzxNV+BuLhY7VnkbjqViJl/OAe+9KhUBNF WeuKsi+EN2eybn7mmQEVOgDpEuqUZLY44h5n+WirB2fm3GLUpjb76bock1+emLL+RZoO 2B4vche5B/IgRB1UEBT1ywGoDLWA4RvXzjPYZouBZ1sCroIR8XtPZOfie7MXzOku/ntK mjg2ppRuuKPUnZ6jJge522e0i5L5EarrGRP/Azn84Fp4pAUx0raEvETIZ2PmI+I68bdp LPtg== X-Forwarded-Encrypted: i=1; AJvYcCX/UModMtUrRF/D/9YkghwB/k2PaaE9aP0GAqrHaT5BcHh482B85TI4DKs4W1m4Fhq5MfgSz3Edp+U=@lists.xenproject.org X-Gm-Message-State: AOJu0Yze56e0eCoxQNwGXUKVDXSRqcEWj0CvDUCSlqCaY9v9zzk5THq7 GCyLG4u5T85aeJl8r0RoDR9NdjJhJK5+UKBzWR5Ab1Xy8SSQBmAfybluUNjq/MA= X-Gm-Gg: ASbGncvvXgWxcVVDcPuPAjGDsWx3z2hGM/G2NLBbqhDKAPcwUR3FrJBTpljIuY4cHkk pmfNqR52f4Jp765SFXmEqznHUFQXq6iHoxpV1M716BYY8lTWbOAOBKH1kL77SdN/p2a6Rv87fgc J9fKEo6utw+XnqtDAa8TY4TZaRqBcP7KnVWRB6afWXONMUSsZTabVVX3Wo/lgLZ0c1Fd0qrimWw efYH1lnt3NrJvQzFTs8MvrRLOsN1B8ixlwursEHjJ84ccjpjAR8E+bcKoyPLlY7xxG8k0bJ/Blh sUyNbPlogzB07G7NYXAHNAv924CCAfs= X-Google-Smtp-Source: AGHT+IG6hn6gQ1rEDpo0RUo5rK6HsOddWfOpcS85mXtVNMxlfkCCUdnnKaA6rQB2Q6OTZ5JLDkEevw== X-Received: by 2002:a05:600c:1d12:b0:436:1b86:f05 with SMTP id 5b1f17b1804b1-436dc20b0c1mr4405765e9.11.1736193795597; Mon, 06 Jan 2025 12:03:15 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 2/7] cpus: Introduce AccelOpsClass::get_cpus_queue() Date: Mon, 6 Jan 2025 21:02:53 +0100 Message-ID: <20250106200258.37008-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1736193818200116600 We want the ability to iterate over vCPUs of a specific accelerator. Introduce cpus_get_accel_cpus_queue() to be used by accelerator common code, and expose the get_cpus_queue() in AccelOpsClass, so each accelerator can register its own queue of vCPUs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 8 ++++++++ include/system/accel-ops.h | 6 ++++++ accel/tcg/user-exec-stub.c | 5 +++++ cpu-common.c | 10 ++++++++++ system/cpus.c | 5 +++++ 5 files changed, 34 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 48d90f50a71..5ae9bb64d6e 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -591,6 +591,14 @@ static inline CPUArchState *cpu_env(CPUState *cpu) typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ; extern CPUTailQ cpus_queue; =20 +/** + * cpus_get_accel_cpus_queue: + * @cpu: The vCPU to get the accelerator #CPUTailQ. + * + * Returns the #CPUTailQ associated with the accelerator of the vCPU. + */ +CPUTailQ *cpus_get_accel_cpus_queue(CPUState *cpu); + #define first_cpu QTAILQ_FIRST_RCU(&cpus_queue) #define CPU_NEXT(cpu) QTAILQ_NEXT_RCU(cpu, node) #define CPU_FOREACH(cpu) QTAILQ_FOREACH_RCU(cpu, &cpus_queue, node) diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index 137fb96d444..fe59f728bfc 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -12,6 +12,7 @@ =20 #include "exec/vaddr.h" #include "qom/object.h" +#include "hw/core/cpu.h" =20 #define ACCEL_OPS_SUFFIX "-ops" #define TYPE_ACCEL_OPS "accel" ACCEL_OPS_SUFFIX @@ -37,6 +38,11 @@ struct AccelOpsClass { bool (*cpus_are_resettable)(void); void (*cpu_reset_hold)(CPUState *cpu); =20 + /** + * get_cpus_queue: + * Returns the #CPUTailQ maintained by this accelerator. + */ + CPUTailQ *(*get_cpus_queue)(void); void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ void (*kick_vcpu_thread)(CPUState *cpu); bool (*cpu_thread_is_idle)(CPUState *cpu); diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c index 4fbe2dbdc88..cb76cec76be 100644 --- a/accel/tcg/user-exec-stub.c +++ b/accel/tcg/user-exec-stub.c @@ -18,6 +18,11 @@ void cpu_exec_reset_hold(CPUState *cpu) { } =20 +CPUTailQ *cpus_get_accel_cpus_queue(CPUState *cpu) +{ + return NULL; +} + /* User mode emulation does not support record/replay yet. */ =20 bool replay_exception(void) diff --git a/cpu-common.c b/cpu-common.c index 4248b2d727e..ff8db9c7f9d 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -82,6 +82,7 @@ unsigned int cpu_list_generation_id_get(void) void cpu_list_add(CPUState *cpu) { static bool cpu_index_auto_assigned; + CPUTailQ *accel_cpus_queue =3D cpus_get_accel_cpus_queue(cpu); =20 QEMU_LOCK_GUARD(&qemu_cpu_list_lock); if (cpu->cpu_index =3D=3D UNASSIGNED_CPU_INDEX) { @@ -92,17 +93,26 @@ void cpu_list_add(CPUState *cpu) assert(!cpu_index_auto_assigned); } QTAILQ_INSERT_TAIL_RCU(&cpus_queue, cpu, node); + if (accel_cpus_queue) { + QTAILQ_INSERT_TAIL_RCU(accel_cpus_queue, cpu, node); + } + cpu_list_generation_id++; } =20 void cpu_list_remove(CPUState *cpu) { + CPUTailQ *accel_cpus_queue =3D cpus_get_accel_cpus_queue(cpu); + QEMU_LOCK_GUARD(&qemu_cpu_list_lock); if (!QTAILQ_IN_USE(cpu, node)) { /* there is nothing to undo since cpu_exec_init() hasn't been call= ed */ return; } =20 + if (accel_cpus_queue) { + QTAILQ_REMOVE_RCU(accel_cpus_queue, cpu, node); + } QTAILQ_REMOVE_RCU(&cpus_queue, cpu, node); cpu->cpu_index =3D UNASSIGNED_CPU_INDEX; cpu_list_generation_id++; diff --git a/system/cpus.c b/system/cpus.c index 99f83806c16..972df6ab061 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -209,6 +209,11 @@ void cpu_exec_reset_hold(CPUState *cpu) } } =20 +CPUTailQ *cpus_get_accel_cpus_queue(CPUState *cpu) +{ + return cpus_accel ? cpus_accel->get_cpus_queue() : NULL; +} + int64_t cpus_get_virtual_clock(void) { /* --=20 2.47.1 From nobody Sun Apr 6 20:58:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736193822; cv=none; d=zohomail.com; s=zohoarc; b=W+zFxS8uRmtcgSSchU/dP3Ur7DwwFUK94skXKj3VC8nq9EN4xqKmukXcMrJm1kYiTlyx+dR4bmeqBjM3QO1NkyOU6tQTEJWsxWjHSos/akN9PvsYRFl7QkM2czSt6rDguxQD43fFmbpIl6MlP0XxfPTB9QnphSpOjT1Mk43f8sE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193822; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; b=Gas4CSm6TNIEiAGUrZJ74+388jsSfXzA9sq9zIAf/XucvsRMQr1w1+6U/WQRz9xAD8L+QueCfedl9Sv0Ix+02iOTdocfgvcQM8LsOaLmkJN+MqEUrV6mBIwvaxczhkMl0AC5nFO0hzraAAbIIFJOzAhKgcdTlONwi9H719SDbb8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736193822954541.9842126148517; Mon, 6 Jan 2025 12:03:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.865905.1277213 (Exim 4.92) (envelope-from ) id 1tUtJu-0003bp-Su; Mon, 06 Jan 2025 20:03:26 +0000 Received: by outflank-mailman (output) from mailman id 865905.1277213; Mon, 06 Jan 2025 20:03:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJu-0003bS-Pa; Mon, 06 Jan 2025 20:03:26 +0000 Received: by outflank-mailman (input) for mailman id 865905; Mon, 06 Jan 2025 20:03:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJs-0002e6-Rz for xen-devel@lists.xenproject.org; Mon, 06 Jan 2025 20:03:24 +0000 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [2a00:1450:4864:20::32a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 48821c5b-cc69-11ef-99a4-01e77a169b0f; Mon, 06 Jan 2025 21:03:23 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-436281c8a38so105991955e9.3 for ; Mon, 06 Jan 2025 12:03:23 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4365c08afcbsm586765365e9.21.2025.01.06.12.03.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:20 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 48821c5b-cc69-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193803; x=1736798603; darn=lists.xenproject.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=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; b=FFy6RLjh7TTri8MMMVzmUwJljPN7BpxZ8zdqOvSf5LoMWpP/tH8oL1Z5lJQHBIgwhM XTGAZFf6CyM8Tnd53E4pxXZsGpy+nN6ZTB1SLsi3Z/4fyF+oJvG+3RevFuCHgaO09CMX C3JR6qOYy5aueOMC1xywlNWDdtsrBGD8Lqp9xwfSuOftmQHYbXJKzGoZSkFF3yS/7Y2Y fGGdM/ddjrrh8h+422wnOrC2ZyX++35SUn644FyKUY+cYYmpZOeonm4uzCQwsUjBAyAh 2RErF9PpcsQZcv70kpXarc3Ab588DYOEurLbm6P9tS6sATkOX1xXdYFv6xny2h9h0i9G DCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193803; x=1736798603; 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=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; b=jGW+IFInjnUL40cFpLrI20PRPbD9D2DYlZnKVkogu5CVWJzjTKjfENl3VXiNGK0MeM VBrfd7Fwvh3iPlCTLJsdNCvT6z19Jeq4evnybwbMn8r6flAmXtk+p6SmZFDmkK8PZmPN hUnYl2fIDqHiJ9QpOBFIMkET02MijIUI47SyjuoksC/CrbHeavKcTKaBYB4V9Z6Zwt+Y dvef4q7ArC11ODfSoZ42HK63i3sPwvIglJIBM+jc+zIPJGevFOCO4AINhlPWusyz0Ulm C2X3eaxSnKqsYQem3io9jBa3/KBUrCVl+xIjNzpItQtlgwsmNRkEe/kduoaqGS/zvUSE LjMA== X-Forwarded-Encrypted: i=1; AJvYcCWw1gHom9BynyB4uZBkt1Np8iOWdrifhlbMfaise8EY5GZkaQnrkuOTVE46D6qYqctpAOVufRidGnk=@lists.xenproject.org X-Gm-Message-State: AOJu0YxVv9sRkqK7PoxdGCp9qP4N3fcTqoNRtJRKSdZ06THGxXRL4K2V h7zQNbA+FHU0c5/dd9E+f+yoU0zQjygIi5UZjxKsDkKHYjdB7CbdZahtNEGU9NM= X-Gm-Gg: ASbGncv/u+iS0y5up9jjzLP8+lFZrO2VrJz8AXqdlfAbauxxFlRWD78KKD8xQOrwC3o +2EawwYwBHv75nIJr6BB/GrjyWYR+tD1jxyQw6UE/7xN/PBGnXdx3ET+JuVneZNvE0nU//pvhi+ dRFYq3q0saYB3sXP8JTHwNSRX2TiTlA9x+QSskxF8HwFywRK/TIUMwdtYV4T8100UZOLKgS+Vhc q7lLIEyp8Qw/4Eq+ibso4RWJC8Fr3G+7n8HtzYPcvqXXBj/mF7nJ5mX1ZcSY8E58dBtVeAXlKKJ xhYW1OuVsp5lwrtPR9i1TyZNBI0MiLg= X-Google-Smtp-Source: AGHT+IHMet/slV/sVRHbkbSGWWghuJnC++0pCmETj2WxsmX+/fk8W7s4g7KNnMtjYH7DDkOzwohlVQ== X-Received: by 2002:a05:600c:4f84:b0:434:fec5:4ef5 with SMTP id 5b1f17b1804b1-43668643743mr497181795e9.14.1736193801273; Mon, 06 Jan 2025 12:03:21 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 3/7] accel/tcg: Implement tcg_get_cpus_queue() Date: Mon, 6 Jan 2025 21:02:54 +0100 Message-ID: <20250106200258.37008-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1736193824251116600 Use a specific vCPUs queue for our unique software accelerator. Register the AccelOpsClass::get_cpus_queue() handler. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/tcg-accel-ops.h | 10 ++++++++++ accel/tcg/tcg-accel-ops.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h index 6feeb3f3e9b..7b1d6288742 100644 --- a/accel/tcg/tcg-accel-ops.h +++ b/accel/tcg/tcg-accel-ops.h @@ -13,10 +13,20 @@ #define TCG_ACCEL_OPS_H =20 #include "system/cpus.h" +#include "hw/core/cpu.h" =20 void tcg_cpu_destroy(CPUState *cpu); int tcg_cpu_exec(CPUState *cpu); void tcg_handle_interrupt(CPUState *cpu, int mask); void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); =20 +#ifdef CONFIG_USER_ONLY +#define tcg_cpus_queue cpus_queue +#else +/* Guard with qemu_cpu_list_lock */ +extern CPUTailQ tcg_cpus_queue; +#endif + +#define CPU_FOREACH_TCG(cpu) QTAILQ_FOREACH_RCU(cpu, &tcg_cpus_queue, node) + #endif /* TCG_ACCEL_OPS_H */ diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 6e3f1fa92b2..1fb077f7b38 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -47,6 +47,13 @@ =20 /* common functionality among all TCG variants */ =20 +CPUTailQ tcg_cpus_queue =3D QTAILQ_HEAD_INITIALIZER(tcg_cpus_queue); + +static CPUTailQ *tcg_get_cpus_queue(void) +{ + return &tcg_cpus_queue; +} + void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) { uint32_t cflags; @@ -199,6 +206,7 @@ static inline void tcg_remove_all_breakpoints(CPUState = *cpu) =20 static void tcg_accel_ops_init(AccelOpsClass *ops) { + ops->get_cpus_queue =3D tcg_get_cpus_queue; if (qemu_tcg_mttcg_enabled()) { ops->create_vcpu_thread =3D mttcg_start_vcpu_thread; ops->kick_vcpu_thread =3D mttcg_kick_vcpu_thread; --=20 2.47.1 From nobody Sun Apr 6 20:58:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736193826; cv=none; d=zohomail.com; s=zohoarc; b=K52/D1n6Qg41zZUl4s/6AzP5d4NYjc/Iz5r/Gp7yNGK2X+9BwAc1Jl/YjhkHItSc/jRCcwsK77fAAKB2shzph1oFEpcD4O9qYbD0EADrSf7rEXybWw10QiCZSBBwIiW4NUxefGmrh7p1s4T1JGRYQAeoDXIPXJaPBB8Jzl3KMMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193826; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CfaBEiOdRjHzzwUS3kiFtedqZxggxEJ4hucj9YdleWw=; b=CfQPdDwRCnOhB+bEftCDFPxzNysEHkFj/YlfZgYbjGaxlKC2a1r2xYQhpRFMbfrhH0S7LdolBbLih74wUk2IWj/8aGV2eN3YvARPmX7RaQW4mdX1L9Pzb3l84dezHEeXAIJXCT5WrgCxTw/YEcPUnJ7DCtcWfzWYbJACweClF60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736193826903857.1166804856692; Mon, 6 Jan 2025 12:03:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.865908.1277222 (Exim 4.92) (envelope-from ) id 1tUtJy-0003z4-2j; Mon, 06 Jan 2025 20:03:30 +0000 Received: by outflank-mailman (output) from mailman id 865908.1277222; Mon, 06 Jan 2025 20:03:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJx-0003yK-WA; Mon, 06 Jan 2025 20:03:29 +0000 Received: by outflank-mailman (input) for mailman id 865908; Mon, 06 Jan 2025 20:03:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtJw-0002s4-Va for xen-devel@lists.xenproject.org; Mon, 06 Jan 2025 20:03:28 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4b78297d-cc69-11ef-a0df-8be0dac302b0; Mon, 06 Jan 2025 21:03:28 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43618283d48so106994775e9.1 for ; Mon, 06 Jan 2025 12:03:28 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6cbbsm610646205e9.3.2025.01.06.12.03.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:26 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4b78297d-cc69-11ef-a0df-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193808; x=1736798608; darn=lists.xenproject.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=CfaBEiOdRjHzzwUS3kiFtedqZxggxEJ4hucj9YdleWw=; b=MIXQ1pKaADARQyYOVuz1GkgifJqEgVR4a03UIQuYi3Y88GMHUCxON0rTzcTyTKA7qc ekFXUoqq2XzCX79+rxFhq3PJEHqtgU476Vyn+Yx8bi833Oex+GIM0cr6wJXJxOgbuRKh VZaYAWO6hdQkGTOm7SUTZXKRH7IvHgUWUefNbvz2jRNJbHGUAuEVUOKhl5Q54H7llzSd 4AP2FfRsPUGjB/S0pVWGsJLZul/CdWy4HVZawdps6SDnrhP9rmQYOhNFqmxWFHj3jNZh hd1njrEuygFdFat46h31mx2i1RCyMQumguSinYTrIz0ZOwcmOYevIJ1MygR7CsLKZP9m oEIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193808; x=1736798608; 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=CfaBEiOdRjHzzwUS3kiFtedqZxggxEJ4hucj9YdleWw=; b=vHzCwfqJ0f6cE8Nqe4+0MP9bnrUTnyBVo32QwxvtKtDKSZnrRi3Wcgd4aYFB61NEx/ Ct9wYEdhxoL/L1SICDnRQFVazsMhBf7Wb843JOFViRckZYhHi4SjsobGpoBwyqcFunyw JBfzaYVISulvx7rAJQpAj2CYCMcrttCNqqlqRSoUBSD39gPxq7FJvEBRvBjLKOLQunyD I3/ZGSCAUO5wkc04juBxMIoFO3NKmvDoAnoR8OMTR7fUVcOyhdzy+IhvL1rJVF7pa6tb dWbRNjZw4iSvJajMpy4Zn2Ass0h7Tfm8f5atKq9JB0lF2MdUdQ/bRhCvLakc4Kt7i/OK RJog== X-Forwarded-Encrypted: i=1; AJvYcCUXoKfnmuo8udwCkm/b1/gC6QYZG+rVn8xtSxmRYRzH1dHe7/I987li7EJeMu3MJ/OVx9oONobew4M=@lists.xenproject.org X-Gm-Message-State: AOJu0YyzOfB9xcCWVaaQuVYtJjRXfeEGJ2lFSIMQQDmbfj6q+90D7ucZ Epy0TdAc+EhLkq1GDf/7EpiSSl4RQC9Q7o/EEcOGI8QtMBHMzBVgahuedomkSVI= X-Gm-Gg: ASbGncuVF/s9xaeLkHh70blFvtNIWcOrQTxnQjY6rQRg6ldckAn4zHgx2yUKlvXqtRk ngUhcf7kPeAS+1pNCOz3aXp6tXJ8TheKCL3tgOgZGlShGwy9Mp076mZ3LF/x7T5awITEJFZjY9V gUcCzoQ6PJX5BdO+vskTgGGCXb/nN/llctSlGIanQ6Hpl98VeH/dhHPvKoSMz5dieR1uES2O+ub jfkLS5WJ6VBdVSNraEBi8wQUDruyXNO3b8XQvfviJjYN7+HIcV3iMKXY/pZX7D0LDCW55rWZDc7 qq9sd7YT/rwylPg0EiVolSshrkxtOyU= X-Google-Smtp-Source: AGHT+IF3+buEkSMAzhBuTtka5TQV/I34nAgDx1rHh3g80/cDyG64W7K1EH4+aemix37pseTOETajew== X-Received: by 2002:a05:600c:4f94:b0:434:f871:1b96 with SMTP id 5b1f17b1804b1-43668b7a1dfmr474821135e9.29.1736193807616; Mon, 06 Jan 2025 12:03:27 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 4/7] accel/tcg: Use CPU_FOREACH_TCG() Date: Mon, 6 Jan 2025 21:02:55 +0100 Message-ID: <20250106200258.37008-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1736193828407116600 Only iterate over TCG vCPUs when running TCG specific code. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/cputlb.c | 7 ++++--- accel/tcg/monitor.c | 3 ++- accel/tcg/tb-maint.c | 7 ++++--- accel/tcg/tcg-accel-ops-rr.c | 10 +++++----- accel/tcg/tcg-accel-ops.c | 8 ++++---- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b4ccf0cdcb7..06f34df808b 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -48,6 +48,7 @@ #endif #include "tcg/tcg-ldst.h" #include "tcg/oversized-guest.h" +#include "tcg-accel-ops.h" =20 /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -368,7 +369,7 @@ static void flush_all_helper(CPUState *src, run_on_cpu_= func fn, { CPUState *cpu; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { if (cpu !=3D src) { async_run_on_cpu(cpu, fn, d); } @@ -646,7 +647,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState = *src_cpu, TLBFlushPageByMMUIdxData *d; =20 /* Allocate a separate data block for each destination cpu. */ - CPU_FOREACH(dst_cpu) { + CPU_FOREACH_TCG(dst_cpu) { if (dst_cpu !=3D src_cpu) { d =3D g_new(TLBFlushPageByMMUIdxData, 1); d->addr =3D addr; @@ -839,7 +840,7 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState= *src_cpu, d.bits =3D bits; =20 /* Allocate a separate data block for each destination cpu. */ - CPU_FOREACH(dst_cpu) { + CPU_FOREACH_TCG(dst_cpu) { if (dst_cpu !=3D src_cpu) { p =3D g_memdup(&d, sizeof(d)); async_run_on_cpu(dst_cpu, tlb_flush_range_by_mmuidx_async_1, diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c index ae1dbeb79f8..98bd937ae20 100644 --- a/accel/tcg/monitor.c +++ b/accel/tcg/monitor.c @@ -19,6 +19,7 @@ #include "tcg/tcg.h" #include "internal-common.h" #include "tb-context.h" +#include "tcg-accel-ops.h" =20 =20 static void dump_drift_info(GString *buf) @@ -131,7 +132,7 @@ static void tlb_flush_counts(size_t *pfull, size_t *ppa= rt, size_t *pelide) CPUState *cpu; size_t full =3D 0, part =3D 0, elide =3D 0; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { full +=3D qatomic_read(&cpu->neg.tlb.c.full_flush_count); part +=3D qatomic_read(&cpu->neg.tlb.c.part_flush_count); elide +=3D qatomic_read(&cpu->neg.tlb.c.elide_flush_count); diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 3f1bebf6ab5..8598c59654f 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -36,6 +36,7 @@ #ifdef CONFIG_USER_ONLY #include "user/page-protection.h" #endif +#include "tcg-accel-ops.h" =20 =20 /* List iterators for lists of tagged pointers in TranslationBlock. */ @@ -771,7 +772,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data = tb_flush_count) } did_flush =3D true; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { tcg_flush_jmp_cache(cpu); } =20 @@ -885,13 +886,13 @@ static void tb_jmp_cache_inval_tb(TranslationBlock *t= b) =20 if (tb_cflags(tb) & CF_PCREL) { /* A TB may be at any virtual address */ - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { tcg_flush_jmp_cache(cpu); } } else { uint32_t h =3D tb_jmp_cache_hash_func(tb->pc); =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { CPUJumpCache *jc =3D cpu->tb_jmp_cache; =20 if (qatomic_read(&jc->array[h].tb) =3D=3D tb) { diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 028b385af9a..e5ce285efb9 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -42,7 +42,7 @@ void rr_kick_vcpu_thread(CPUState *unused) { CPUState *cpu; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { cpu_exit(cpu); }; } @@ -116,7 +116,7 @@ static void rr_wait_io_event(void) =20 rr_start_kick_timer(); =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { qemu_wait_io_event_common(cpu); } } @@ -129,7 +129,7 @@ static void rr_deal_with_unplugged_cpus(void) { CPUState *cpu; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { if (cpu->unplug && !cpu_can_run(cpu)) { tcg_cpu_destroy(cpu); break; @@ -160,7 +160,7 @@ static int rr_cpu_count(void) =20 if (cpu_list_generation_id_get() !=3D last_gen_id) { cpu_count =3D 0; - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { ++cpu_count; } last_gen_id =3D cpu_list_generation_id_get(); @@ -201,7 +201,7 @@ static void *rr_cpu_thread_fn(void *arg) qemu_cond_wait_bql(first_cpu->halt_cond); =20 /* process any pending work */ - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { current_cpu =3D cpu; qemu_wait_io_event_common(cpu); } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 1fb077f7b38..371bbaa0307 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -144,7 +144,7 @@ static int tcg_insert_breakpoint(CPUState *cs, int type= , vaddr addr, vaddr len) switch (type) { case GDB_BREAKPOINT_SW: case GDB_BREAKPOINT_HW: - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { err =3D cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL); if (err) { break; @@ -154,7 +154,7 @@ static int tcg_insert_breakpoint(CPUState *cs, int type= , vaddr addr, vaddr len) case GDB_WATCHPOINT_WRITE: case GDB_WATCHPOINT_READ: case GDB_WATCHPOINT_ACCESS: - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { err =3D cpu_watchpoint_insert(cpu, addr, len, xlat_gdb_type(cpu, type), NULL); if (err) { @@ -175,7 +175,7 @@ static int tcg_remove_breakpoint(CPUState *cs, int type= , vaddr addr, vaddr len) switch (type) { case GDB_BREAKPOINT_SW: case GDB_BREAKPOINT_HW: - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { err =3D cpu_breakpoint_remove(cpu, addr, BP_GDB); if (err) { break; @@ -185,7 +185,7 @@ static int tcg_remove_breakpoint(CPUState *cs, int type= , vaddr addr, vaddr len) case GDB_WATCHPOINT_WRITE: case GDB_WATCHPOINT_READ: case GDB_WATCHPOINT_ACCESS: - CPU_FOREACH(cpu) { + CPU_FOREACH_TCG(cpu) { err =3D cpu_watchpoint_remove(cpu, addr, len, xlat_gdb_type(cpu, type)); if (err) { --=20 2.47.1 From nobody Sun Apr 6 20:58:31 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=1736193868; cv=none; d=zohomail.com; s=zohoarc; b=X53Okpt3TbGJrXNE+04fPmGQc8gcYW0BGmtGTqNPfO33mmzewKtBoUDI8jn/0eKKdqI4NM1PiOBKDSc8bpvsxiLUmAuFB/rTsTVqY4Y8eHP8kzWx/WT8kq3QiLoRnCx5jIHybC3Du5l0lMOzgm6eIc4czAjJ/OXRVtrKxklQY5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193868; 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=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; b=CrC5fJdtJiAz9gEIpjs+ZQvxbTC9WC/1Q2qQj2HuwX30Sjnaapa71Ju6gJ0VHELjBzKBtH6O6jKY5gxCNuu5drXvoS+k5c9JL4ChbwOhXUiR+MyGGEfX2TYzU+43mQ+HfwEPA95FEQoyWs+MsEfpcJv9QL7FjpyJAKP00NScJU4= 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 1736193868524555.0285084253925; Mon, 6 Jan 2025 12:04:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtK9-0002ld-1r; Mon, 06 Jan 2025 15:03:41 -0500 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 1tUtK7-0002ja-2f for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:39 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtK3-0003FX-6M for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:38 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-385dece873cso5490594f8f.0 for ; Mon, 06 Jan 2025 12:03:34 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6d02sm618987535e9.1.2025.01.06.12.03.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193813; x=1736798613; 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=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; b=fi+mmOV6FpCWixDy/UGX6sSvUe51RRCle/PhRukH6wdUPnDYzo5O6GqGbFqrXsUgT4 ErIw1js0sFnfGpRJeY3CrpxElC0EG2i5NJPPN7Bw0KRTspIh8jQlk1cuzP+up25QF/Ou gpLWTpU/zTqDWmRnZSms5h+/81azirWJOt0sbfUUK1hjqxhsqrIPCY+XrvBXUltN3wWd mrwwOG2bk4GvHz9MOAbkAz8plix/jy7x6u67/96EtALeJeOEj0HYP5E2M5+6CcUa87a7 wCTRK/k4Zd6N2zA751tGOAq6WelbDkzSkmZE7Hlv1suwR9gEJbS+vKfQQ0P0IYPPHCkA tS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193813; x=1736798613; 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=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; b=gHICRBblk2pnF6BL6l/qw8tzAmkloZLZWQgM6YkwuQ1i7qqhS9H99r7YffVezh6T8M gOEZAb6uOGAU0dkVyqzxTLOlUgQvkkFnRgQSnWLel2fwRpqdIYg0xkbjqIxbUFhbA+sX dAz1ruEmrgzKTkYWWRg4KUllGqwv1Aw/F2c1l5a+JMY1eBPsttvgv9IPggVeR9p7A9x5 jVrd1WHy7epMjialxyGJkXk0FJ3m+zATzeud+HGIMcU1oBJLZAY1uqz02JjR5o0uwl/M vpMZm7ygR9G14h8/in6udMWuS4yS0TTnGloobQ5QQgFlgEnDAzp/iUpgaNZE+DBIS3pu 5OqA== X-Gm-Message-State: AOJu0YzpWaayFW2nSnbUiuO44gMYHU5+6gTWoK5+e1UvLa+qrxUBCGfe gYa59Ya09HNtJQySxHA0Zi7fpo9j+uTTs+NvVlLq8wCECw4ZCf4sfPNbGgXvTmkQnYRMDPzYF80 wpaM= X-Gm-Gg: ASbGncsx5R5jKP8laHfykcMZrLfVnGJfy/NhAea1DWa15jXNFdBrCzEcJyWXWjJ9ymb aj+pBxsCo6TI8xHZeYD7Rm4Cv+tP4n3Jco1LMzDbymYk6w57dJFcZHD5om8cKvg6rSKoKEV40nj 9G5WBAPTQxnErkt119tAH0OREu6xgBa795oUdxzmGqM9bQWgfSYtv7QuWUMYdFyS7iTlTLiEp9I qOiPvVzyixh8aPzHKJsalX1RHHx8hYXDmzLNXk5W5mQbq+y+7pm2Mm5SSXmHjOYHaDNRdg3e3W6 nqTDo6wIaOAQEjSfhstyIY61gEOgplw= X-Google-Smtp-Source: AGHT+IGoS13s7EdoAdq3NUY+QaACk4mt67qvYvBPAyuPr3+V1znGvuXeRZNJwXBUnZIrDNw4J4+93w== X-Received: by 2002:adf:a3d9:0:b0:38a:39ad:3e31 with SMTP id ffacd0b85a97d-38a39ad4128mr24752061f8f.57.1736193813254; Mon, 06 Jan 2025 12:03:33 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 5/7] accel/hw: Implement hw_accel_get_cpus_queue() Date: Mon, 6 Jan 2025 21:02:56 +0100 Message-ID: <20250106200258.37008-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-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::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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=unavailable 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: 1736193871190116600 We can only run a single hardware accelerator at a time, so add a generic hw_accel_get_cpus_queue() helper in accel-system.c, a file common to all HW accelerators. Register AccelOpsClass::get_cpus_queue() for each HW accelerator. Add a generic CPU_FOREACH_HWACCEL() macro. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/hw_accel.h | 9 +++++++++ accel/accel-system.c | 8 ++++++++ accel/kvm/kvm-accel-ops.c | 1 + accel/xen/xen-all.c | 1 + target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 6 files changed, 21 insertions(+) diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h index 380e9e640b6..12664cac6f9 100644 --- a/include/system/hw_accel.h +++ b/include/system/hw_accel.h @@ -2,6 +2,7 @@ * QEMU Hardware accelerators support * * Copyright 2016 Google, Inc. + * Copyright 2025 Linaro Ltd. * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -17,6 +18,14 @@ #include "system/whpx.h" #include "system/nvmm.h" =20 +/* Guard with qemu_cpu_list_lock */ +extern CPUTailQ hw_accel_cpus_queue; + +#define CPU_FOREACH_HWACCEL(cpu) \ + QTAILQ_FOREACH_RCU(cpu, &hw_accel_cpus_queue, node) + +CPUTailQ *hw_accel_get_cpus_queue(void); + void cpu_synchronize_state(CPUState *cpu); void cpu_synchronize_post_reset(CPUState *cpu); void cpu_synchronize_post_init(CPUState *cpu); diff --git a/accel/accel-system.c b/accel/accel-system.c index a7596aef59d..60877ea7a28 100644 --- a/accel/accel-system.c +++ b/accel/accel-system.c @@ -27,9 +27,17 @@ #include "qemu/accel.h" #include "hw/boards.h" #include "system/cpus.h" +#include "system/hw_accel.h" #include "qemu/error-report.h" #include "accel-system.h" =20 +CPUTailQ hw_accel_cpus_queue =3D QTAILQ_HEAD_INITIALIZER(hw_accel_cpus_que= ue); + +CPUTailQ *hw_accel_get_cpus_queue(void) +{ + return &hw_accel_cpus_queue; +} + int accel_init_machine(AccelState *accel, MachineState *ms) { AccelClass *acc =3D ACCEL_GET_CLASS(accel); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index a81e8f3b03b..5f4001860d5 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -93,6 +93,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, voi= d *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->get_cpus_queue =3D hw_accel_get_cpus_queue; ops->create_vcpu_thread =3D kvm_start_vcpu_thread; ops->cpu_thread_is_idle =3D kvm_vcpu_thread_is_idle; ops->cpus_are_resettable =3D kvm_cpus_are_resettable; diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 852e9fbe5fe..ac5ed2dfb80 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -150,6 +150,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, v= oid *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->get_cpus_queue =3D hw_accel_get_cpus_queue; ops->create_vcpu_thread =3D dummy_start_vcpu_thread; } =20 diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index e7b56662fee..bb407c68e14 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -84,6 +84,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, vo= id *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->get_cpus_queue =3D hw_accel_get_cpus_queue; ops->create_vcpu_thread =3D nvmm_start_vcpu_thread; ops->kick_vcpu_thread =3D nvmm_kick_vcpu_thread; =20 diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-acce= l-ops.c index ab2e014c9ea..191214ca81d 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -86,6 +86,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, vo= id *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->get_cpus_queue =3D hw_accel_get_cpus_queue; ops->create_vcpu_thread =3D whpx_start_vcpu_thread; ops->kick_vcpu_thread =3D whpx_kick_vcpu_thread; ops->cpu_thread_is_idle =3D whpx_vcpu_thread_is_idle; --=20 2.47.1 From nobody Sun Apr 6 20:58:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736193837; cv=none; d=zohomail.com; s=zohoarc; b=CCeItdYuzJqgbUhgBxceWUBM/CWvnWCeRZHzfFf4X37E55lPjTTPqSRRfRjlkhys+H0Rb+nhaKCf5qhpVa8JQSl9QTEh8YrF39zL80fSb1ebnhcJw5+mpG7BJSphRRjJZEWpDOC2jgTpoz1qLtirTkRbxrf0+0Y98z/36sM+xMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193837; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sQToL39oc1IIGRZ4x4DJpAbte9qYHUOsWxQUB+w3STI=; b=LN/KeOUDf+MDsu1yUm03YuBapLytZSb/jrYIiSusHQGr2hX2xggsyEfg+1aBUvhKnCu27GMBu4QCLn0WHeoi4/Z5YB803XjFYdBEfkwaZrT3MVqvRMh5l6aHs3LSk5gT8VghkVY7EI9Ur08sBNFeHABGU/wAD1bq1qei4KG9f2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736193837957564.7327335370807; Mon, 6 Jan 2025 12:03:57 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.865922.1277242 (Exim 4.92) (envelope-from ) id 1tUtKA-00052o-Le; Mon, 06 Jan 2025 20:03:42 +0000 Received: by outflank-mailman (output) from mailman id 865922.1277242; Mon, 06 Jan 2025 20:03:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtKA-00052h-I9; Mon, 06 Jan 2025 20:03:42 +0000 Received: by outflank-mailman (input) for mailman id 865922; Mon, 06 Jan 2025 20:03:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tUtK9-0002e6-26 for xen-devel@lists.xenproject.org; Mon, 06 Jan 2025 20:03:41 +0000 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [2a00:1450:4864:20::32e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 52257aff-cc69-11ef-99a4-01e77a169b0f; Mon, 06 Jan 2025 21:03:39 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43634b570c1so106121915e9.0 for ; Mon, 06 Jan 2025 12:03:39 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4367086e40esm543882975e9.30.2025.01.06.12.03.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:38 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 52257aff-cc69-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193819; x=1736798619; darn=lists.xenproject.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=sQToL39oc1IIGRZ4x4DJpAbte9qYHUOsWxQUB+w3STI=; b=HnqsJLY5AhpCusyHICdrnD9l2+FE6W4BU5T/X9zrZ7qLjjHfQ9f46rVUrUQjVW63pm G0Wn4dFFWuDuIfzGJ3ZfqOK3kRUHkxUEWdFNxMXLbsUL2f+XGgvGChMXucFLyagnzQD9 PfTV5dYPLE9a2wUMN31ttgZwCB+tb7Qzwyxx066ceG+1/ec/c/o+3C5zPwaxP4lWirlQ JJnE3OvN9Vj1/JWbIHr5r/VxSc8b01tGOh+Um/LBjLOBxJ/W2xG6oIfQr2lJpZn+sL9N RR/CY2wD4mm+YsWe0ybROGt5HiQJnS7qkCqgIcvAZcqVCrdvyjYPPKhCVcMQjm94SOlA ZKLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193819; x=1736798619; 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=sQToL39oc1IIGRZ4x4DJpAbte9qYHUOsWxQUB+w3STI=; b=nKkm3VF7Mmc+4hCQvVpZpCX2kIB0u27lQEo+5C6vDiA8M11o/kWn2fviZyricED/6A 3ehbJhY7IWC93xZNFpWYnjNRcG4mNdZctrTavO4aue6YGGoTaWVvxU7ySJ+hBW49BPz/ u4N9Trzq2cBvVuvaVDv8u2oZe1JYNWRwW9iDUCiHkaR84Qu/qkUqP5ZZpCBKtFB057UJ pGLUIQZnNOuR6KoXhMlDI5wuCteKagZU1xNHHjl6liWK5YwgcbLvByLm13m7VR4tvknW Qj8Ey6Ih/NIXPm1XouECU9LYBy7vFaFH9xn5QFo4O2eZtC+U/d0x17G0M1FPrwL3jk0o NJrQ== X-Forwarded-Encrypted: i=1; AJvYcCXWSxqcku9QthEC58td0ig9rH8803QMxBlISvRqWg+XOirBqeuPejB1WIf/iKvVWI67GYIexU3HGHQ=@lists.xenproject.org X-Gm-Message-State: AOJu0Yzk0R0fBiUZrvt0fp286EKr+uqjDx/mgh/1n9NMy3yOaiYf1cNv MB+mEEt1YRGlg4HSMctEWmv1gOIpKJia6MzFkjWxNri8EYA54P/M5N8iJ8S5auU= X-Gm-Gg: ASbGncsnJwKZZP2Q+L/OpsXqXwEtJK9y8VHbWCu9fWGxCtnzlcNSVUOO9IOYxu45pBs HPsTPh2rmxpdhgD5yGiDP4A6KzjeDK02WwiGHgiD8b5PGLrPzHVx8XrWmwaa/gURae7kOiGqHxl gDIsqaNnQPWqmSkhihkedl53QIY/9ChHEiREYiJRFmfrpVH9TC+GZyp8DMycuIRwfk6YohCZVPH x2RuFNydphYUBkkUazj4pX9xLAP1TDLn1nIbRGjZKkOK6YwzL0gsrYMy3nKFULyabruNbT5K1v7 MEukR9hqNJ9QKqu7ot1sXkcu80qsK4w= X-Google-Smtp-Source: AGHT+IFXiDdVgmnTH4sfktC8/xKNinP6K1bHXh0LE5bFlepNSrMiJFLvtHvHs4neclwfX3Zl5Vm/Iw== X-Received: by 2002:a05:600c:5112:b0:434:faa9:5266 with SMTP id 5b1f17b1804b1-436c2b5b491mr121041605e9.13.1736193818909; Mon, 06 Jan 2025 12:03:38 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 6/7] accel/hvf: Use CPU_FOREACH_HVF() Date: Mon, 6 Jan 2025 21:02:57 +0100 Message-ID: <20250106200258.37008-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1736193838349116600 Only iterate over HVF vCPUs when running HVF specific code. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/hvf_int.h | 4 ++++ accel/hvf/hvf-accel-ops.c | 9 +++++---- target/arm/hvf/hvf.c | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index 42ae18433f0..3cf64faabd1 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -11,6 +11,8 @@ #ifndef HVF_INT_H #define HVF_INT_H =20 +#include "system/hw_accel.h" + #ifdef __aarch64__ #include typedef hv_vcpu_t hvf_vcpuid; @@ -74,4 +76,6 @@ int hvf_put_registers(CPUState *); int hvf_get_registers(CPUState *); void hvf_kick_vcpu_thread(CPUState *cpu); =20 +#define CPU_FOREACH_HVF(cpu) CPU_FOREACH_HWACCEL(cpu) + #endif diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 945ba720513..bbbe2f8d45b 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -504,7 +504,7 @@ static int hvf_insert_breakpoint(CPUState *cpu, int typ= e, vaddr addr, vaddr len) } } =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_HVF(cpu) { err =3D hvf_update_guest_debug(cpu); if (err) { return err; @@ -543,7 +543,7 @@ static int hvf_remove_breakpoint(CPUState *cpu, int typ= e, vaddr addr, vaddr len) } } =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_HVF(cpu) { err =3D hvf_update_guest_debug(cpu); if (err) { return err; @@ -560,7 +560,7 @@ static void hvf_remove_all_breakpoints(CPUState *cpu) QTAILQ_FOREACH_SAFE(bp, &hvf_state->hvf_sw_breakpoints, entry, next) { if (hvf_arch_remove_sw_breakpoint(cpu, bp) !=3D 0) { /* Try harder to find a CPU that currently sees the breakpoint= . */ - CPU_FOREACH(tmpcpu) + CPU_FOREACH_HVF(tmpcpu) { if (hvf_arch_remove_sw_breakpoint(tmpcpu, bp) =3D=3D 0) { break; @@ -572,7 +572,7 @@ static void hvf_remove_all_breakpoints(CPUState *cpu) } hvf_arch_remove_all_hw_breakpoints(); =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_HVF(cpu) { hvf_update_guest_debug(cpu); } } @@ -581,6 +581,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, v= oid *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->get_cpus_queue =3D hw_accel_get_cpus_queue; ops->create_vcpu_thread =3D hvf_start_vcpu_thread; ops->kick_vcpu_thread =3D hvf_kick_vcpu_thread; =20 diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0afd96018e0..13400ff0d5f 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2269,10 +2269,10 @@ static void hvf_arch_set_traps(void) =20 /* Check whether guest debugging is enabled for at least one vCPU; if = it * is, enable exiting the guest on all vCPUs */ - CPU_FOREACH(cpu) { + CPU_FOREACH_HVF(cpu) { should_enable_traps |=3D cpu->accel->guest_debug_enabled; } - CPU_FOREACH(cpu) { + CPU_FOREACH_HVF(cpu) { /* Set whether debug exceptions exit the guest */ r =3D hv_vcpu_set_trap_debug_exceptions(cpu->accel->fd, should_enable_traps); --=20 2.47.1 From nobody Sun Apr 6 20:58:32 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=1736193932; cv=none; d=zohomail.com; s=zohoarc; b=G0oY1IZB9fHDzVJWABWwD4EYn1oRKLi0qZTUxtoiN3SEYSKf3PtvJ9row3OuwqVzgfBH3Xwpscf2nlLJFAla/lpmmH7d/SM6xZfrWSNDgEDNRd6neOU4FLpX1rUAdKjfigU9zmecO9mxqXDNyR6m40tS+bzJ2m7XCsuAYZNIfAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736193932; 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=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; b=iMYdWOAPJpKiAGc9EKwtQ7mjiXHFIGxfrxG2nDGoG1jFV2YrZtAKLAIrjPybFraUci5YiDOOgFZPcQcLjzSsBNfSsQDWyTlVnvfbC7whPLbBX7LD7n9ihwyWvWtg17MEuLa0TP/J6f0y2+IaxvEAJ7+AnzvgIzfoz+u3/KA58fE= 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 1736193931969312.5200316865747; Mon, 6 Jan 2025 12:05:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtKN-0002sP-78; Mon, 06 Jan 2025 15:03:55 -0500 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 1tUtKK-0002qF-PC for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:52 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtKH-0003cP-BD for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:52 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso14193128f8f.2 for ; Mon, 06 Jan 2025 12:03:48 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436723cb159sm525092965e9.16.2025.01.06.12.03.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193828; x=1736798628; 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=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; b=LBR/DXZRmSrzf6cNzKaXGzcg5zmJ7W8SRehar81uDGTmoZKgNXjqnmSMUvumBQrO/R sVm4d7K+uRJjwivKq2IARdDmn+wrFhIjdwM8eX+M7eS7FVh90eudcFo+XWw5sLQ4khZW l6uv2wKASPzPy8Y3GDGJWO7s+AMhfhJoMNBfBvjIZIzfQIeUa2lk/ELfjUUugXE4MvBv 3I7akvh9HzQTjLA5UXgX1O1MJUioU0NdS8924IenP/Icii1RQqDOGKBEvlX1KXI/sPZi ySEmN++NXtqf69DxjGpM382IhL8wTQ7CXTAAQ+j3RoQdKltV5Y8HaG4w77Rj9rpilhsG Gubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193828; x=1736798628; 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=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; b=cepJNaGUr6jx/FWifNIkbWGKbX0iVrHIQR+5CK5PyRHqxg+Y8c4037gZrngcVFNBpD +oUcbHyvtLz3SOqnnE2k+xyvKc0TEobPwut7Zt30pxZCbL4iH4AViK+rAXN5BYpw2otT 7CAsavC6PXIWpwx0O9GXA7TF5VYX6l5slGBgya4nobsN7tdQQiI56twwe7JGdXO0lWFm L3BmontxAQD+spaKJ8QGjYTkE0+hKKq7rq3MVX6rmEZ2wV85g4buNC5jSXk+qIhCw7Uw on9uYoQ9PpFnVzb5smud8DyWfWgXddsHGoCgRI6XfWgAKRtFbEhQ4u4jI6PWjsCs8hyf kGrw== X-Gm-Message-State: AOJu0Yxf9p+4Hyl/FxB6Q5u87IhjDD2XdPR7X61503LgMvssSw0ZnMqx YdNNstYR7n3zDlQoO1/pHnpZDKPXtxRbngdWnJFD3RXTPmvfUim0nrAwUrInHiLKMZvQzbqd9FJ oyfo= X-Gm-Gg: ASbGncszjujSgWa67lJgRVVe/jxZ/TL3ZNIQtNDbjkZNmubaDjfxirJbg7MTitLSyvM S0kiEu2NO73gcwDqxMimYIde8J3LoSxrmT7hkt5Pa5lhgQRG9H/8Zoyvb7BB6HROg+W0rUbIMpm TVFr0AzjttOZokyy3TChidq6A6n6RgST18APY4W8UASm+wHo7369zE71DvIwyYb3QHSb/goeMQt AOBGOqmKHIALkBqNVy9nnC4ba6sywc1WSRA031pLxcs4JkROJYhPmXJbRM++Y3PTnwRYyffoiIr 0fugErAFYzOQ3HbHlC17oD1uqdpzoZY= X-Google-Smtp-Source: AGHT+IHDE/cbM5Uz3mC6dPWI+SKnpmJxnVL7+eC7vPChMfg/0MfF0CSgk918tvS7UmQNdLQuffdZDw== X-Received: by 2002:a5d:6c64:0:b0:385:f6f4:f8e with SMTP id ffacd0b85a97d-38a223ff1cemr40988273f8f.50.1736193825978; Mon, 06 Jan 2025 12:03:45 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 7/7] accel/kvm: Use CPU_FOREACH_KVM() Date: Mon, 6 Jan 2025 21:02:58 +0100 Message-ID: <20250106200258.37008-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-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::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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=unavailable 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: 1736193932992116600 Only iterate over KVM vCPUs when running KVM specific code. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/kvm_int.h | 3 +++ accel/kvm/kvm-all.c | 14 +++++++------- hw/i386/kvm/clock.c | 3 ++- hw/intc/spapr_xive_kvm.c | 5 +++-- hw/intc/xics_kvm.c | 5 +++-- target/i386/kvm/kvm.c | 4 ++-- target/i386/kvm/xen-emu.c | 2 +- target/s390x/kvm/kvm.c | 2 +- target/s390x/kvm/stsi-topology.c | 3 ++- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/system/kvm_int.h b/include/system/kvm_int.h index 4de6106869b..0ef4c336b18 100644 --- a/include/system/kvm_int.h +++ b/include/system/kvm_int.h @@ -13,6 +13,7 @@ #include "qapi/qapi-types-common.h" #include "qemu/accel.h" #include "qemu/queue.h" +#include "system/hw_accel.h" #include "system/kvm.h" #include "hw/boards.h" #include "hw/i386/topology.h" @@ -168,6 +169,8 @@ struct KVMState char *device; }; =20 +#define CPU_FOREACH_KVM(cpu) CPU_FOREACH_HWACCEL(cpu) + void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id, const char = *name); =20 diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c65b790433c..9b26b286865 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -872,7 +872,7 @@ static uint64_t kvm_dirty_ring_reap_locked(KVMState *s,= CPUState* cpu) if (cpu) { total =3D kvm_dirty_ring_reap_one(s, cpu); } else { - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { total +=3D kvm_dirty_ring_reap_one(s, cpu); } } @@ -935,7 +935,7 @@ static void kvm_cpu_synchronize_kick_all(void) { CPUState *cpu; =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvm_cpu_synchronize_kick, RUN_ON_CPU_NULL); } } @@ -3535,7 +3535,7 @@ int kvm_insert_breakpoint(CPUState *cpu, int type, va= ddr addr, vaddr len) } } =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { err =3D kvm_update_guest_debug(cpu, 0); if (err) { return err; @@ -3574,7 +3574,7 @@ int kvm_remove_breakpoint(CPUState *cpu, int type, va= ddr addr, vaddr len) } } =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { err =3D kvm_update_guest_debug(cpu, 0); if (err) { return err; @@ -3592,7 +3592,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { if (kvm_arch_remove_sw_breakpoint(cpu, bp) !=3D 0) { /* Try harder to find a CPU that currently sees the breakpoint= . */ - CPU_FOREACH(tmpcpu) { + CPU_FOREACH_KVM(tmpcpu) { if (kvm_arch_remove_sw_breakpoint(tmpcpu, bp) =3D=3D 0) { break; } @@ -3603,7 +3603,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) } kvm_arch_remove_all_hw_breakpoints(); =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { kvm_update_guest_debug(cpu, 0); } } @@ -4384,7 +4384,7 @@ static void query_stats_cb(StatsResultList **result, = StatsTarget target, stats_args.result.stats =3D result; stats_args.names =3D names; stats_args.errp =3D errp; - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { if (!apply_str_list_filter(cpu->parent_obj.canonical_path, tar= gets)) { continue; } diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 63be5088420..f2638cf2c22 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -17,6 +17,7 @@ #include "qemu/host-utils.h" #include "qemu/module.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "system/runstate.h" #include "system/hw_accel.h" #include "kvm/kvm_i386.h" @@ -196,7 +197,7 @@ static void kvmclock_vm_state_change(void *opaque, bool= running, if (!cap_clock_ctrl) { return; } - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvmclock_ctrl, RUN_ON_CPU_NULL); } } else { diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 26d30b41c15..08354f08512 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -14,6 +14,7 @@ #include "target/ppc/cpu.h" #include "system/cpus.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "system/runstate.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" @@ -678,7 +679,7 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_= id) * 'post_load' handler of XiveTCTX because the machine is not * necessarily connected to the KVM device at that time. */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 ret =3D kvmppc_xive_cpu_set_state(spapr_cpu_state(cpu)->tctx, &loc= al_err); @@ -795,7 +796,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, kvmppc_xive_change_state_handler, xive); =20 /* Connect the presenters to the initial VCPUs of the machine */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 ret =3D kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp); diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index ee72969f5f1..aed2ad44363 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -29,6 +29,7 @@ #include "qapi/error.h" #include "trace.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" #include "hw/ppc/xics.h" @@ -418,7 +419,7 @@ int xics_kvm_connect(SpaprInterruptController *intc, ui= nt32_t nr_servers, kvm_gsi_direct_mapping =3D true; =20 /* Create the presenters */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), &local_err); @@ -434,7 +435,7 @@ int xics_kvm_connect(SpaprInterruptController *intc, ui= nt32_t nr_servers, } =20 /* Connect the presenters to the initial VCPUs of the machine */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); icp_set_kvm_state(spapr_cpu_state(cpu)->icp, &local_err); if (local_err) { diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2f66e63b880..437911d6c6a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -329,7 +329,7 @@ void kvm_synchronize_all_tsc(void) CPUState *cpu; =20 if (kvm_enabled()) { - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvm_synchronize_tsc, RUN_ON_CPU_NULL); } } @@ -2847,7 +2847,7 @@ static void *kvm_msr_energy_thread(void *data) * Identify the vcpu threads * Calculate the number of vcpu per package */ - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { for (int i =3D 0; i < num_threads; i++) { if (cpu->thread_id =3D=3D thd_stat[i].thread_id) { thd_stat[i].is_vcpu =3D true; diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index e81a2458812..36ae9c11252 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -1422,7 +1422,7 @@ int kvm_xen_soft_reset(void) return err; } =20 - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { async_run_on_cpu(cpu, do_vcpu_soft_reset, RUN_ON_CPU_NULL); } =20 diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index db645a48133..a02e78ce807 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1559,7 +1559,7 @@ static void handle_diag_318(S390CPU *cpu, struct kvm_= run *run) return; } =20 - CPU_FOREACH(t) { + CPU_FOREACH_KVM(t) { run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(diag318_info)); } diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topol= ogy.c index c8d6389cd87..cf1a9b5d218 100644 --- a/target/s390x/kvm/stsi-topology.c +++ b/target/s390x/kvm/stsi-topology.c @@ -10,6 +10,7 @@ #include "cpu.h" #include "hw/s390x/sclp.h" #include "hw/s390x/cpu-topology.h" +#include "system/kvm_int.h" =20 QEMU_BUILD_BUG_ON(S390_CPU_ENTITLEMENT_LOW !=3D 1); QEMU_BUILD_BUG_ON(S390_CPU_ENTITLEMENT_MEDIUM !=3D 2); @@ -256,7 +257,7 @@ static void s390_topology_fill_list_sorted(S390Topology= List *topology_list) =20 QTAILQ_INSERT_HEAD(topology_list, &sentinel, next); =20 - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { S390TopologyId id =3D s390_topology_from_cpu(S390_CPU(cs)); S390TopologyEntry *entry =3D NULL, *tmp; =20 --=20 2.47.1