From patchwork Thu May 30 19:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 800208 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp401386wrw; Thu, 30 May 2024 12:43:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUlAdSrGkuHAmyzPyvsTQjJU3vIteWNg8euTsii2ggcOOkglBM4uRP/zjLLoZhKQ6/ghtj/0WtcWNgxyzQLxwAF X-Google-Smtp-Source: AGHT+IHji5TxEvwJo/uN4LL4NV+jJi7qfFLlZ8/bc6aqZolxypsMiML4z9xZcbNBXpXxaKaGI3LM X-Received: by 2002:a05:6808:98f:b0:3c9:736b:4016 with SMTP id 5614622812f47-3d1dcd1aebfmr3206780b6e.42.1717098227048; Thu, 30 May 2024 12:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717098227; cv=none; d=google.com; s=arc-20160816; b=oEf1PXWgQgjWRVsVBG74GzTw8r6H0pyrSU3Ll1lGHp7OWG/SC8ON/31Zzy3mMz06rA AKbtDkCsnadMdhTzrTckDvgUkSMCG1aoVyySD5lWPzhLRVW/E3AmjGqP14DJWKgk9CsE svZPvMv500lK+rXCHAUSLMxptWJstUfYJH6uwLTRv1emjKwSCYUcxcQRQ+/c5RT3FPZF U+fyx1iZjy4l3ooKQybpeCFa8dVcK4LDqPoBh7VwypFjK8RkUkTDnbG4NMY2ZxLPJ5sD aunpVMtMHBlKxhFE+U9Vd3Qmml+Gy0H6BCBps80oQqCGSJPpO7jqd2ztvmdIk+I1lfEk 0hQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uF3iE8sM7cMEjCs0SvCbRt/oMMRILi0hvudECvvT8YU=; fh=aWK/WapK4xf8SGfzgOGJ7AoHDKO+C0u8XFOVHWsQNds=; b=JqqkEmldYf228Get02RNaGFDpeqR22+mnHpmbsvYu8ex6Ip1ZUZOQtk1vtFRPH+jTP uNzvXFHIkSSbBn6urkIIZQl5LWeKM9mo6WoyxYGk3lcyRZkBSAFx3sKqgYgfxH8lUEKr +99A66Fy+3rXQKcQd/bwsQDivxpDiLcfEJ4jDILBp5AvrTwC06w3VI73yfqBPhl3eRO0 jpFNPeLnDSNFabdjTkToz4nxxJBhOQn1iww3Mt41URg5CgsShknn81ixUvN8ETHttFeF WczXA0ug+yXB2uT1tT4yMlWKItbcH2KWbCFO+nW+73dgCJUNmRhL5cyU3zQwk/eTJv9l c67Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qyqnuRw7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b402213si3365346d6.255.2024.05.30.12.43.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 12:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qyqnuRw7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sClfx-0005cq-RG; Thu, 30 May 2024 15:43:01 -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 1sClfw-0005bp-0k for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:00 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sClft-0006HI-0q for qemu-devel@nongnu.org; Thu, 30 May 2024 15:42:59 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a6267778b3aso104624566b.3 for ; Thu, 30 May 2024 12:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717098172; x=1717702972; 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=uF3iE8sM7cMEjCs0SvCbRt/oMMRILi0hvudECvvT8YU=; b=qyqnuRw7c9bVN8zdLBqsDWexKpOqpQDHUBq13VWQC5/mBjqMLXTQCl8r/eMW6tZPz7 AIEy3MPSaqNaEImXCv1E4LqwBQvzS+6qrFUiOE8NFyoC3G/WTTHMCIU4Ne4Rn9LhHNnO XgXhdQh40IqxMs5A6TP6A7C03N9njojNxWnNFW1IQdY0//teAv0ZujUjhhUOw7lq0PcJ spAskfD2MCQ7cmnetjhDOAjN2h7NREBUDE58qg7kUUS3STkANlMaRhl32AAaevOvmBid lFlR1rvMHgD6ichbgygacVFh5cxIqb0AbMxtx6TT6IZvSxF3J28kR/4YkwE/PO/jNeyL sHHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717098172; x=1717702972; 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=uF3iE8sM7cMEjCs0SvCbRt/oMMRILi0hvudECvvT8YU=; b=LacK8uiUPGax5/XEKUcnVaDKSCTJSjKfyBvlrsz+uLc+GkWS6ZFLxbcaz2M3XWq5sL VuLZq1h8QnSFO044Pz6EJ72Tt4PbB9cz5B6KjQmioLdLtURjWhBVrFigPllVgo5YJcqT 6tsP7AecLeeMuZqjKKGmRsVjAEjOcRwcfAdrlcd631KaAlo9eOelPWh2NvCvSLJWHd3j WPdl7P+YxYQf7yPnfhub1wKAigOx6ONURfri3v7CEBEwzHKlYMf0wVdGF1hEGJ5T/4RT KQ91Ta5+35a49pM72pZz1wB20h0MfJzoqPVSz5kCgmMa38bBw/KvYBLHuGoiTzhs5fwt GbTg== X-Gm-Message-State: AOJu0YyeJERyLOX/n3VTjIUyv1rntjYWotfYMZznRgAobwgEqBJhS09D 3sZgxMZqLK1cf1k2Xv3veon6Y01DR63qjEk7E+IniUrqRe2bwmLSpi6wpu8Lb4E= X-Received: by 2002:a17:906:ae8f:b0:a66:ebc8:ad2c with SMTP id a640c23a62f3a-a66ebd812e1mr100669966b.42.1717098171713; Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67e73faa76sm8314766b.75.2024.05.30.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A25505F8D5; Thu, 30 May 2024 20:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Cameron Esfahani , Alexandre Iooss , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Sunil Muthuswamy , Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Mahmoud Mandour , Reinoud Zandijk , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, Roman Bolshakov Subject: [PATCH 1/5] hw/core: expand on the alignment of CPUState Date: Thu, 30 May 2024 20:42:46 +0100 Message-Id: <20240530194250.1801701-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530194250.1801701-1-alex.bennee@linaro.org> References: <20240530194250.1801701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x635.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Make the relationship between CPUState, ArchCPU and cpu_env a bit clearer in the kdoc comments. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index bb398e8237..35d345371b 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -391,7 +391,8 @@ struct qemu_work_item; #define CPU_UNSET_NUMA_NODE_ID -1 /** - * CPUState: + * struct CPUState - common state of one CPU core or thread. + * * @cpu_index: CPU index (informative). * @cluster_index: Identifies which cluster this CPU is in. * For boards which don't define clusters or for "loose" CPUs not assigned @@ -439,10 +440,15 @@ struct qemu_work_item; * @kvm_fetch_index: Keeps the index that we last fetched from the per-vCPU * dirty ring structure. * - * State of one CPU core or thread. + * @neg_align: The CPUState is the common part of a concrete ArchCPU + * which is allocated when an individual CPU instance is created. As + * such care is taken is ensure there is no gap between between + * CPUState and CPUArchState within ArchCPU. * - * Align, in order to match possible alignment required by CPUArchState, - * and eliminate a hole between CPUState and CPUArchState within ArchCPU. + * @neg: The architectural register state ("cpu_env") immediately follows CPUState + * in ArchCPU and is passed to TCG code. The @neg structure holds some + * common TCG CPU variables which are accessed with a negative offset + * from cpu_env. */ struct CPUState { /*< private >*/ From patchwork Thu May 30 19:42:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 800207 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp401389wrw; Thu, 30 May 2024 12:43:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLeSn0Cs8Nm3P8JiSZ5I7v6Jqc5jbUn9Aa2Yx1i93bwUBK8aHgr2hBQOn3jTqi1633WgI4UeLTUO+lAdy33pXB X-Google-Smtp-Source: AGHT+IEIzjPZrH9LSIdyF4PISv0Pu2+G08q2kY77hPY/eyxWQLpT/xNli9LTTfk4+ue9AOzvtyVC X-Received: by 2002:a05:620a:424c:b0:790:9f13:2ed0 with SMTP id af79cd13be357-794eaf06636mr528688185a.22.1717098227437; Thu, 30 May 2024 12:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717098227; cv=none; d=google.com; s=arc-20160816; b=qi7iioClNqR8na0qvnDEupttekBG8ZjgDTnwYHW6fsK0yjx0/nwuAi0fD6aMXcxqX2 5XcyGMddui35uuBP0+FEAE5qKxTPSfSX/KbbCVXzJbAqzs+3IVcViRCx3wU2zN2z0JYA hHqVC5rB5QhrWB+CoI2zSbGyamA2F5DiB/IdIJNcALisZ4dp9MLYRyVS4cc8jvQ7CTLZ tyemkAdi0Rs1A0g9Dmy7MujEa+6J5LrS3Iyqkp6kt+/Vsm4d/oZfTu3GmI5HOrDmwhyb 3nz0+OtpeJg2PQsjXbzUoRajjunv/7+jlSkFHqB8GfpE/4C3gq0BUe6YzcTPCKejtmNP uYZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cnc+k2fYpUESVUzqiNhwI1EEtv65T/mceqpj8jrBceI=; fh=aWK/WapK4xf8SGfzgOGJ7AoHDKO+C0u8XFOVHWsQNds=; b=suM0/T1nygF4A0pqAw7IwREw3Bkhr7eN/HF1pSicM40EUbexW0Sczo2sFltEXUHZwm TmZvuCCayccgcQIs2a3H20MOzICJfJoqvRJ+gmp1uNC9zudc2eQpHLpyZSC0ncOtbwgN 0Bpmpjpwc4fS4jUTb3x/EHiOGlkLklELnXoPmfh4ujqKRo+tT1AkgMwLRJIlFikuZA56 47bhlvmhx4TFJuxNCifY02FgtkWVAycixFJGW8eDXdqfNEUd/gRhrmCaNA+J9svQ2R9G VDfyugc10n0cMkBjzqVDKdUAN51rHg1ko8Z/g385vu3RchNXrDE6BknC+mARBEzZnIR5 LJBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TPGsivEk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-794f32a331csi26860785a.549.2024.05.30.12.43.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 12:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TPGsivEk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sClfy-0005dO-Fy; Thu, 30 May 2024 15:43:02 -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 1sClfw-0005cB-BP for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:00 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sClft-0006HT-0G for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:00 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a667e104375so92875566b.1 for ; Thu, 30 May 2024 12:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717098173; x=1717702973; 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=Cnc+k2fYpUESVUzqiNhwI1EEtv65T/mceqpj8jrBceI=; b=TPGsivEkah+YWZfFOWdgKXB/8asyeaKesCUHcB7OcvcQ1Yb6WnI//SMBdvamuK+k0R ryYMti2/NsEMavvSu2N5T4yarHy9b8YwEep3mAsDOlC2RlaNuPktzXjEa1Ib6SNQPESK /ULFBjb6lE3zT/nsiwYBwmGCHxAwB82Q56P9vC/Nceu5OSOapCiRDGKA8KHWdfZz88qh nJshlUTHHWjllyNo+HiX9umJnoOqW2FEMmWGYDnpS2rJKYU6XzfmJMM5EhSxCQiEDm5e hNLrK7A19MKy5fviIUVI04evcuiOt8p84jh60++Syq1HZhtRpOXcf2i4XkcJ6Az++8wg jBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717098173; x=1717702973; 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=Cnc+k2fYpUESVUzqiNhwI1EEtv65T/mceqpj8jrBceI=; b=MqghTdIEWicNxlJvTOfQyu0J5qJpBmPnN077S1m6fp4PNMAS4fAhyt7evUQd10rTlU 4/Im7P2XBSNCGzYmWXL8FwePmJBdhMneX1xeTfyyCMT55csgUJUVx/j1+7nyUDjMU+Mu j8N9IGTKHMN+zWNsdNmAB1zE89P+99jFPW/ZdBGQz4+09Rvo1Zzc+SDkz9UdMw0f33w0 GBb5udPzdvx+6a0RqHzJXI2I9fwui18sCy4ey9Pw6vzu+ruvIn2XRqDae0qtk7F0NemH d29Qce3vizvqawzxUOxvqr/AOzTYrci5XqL2BsBywF9ctjpAqXKXsUtZonZcs8cV8BX1 WnpQ== X-Gm-Message-State: AOJu0YwJZ3Vvc3j7wcNxUr1yIdPE0x7YB1HdzlolKGPuuQbS2FHtuxBM 9pzFzKHB3pX1NkB11d3szNvCporOHaBMIM4l+X+tGlINF0PGabuonbZlB4kcuWw= X-Received: by 2002:a17:906:d1c9:b0:a67:aa2b:1032 with SMTP id a640c23a62f3a-a67aa2b10f1mr32855366b.28.1717098173261; Thu, 30 May 2024 12:42:53 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67ea67b4f8sm7831766b.102.2024.05.30.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C35165F8E3; Thu, 30 May 2024 20:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Cameron Esfahani , Alexandre Iooss , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Sunil Muthuswamy , Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Mahmoud Mandour , Reinoud Zandijk , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, Roman Bolshakov Subject: [PATCH 2/5] cpu: move Qemu[Thread|Cond] setup into common code Date: Thu, 30 May 2024 20:42:47 +0100 Message-Id: <20240530194250.1801701-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530194250.1801701-1-alex.bennee@linaro.org> References: <20240530194250.1801701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Aside from the round robin threads this is all common code. By moving the halt_cond setup we also no longer need hacks to work around the race between QOM object creation and thread creation. It is a little ugly to free stuff up for the round robin thread but better it deal with its own specialises than making the other accelerators jump through hoops. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 4 ++++ accel/dummy-cpus.c | 3 --- accel/hvf/hvf-accel-ops.c | 4 ---- accel/kvm/kvm-accel-ops.c | 3 --- accel/tcg/tcg-accel-ops-mttcg.c | 4 ---- accel/tcg/tcg-accel-ops-rr.c | 14 +++++++------- hw/core/cpu-common.c | 5 +++++ target/i386/nvmm/nvmm-accel-ops.c | 3 --- target/i386/whpx/whpx-accel-ops.c | 3 --- 9 files changed, 16 insertions(+), 27 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 35d345371b..a405119eda 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -404,10 +404,14 @@ struct qemu_work_item; * @tcg_cflags: Pre-computed cflags for this cpu. * @nr_cores: Number of cores within this CPU package. * @nr_threads: Number of threads within this CPU core. + * @thread: Host thread details, only live once @created is #true + * @sem: WIN32 only semaphore used only for qtest + * @thread_id: native thread id of vCPU, only live once @created is #true * @running: #true if CPU is currently running (lockless). * @has_waiter: #true if a CPU is currently waiting for the cpu_exec_end; * valid under cpu_list_lock. * @created: Indicates whether the CPU thread has been successfully created. + * @halt_cond: condition variable sleeping threads can wait on. * @interrupt_request: Indicates a pending interrupt request. * @halted: Nonzero if the CPU is in suspended state. * @stop: Indicates a pending stop request. diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index 20519f1ea4..f32d8c8dc3 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -68,9 +68,6 @@ void dummy_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY", cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu, diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 40d4187d9d..6f1e27ef46 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -463,10 +463,6 @@ static void hvf_start_vcpu_thread(CPUState *cpu) */ assert(hvf_enabled()); - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HVF", cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, hvf_cpu_thread_fn, diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 94c828ac8d..c239dfc87a 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -66,9 +66,6 @@ static void kvm_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/KVM", cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, kvm_vcpu_thread_fn, diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c index c552b45b8e..49814ec4af 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -137,10 +137,6 @@ void mttcg_start_vcpu_thread(CPUState *cpu) g_assert(tcg_enabled()); tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - /* create a thread per vCPU with TCG (MTTCG) */ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG", cpu->cpu_index); diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 894e73e52c..84c36c1450 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -317,22 +317,22 @@ void rr_start_vcpu_thread(CPUState *cpu) tcg_cpu_init_cflags(cpu, false); if (!single_tcg_cpu_thread) { - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); + single_tcg_halt_cond = cpu->halt_cond; + single_tcg_cpu_thread = cpu->thread; /* share a single thread for all cpus with TCG */ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "ALL CPUs/TCG"); qemu_thread_create(cpu->thread, thread_name, rr_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); - - single_tcg_halt_cond = cpu->halt_cond; - single_tcg_cpu_thread = cpu->thread; } else { - /* we share the thread */ + /* we share the thread, dump spare data */ + g_free(cpu->thread); + qemu_cond_destroy(cpu->halt_cond); cpu->thread = single_tcg_cpu_thread; cpu->halt_cond = single_tcg_halt_cond; + + /* copy the stuff done at start of rr_cpu_thread_fn */ cpu->thread_id = first_cpu->thread_id; cpu->neg.can_do_io = 1; cpu->created = true; diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 0f0a247f56..6cfc01593a 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -261,6 +261,11 @@ static void cpu_common_initfn(Object *obj) cpu->nr_threads = 1; cpu->cflags_next_tb = -1; + /* allocate storage for thread info, initialise condition variables */ + cpu->thread = g_new0(QemuThread, 1); + cpu->halt_cond = g_new0(QemuCond, 1); + qemu_cond_init(cpu->halt_cond); + qemu_mutex_init(&cpu->work_mutex); qemu_lockcnt_init(&cpu->in_ioctl_lock); QSIMPLEQ_INIT(&cpu->work_list); diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index 6b2bfd9b9c..0ba31201e2 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -64,9 +64,6 @@ static void nvmm_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/NVMM", cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, qemu_nvmm_cpu_thread_fn, diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index 189ae0f140..1a2b4e1c43 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -64,9 +64,6 @@ static void whpx_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX", cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, whpx_cpu_thread_fn, From patchwork Thu May 30 19:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 800205 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp401383wrw; Thu, 30 May 2024 12:43:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4g3zj35pjXY7tpJ7vCOdckbnKsgdpSqcziFhmc81ej5Tz13R2+rkNYHxiQFWZcJ80HALrO+1Yw4a7SuL8dGrq X-Google-Smtp-Source: AGHT+IENCaBXfsC6rOmzCR+887Ik0Db1PrPIYQsPguxi9Z2V+y4N2dptCpQpgPrjYrspAv93uCMv X-Received: by 2002:a05:6808:278f:b0:3c6:f7ce:babd with SMTP id 5614622812f47-3d1dcd11649mr3838600b6e.44.1717098226890; Thu, 30 May 2024 12:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717098226; cv=none; d=google.com; s=arc-20160816; b=WowrMtcce0ff+XDVqR+OWDvq0pyWbk+IBX1nUL4ZalpK+olkP+iNjHyUFkyCnxsPCD A05sLJBCo6ddzRILCGF6zgelamxIbYUROF+fnG3SmYovvWBqJLU24XxHhCVyQ4D+Wuqw qCnYlwlwfyXdxtYHHiVfbJ5iHr7zC1p7fo/atfSVWDLq5qX+lhGwtUsYu1XKHIgNQjVm IZAxSDgwv/7wYLO1TMJJjr1uhonfXIrYL11nKChuE+CYnnIaHjWDpEhIR7P0UtEG/LyV qCJFsFGnKri3cFbfF0vzomYoLh8S7GfXobEZ9ndg1qDF4OzmjvB3mktgZHxwPNeXo2WL N9qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=32yQbNKYA/0QpYwGyLEbfW3tqRcvc30vIF3lo+QmN14=; fh=aWK/WapK4xf8SGfzgOGJ7AoHDKO+C0u8XFOVHWsQNds=; b=vEKypUQnaHLhFSlVSTeNcSsCgoBYOCjYNer6RtPe81hBqiLX/LPJ+gSgJ+6cjRFOv8 CiPzVrnBV+iwQTMAHCtX+mSd0bjtlJ/StQwl7/focueFcNwUd9Qcr7Fhn3hyPBOPsyK9 fQrjKmgjpaaxVt2ZoH8vVWtLRIWKa8Q/O5cYKc1mmDU9Bpbw9OIEgL/6J9vavP/vvKZN bQDiQZOj/lHTTDc3BeV01MYJphxQy6wTdYFQS3CIB3lYhrFAT5NXVTu0RGaY3SGjGUnG 6doo+pRsaKCKAqrX0qACs9hg9ycUH7xdYPmo/p/zXbomgq9okJRNpTOUGSsUA10A3zdd axKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WvH2LWEQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b43d7f6si3656996d6.557.2024.05.30.12.43.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 12:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WvH2LWEQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sClfw-0005cO-Td; Thu, 30 May 2024 15:43:00 -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 1sClfv-0005be-5d for qemu-devel@nongnu.org; Thu, 30 May 2024 15:42:59 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sClft-0006HL-02 for qemu-devel@nongnu.org; Thu, 30 May 2024 15:42:58 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a626777f74eso125709766b.3 for ; Thu, 30 May 2024 12:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717098172; x=1717702972; 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=32yQbNKYA/0QpYwGyLEbfW3tqRcvc30vIF3lo+QmN14=; b=WvH2LWEQpYp8Q5bSeGBHdDeAgwfgbgSh9s94/RIvygnDz6krOZRgc7hlod6t6GRarT ouf/fYcPnbiK6mOuex1lzb1FlB8e45rDhtsUVmlIN2kMwl8xvaUHXpcmrmP8N95aLx1t 7c2vilNx65mBHxm1McXKWoRjeRDi2IITcqxhvRJchwoLHWzfdD+shhqwu+EYUH6p8sps DGsOiL71Sx6qeskWsFPiW8b2HVkC04ebccCNsHc8pPaWxji9hSylrTSM8SkwkonCi8Mc GLEPuA6pYgdUKcIgMwgMJaxBlHrgHrnn18uMSDfduZ/0TqvsvfxpgVGK9hsWOBH5EiRn cOiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717098172; x=1717702972; 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=32yQbNKYA/0QpYwGyLEbfW3tqRcvc30vIF3lo+QmN14=; b=u42D9S0YXCKzhTtC5q5W0hkX9Gwa9BKY3x989wQPLKtjApiWMB7BF1F4cGOtcHMM/U +SfaJgiPGaEqNQDC5CXymj/tFptV7IZX65HMkNyrjEWLQthOHoY/dfT1i8sJulXgygh9 a1o5MB3G1RKS/UpCL62Ib5886DgC3pS7EXgKNPF4oLiRbBGFQ/5PZDQ/sI4yZYsAlW28 H9rD1wNYjW/tStl/JfjxzKOr9Dr9+kVYUqWL8/Jzw654QhltmhtkFAHFhsu1y9/dnwSr 9o/NbbABK8XPMyDkZoqXH6eUANHAVcsropntNhvxol93EGsAi7/0NrrE8gafbP17ELOY FJDQ== X-Gm-Message-State: AOJu0YxkraqBGYKfTtiG4h9Fk8o1GbcRJvgPuCHxeIEcyXVCs40ad1s7 2nrOEdrZzcFCvI1OhlKqhNlnQ/vcJ2YBIve1YjJ+eqQ7xju2/klCHHTjvXeai2o= X-Received: by 2002:a17:906:f2d9:b0:a61:42ce:bbe4 with SMTP id a640c23a62f3a-a65e8e507f0mr301550166b.27.1717098171970; Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eb34204dsm7560266b.191.2024.05.30.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DA9075F8E5; Thu, 30 May 2024 20:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Cameron Esfahani , Alexandre Iooss , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Sunil Muthuswamy , Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Mahmoud Mandour , Reinoud Zandijk , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, Roman Bolshakov Subject: [PATCH 3/5] cpu-target: don't set cpu->thread_id to bogus value Date: Thu, 30 May 2024 20:42:48 +0100 Message-Id: <20240530194250.1801701-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530194250.1801701-1-alex.bennee@linaro.org> References: <20240530194250.1801701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The thread_id isn't valid until the threads are created. There is no point setting it here. The only thing that cares about the thread_id is qmp_query_cpus_fast. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- cpu-target.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cpu-target.c b/cpu-target.c index 5af120e8aa..499facf774 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -241,7 +241,6 @@ void cpu_exec_initfn(CPUState *cpu) cpu->num_ases = 0; #ifndef CONFIG_USER_ONLY - cpu->thread_id = qemu_get_thread_id(); cpu->memory = get_system_memory(); object_ref(OBJECT(cpu->memory)); #endif From patchwork Thu May 30 19:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 800209 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp401424wrw; Thu, 30 May 2024 12:43:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX0qN1yDr3GQgaSvdx9sDkzr/fwm6jhZWkBYhpg2QWUN1Nq/ODjncLP2t9RsQ0OZcdVTuwj6kcFKsHrmmlnWF6Y X-Google-Smtp-Source: AGHT+IEAyGadFdaciz071kdfby9EDRU3rUcpA/h+UgsYFbzmf+vOya3fOKaXPgxUkhawoINo4ArU X-Received: by 2002:a05:622a:1827:b0:43f:f168:ae69 with SMTP id d75a77b69052e-43ff168b02emr11437301cf.46.1717098234706; Thu, 30 May 2024 12:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717098234; cv=none; d=google.com; s=arc-20160816; b=kmxuggUwl5ZJdynx5vW54VCStXMDDsFx2gvtS56O3MrzgU3hEyB63PPrkDmT8p5M9A F/ymc8MquHnbGwsTkvq7tyweS4oejWiZ/Gm/884SWIh2EPS9G1J8lcKyZtoB90/e9WI6 5ctSqTZPs/SnVCxPjDTxyt5Cz3JFIgMvtulUqNmXI64JsF36prozVwk81EKJt3ULcp47 1w2LKrkWENJ5Jsf11lAedfrckJ8qpcyBj1D09+wrigLwPSGqQNvFOkyDLHPhWchPZh4i EErbPQ3PnyxLER8bm1TEiXgfH1VGRpNBk6y3bUUQ8K4eIrVPxjxOQErAZhLUVlxOLF8n ctaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uSiuGXiCgmtxSxVezOHytC/a0n/fTNdw2YFzo1KJ2YY=; fh=aWK/WapK4xf8SGfzgOGJ7AoHDKO+C0u8XFOVHWsQNds=; b=fbpLd7YTrMZW75Ppx9IJdGAAWma29GWT+jQF+bRjw63NXPn37wSxMbQTjcP3ZEOVqh AZ3RfWrbqQjR2qEWACg8zdXGbQjQvAccUVxJZ8IPrfjpdB4qPpJahRConwFvujT6UhTJ k7TjcuikZWJM/QeYEGOx3RcRSdGeHu3bf0rVBnOiJNcHAY2Irgk0AEljxz6P9ynI/97o MpkdD5nmA9zqjO2AV4itCLcADxKMObYEuLJMwv+RWLf392T5bvUZLeRe/lATYqrfLkM1 bSJprSWnnpyVXhmS1kEY9UdPmQTS+vLDwgrFaZJyGwX+/2bnAU/ZkUPBEwVnt/cuFFhv kV4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kWm70oz+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-43ff246744dsi3048961cf.345.2024.05.30.12.43.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 12:43:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kWm70oz+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sClg1-0005eR-1n; Thu, 30 May 2024 15:43:05 -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 1sClfy-0005dR-Sj for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:02 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sClft-0006HV-05 for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:02 -0400 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a621cb07d8fso134150066b.2 for ; Thu, 30 May 2024 12:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717098174; x=1717702974; 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=uSiuGXiCgmtxSxVezOHytC/a0n/fTNdw2YFzo1KJ2YY=; b=kWm70oz+mNRpjlcqKQl0qYPZ750I7cW5ssBh14uVBcA422l9x+6ilKeP+yiv1lCbBI N0o9BgporXvCFTBw3XRlzEqUYGd40fzMPoy3ohEHfABaNoE2Q8+EKkqrmejriksZICQo pofVzAGXV3rLRLwyJFiVqS/Y5mOc1amzpnGbHFXXF/AoMLnnofbj/FoUPbgYlAnVihrl Z0u0bGSIhzz0b8wCAzaKgHEUoQyQ90omkMKa/VJpE/cgOrGAVX25WNQ2E/HdEaaJSB9Y A174yqrjc1K7TtomQVyENjCswjQtkjre8wkcmVcvSxVCLPVCGxx1oDaT/mk5GwWZMVlA UHcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717098174; x=1717702974; 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=uSiuGXiCgmtxSxVezOHytC/a0n/fTNdw2YFzo1KJ2YY=; b=loUqKIXFGSGJOkkYW4v8uoR8JA4nY5s9iezbVebOWygMrG9KfdmQKrwbcOc+t4oNnD i1RI2WvKUhy4Yiqsric6whKUJenAT1cpTiE3cQzQSiZwoFjNAuEDGBV85MwjwqyANm1v o48um6qwOHiYpxlXDH4A9NHvyUw6OA14u/vv1EtTsi52gjrh7N1aGvgg6ykfKF83Etia 8Tep2rXvZm7XvZSevVwZGVHBSKOixHdxjSqOP+IX7n1s91gDOKAWi3h86CSI+6sQabST Ud78pMzC+9Q9yJzxYVUpVac53HSgDgPkEHFdmhKvDs6VY5noS6kir3POE1bqnuWgp9Q5 fUGg== X-Gm-Message-State: AOJu0YxhguhVPgbhLtC6ejMvcWDz6k7Jxa/8Xx+C39Twd++Csol/j1e8 NtLArRNtKc58261tUTp4r8dy/c24jDHNoFnISK2Ks7t7kQsa3MvnJcj5EXqWU18= X-Received: by 2002:a17:907:1dd3:b0:a59:ad15:6142 with SMTP id a640c23a62f3a-a65e92304eemr189379466b.77.1717098173472; Thu, 30 May 2024 12:42:53 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab85f32sm7774166b.180.2024.05.30.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:42:51 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F38205F8E7; Thu, 30 May 2024 20:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Cameron Esfahani , Alexandre Iooss , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Sunil Muthuswamy , Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Mahmoud Mandour , Reinoud Zandijk , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, Roman Bolshakov Subject: [PATCH 4/5] plugins: remove special casing for cpu->realized Date: Thu, 30 May 2024 20:42:49 +0100 Message-Id: <20240530194250.1801701-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530194250.1801701-1-alex.bennee@linaro.org> References: <20240530194250.1801701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62c.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now the condition variable is initialised early on we don't need to go through hoops to avoid calling async_run_on_cpu. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- plugins/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/core.c b/plugins/core.c index 0726bc7f25..badede28cf 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata) CPUState *cpu = container_of(k, CPUState, cpu_index); run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask); - if (DEVICE(cpu)->realized) { - async_run_on_cpu(cpu, plugin_cpu_update__async, mask); - } else { - plugin_cpu_update__async(cpu, mask); - } + async_run_on_cpu(cpu, plugin_cpu_update__async, mask); } void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, From patchwork Thu May 30 19:42:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 800206 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp401385wrw; Thu, 30 May 2024 12:43:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUpW8FT53mnKE5n8XvV2u+8fWU1Y1q3ojs2SpDnFwLJFZPUCofZ+40JtrM5eO07EYIFKnkIoLbwR+Ax0+iYD8zA X-Google-Smtp-Source: AGHT+IGumBjRy69//H0M/HaerCBrMPF9n7J4U5TkH9kpk1Y96N+odz/fqxn2oIRVhlsimTuqAFIc X-Received: by 2002:a05:6214:5154:b0:6ae:1b32:b477 with SMTP id 6a1803df08f44-6ae1b32b8aemr19725386d6.28.1717098227099; Thu, 30 May 2024 12:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717098227; cv=none; d=google.com; s=arc-20160816; b=1Ge34lxaubZsHFTqBw8iWLO6U8FOfgimwUhhGULo8arTuNTIK+RjpXKYQrh3f/sI+H FvHUZIb2w2hX8XR4qxyhkFsukTvcJ3xcPT8Ru268Zs3Ot6oNSwtj3GGVQ2mLAmSAkEM+ tf+HGI3ft+thDthhKOZBXHZdwaLprBh4Buj9M1hC1xGbJ/E/hOVvspLgvzIjufC4M5Qq 0cUOe8S0cK+xVizpIxOXwFUzxSjBfR4oG96Wd2KNPTAi457qymCODmfEJaS1K8+fZ4hb t8zcKGEW3T1rnzG1kzc4ez+wPENm3iPklPyah67N2BQVSRH6kKLmBYebePmpT3FMSS07 CuZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fPCSTF6BhpGl/BOGWj8t6sMDRxBkBVgL05/HycPv784=; fh=aWK/WapK4xf8SGfzgOGJ7AoHDKO+C0u8XFOVHWsQNds=; b=ozjzIWJ0Mcn6Y8/KlY3xaakO3pxhCpTk2NhiO4TfTccWU8Irx/R55Ih6HKH1olUzAE k156NFi63CbjWssFkp9MpE2nkqP9CXpjVo3FSiC/CVDg1PYgM6hX7XYpR4o3PiSPzw4Y YPXPF1r3lV7HY1+0XQ1KMAUhbVNCcjbnW4HWLu9T1GvvzE5eYCqZTeOSizmvq+M0fK5g F3Z3iyDNfcRhD3QTSyB8VIE/+tj6pzojiPpHJbwQnNOi08qmvQ/1zd81d1AsozPBlzfC hURDtECwnIoxkp3iri6bUYyGCGj1WAXLSORkpJulHTFZ6yopMU8luI4YTGmxw9QAqgKW fP7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cpr15LOX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b4018b5si3460296d6.249.2024.05.30.12.43.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 12:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cpr15LOX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sClfz-0005da-90; Thu, 30 May 2024 15:43:03 -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 1sClfw-0005bo-0J for qemu-devel@nongnu.org; Thu, 30 May 2024 15:43:00 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sClft-0006HX-1a for qemu-devel@nongnu.org; Thu, 30 May 2024 15:42:59 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso1177179a12.0 for ; Thu, 30 May 2024 12:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717098174; x=1717702974; 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=fPCSTF6BhpGl/BOGWj8t6sMDRxBkBVgL05/HycPv784=; b=Cpr15LOX3D6CRbGYnptBxBZx07KYsY8FhPeQXNXTvuJAedeA5iL8KqBe/gYmn9P0Ra GywApjV6hl5szGirleSwljmgAdf/PUm6aO1wN8HQaP8+yZqTCB8Hnyfus/H5vS5OxSAT KHRJVywwd13mq0H8endRpFu8Xs9gc0QhBXi/N8SgSmgNKwLtzJhZRVueDoZaBdLSEzrS /cCgj8Al4Wp5AvcMtSwtQXiV+VUFOJrdZcwmQEILL7fGuxNRQvpWo5JGIlFf6QGf65lP IWiHpCt2rMZX34vRt+/rBDdyzRNAA18JRLQTLmtZqUZHYuH5hYbp/GX3OjUGvel0Ol1K mL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717098174; x=1717702974; 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=fPCSTF6BhpGl/BOGWj8t6sMDRxBkBVgL05/HycPv784=; b=tAPftSMohLf0yFYMQSTOme59OKsu6hlGJxLGM0tNPGBwz3DqhmsUOr4baOOB3r8v62 Is1SIAO5oEkjaKcvcWmTeZKs9/lcA0gSu2hKUZ9kPsvCu/PystzogdMYG9h3/JQPHkat sGXHTNHAhWUqrm872E39nOLeysb2Yel7wEQgizqT1t7KjS1+YD5UcR6OPTwF318lQH7z cJ9oWkl2U2TRaTh0JyQcUFLJ1lM4GCGAA6Ab5IFv0pLGgsqAuDwS+gz6wjZZchZEFdip 4cniQrjsMMKFEo9RyE9AmtVpu6/6I5a485eORYh+RmjuhrwD94kCavDMNXs4AluqiKs0 2rWA== X-Gm-Message-State: AOJu0Yz/5YF6/pBvDuZkmjZbA8WaN5FLsXizzTqMbQZhiWKVx7Pn9nrR w9S7/DD+FNeS9uMYrqSSKZaxG8qjhtLTREGW3AyY6suZPhJwoqXwsIl1p4ixwKQ= X-Received: by 2002:a17:906:7714:b0:a67:da88:149a with SMTP id a640c23a62f3a-a67da881f76mr21672966b.55.1717098173884; Thu, 30 May 2024 12:42:53 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab85c8fsm7754766b.183.2024.05.30.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:42:53 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 16D015F8E9; Thu, 30 May 2024 20:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Cameron Esfahani , Alexandre Iooss , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Sunil Muthuswamy , Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Mahmoud Mandour , Reinoud Zandijk , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, Roman Bolshakov Subject: [PATCH 5/5] core/cpu-common: initialise plugin state before thread creation Date: Thu, 30 May 2024 20:42:50 +0100 Message-Id: <20240530194250.1801701-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530194250.1801701-1-alex.bennee@linaro.org> References: <20240530194250.1801701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Originally I tried to move where vCPU thread initialisation to later in realize. However pulling that thread (sic) got gnarly really quickly. It turns out some steps of CPU realization need values that can only be determined from the running vCPU thread. However having moved enough out of the thread creation we can now queue work before the thread starts (at least for TCG guests) and avoid the race between vcpu_init and other vcpu states a plugin might subscribe to. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- hw/core/cpu-common.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 6cfc01593a..bf1a7b8892 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -222,14 +222,6 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) cpu_resume(cpu); } - /* Plugin initialization must wait until the cpu start executing code */ -#ifdef CONFIG_PLUGIN - if (tcg_enabled()) { - cpu->plugin_state = qemu_plugin_create_vcpu_state(); - async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); - } -#endif - /* NOTE: latest generic point where the cpu is fully realized */ } @@ -273,6 +265,18 @@ static void cpu_common_initfn(Object *obj) QTAILQ_INIT(&cpu->watchpoints); cpu_exec_initfn(cpu); + + /* + * Plugin initialization must wait until the cpu start executing + * code, but we must queue this work before the threads are + * created to ensure we don't race. + */ +#ifdef CONFIG_PLUGIN + if (tcg_enabled()) { + cpu->plugin_state = qemu_plugin_create_vcpu_state(); + async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); + } +#endif } static void cpu_common_finalize(Object *obj)