From patchwork Tue Feb 6 09:24:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770370 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195959wrb; Tue, 6 Feb 2024 01:26:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IENq3+JNQzupPbKiqjf4Fz8gcQGT8JBBAnTEceMt63SGLHDanDYSbY/oViRgpc7iFcqQqN3 X-Received: by 2002:a81:7e45:0:b0:5ff:604e:2bf with SMTP id p5-20020a817e45000000b005ff604e02bfmr908969ywn.18.1707211586519; Tue, 06 Feb 2024 01:26:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211586; cv=none; d=google.com; s=arc-20160816; b=Kgh8QEpvU9xBkj192v/KOQ/OVffgyjPC11WP9u6bFVrxLtrExYWivtLPGu1dyz2OPR BSfO+QI3wU0jIpNeaYXDY0Vy7Tq2uZMZbIqdFv5RFO2DLpP3qwgh1IhIP8pW3ngRfrJg UEJY4p9vOt18M7l+vBbc5sjN0GIyGe6jeivcMTRHkQIylnxvX2afgvhuI8YQeMv6p3Ue luCnnkjNv6rAWsSbDwanRRm2iDP7mac0nSnq5mwgKtgiJ20QxjSPfBvbKiGGG/lDNdaY 02QXBTjtSThQUAWISKzL5jYAigYaNbYTig4w4R+XYVfaXYO53lGHeYQpXfb/cojmms+M cIqg== 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=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; fh=e8FPCRZZUQOuk0A5nAyvsWISKYwcx9/rSKFSKKQSsfI=; b=TZ9dHI/Zx/BxCqGbgZEWPxDygHXBQ6d/7Fd6Dy7ezXNVpW11yNRJhqItX4WUQBjBsh uZaSGs9G2I8K43sC7WDel5Is+mHu6GK+0VXK0TM9aBJ3mhVDFMJuj+y/LNFe4h3g4DSU /r+xQ32yCYiekRU1mL7Kpro8xvcKJN3JkupRGHLW03Ee16T1PsTixuVYa5N3Jn6DsQQ8 k79C0xV4eIhhJNQSXhnxWBXR6u8V+D+/Bwml3dhLjWhUuhBdeg8oSeTO7i9y32Pa2dFk vdRh/IN28yHuG+W9yIbgSBaMQ5BaPCS6JN/7p1Uicr/0OVYsDc1enpqyfZsfpqAikFNk E1XQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAobvPOr; 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 X-Forwarded-Encrypted: i=0; AJvYcCUeHuRl8vZMJ6akRY0fCMtdVDUvQwLaB71HT67WCqkGrVyTQ+IYJgyYJpGZgTBdbHt6whVHjoPmT7NUphhYyv1/ Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5-20020ac85945000000b0042be7c435casi1960440qtz.763.2024.02.06.01.26.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:26 -0800 (PST) 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=BAobvPOr; 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 1rXHhE-0004fE-D0; Tue, 06 Feb 2024 04:24:52 -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 1rXHhD-0004f3-Kj for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:51 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhC-0004lm-5B for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:51 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40efcb37373so5295055e9.2 for ; Tue, 06 Feb 2024 01:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211488; x=1707816288; 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=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; b=BAobvPOrSVLCqzZs9YIojdLcNYEo4qrpzC+1ku9rr5vEv/VyPztINsnBqwzPE2hnDl 7JBoltfa6MYoD2hOiGruNUFVFPGl1bdNPQVpcaMdmBKS61nCGo4FeDLDzUGIH9PBxr6x CnY47modg9aYM0+KRKbFfIw+ywp3/NdK/v13tO8GV8Twsk7lVhrOcMxLdvlzCbDsILQa EK65ZuOu/bsw9qaXi5amyPVc0sOsDtbXyHyt5pIH43GbofN8jzTl7IrLOjT0e2oQoBul Ji6oBJJsuW4i8ZpZ/HBuHZISUWQgPBqjUyC76YYvB1ib/m3Q9yFyQArfQFpqhye0V/zt V3AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211488; x=1707816288; 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=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; b=icJAvQkU3ZMNzZXC7Beu/dojVJbjkg1PXTSvtP3DMEk3EglMkRurjLk/6A5uLKi5tJ FSfhro5u26yDvpQ49ywtDXccdKjO4vCLH3Ga6VoYZMXQsUTWG2YR8HBfW3ljlgHc+Eli CLNljiBxY/QKRXyxPi8PQfoHHqjcqURAHbahoT4l0VbHEM5BPD4kNFxNXAFeMn5TeCIm UPNLl7B+2RuLDaF9MGfpY0DwVW/ELZI9haitcuKLkzB0KY/rYauTD810iBLQc8cRwwdc Em4Qj3ijHHaHR6qlJyqsr4Vo1o1KuQ5eoX6UbvaQt9jEOIeCFvmjK/PX39ViFnSJkiaf 72qw== X-Gm-Message-State: AOJu0YznanoPqxRNE6jNrK5iFBPr0fTNHTwWjqsJ5NOELAXWqWz8QkE8 vPvY+LQKg9MyRfeOARXoQwKOTaIquM957WFVblh0yTTHWvL9Sj6btTx4adpMpS22LaWo4P1TqFv yysI= X-Received: by 2002:a05:600c:3581:b0:40f:de6a:2a27 with SMTP id p1-20020a05600c358100b0040fde6a2a27mr1649274wmq.40.1707211488060; Tue, 06 Feb 2024 01:24:48 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWBDcU1Ik2599Slt5Dh5fJWg9XnNYFiseY8sQ7UJfX+CKhPEA6t1dMS5F/7D4DTVDxSf+6dqhEOhmqHfu9BzZMD7pJMmmSjop9BAll3gYvMTd03XlgRoYvzLo2nqfTZpF73AYfO8lwlCRSdNSfDq3thmlqyQCXukMRWuHjbp6QDZxbQNd56sJGKm0YP/ciD2Z48VqOdmfRWHClC3Z5BJVfpvbR3+XeURcRFHKXG8SL3Xj8A3r8KadR8TqlIXV7sH3AcPb0g51DCfVx+BiL6zSjNEZlndvTjC1VVey5WtTlnyhIkjCM5Hj+O61liJl8t13rYDbcZJbXYwqictDEy2GNvWaJeKbZIJQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:47 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 04/17] cpu: call plugin init hook asynchronously Date: Tue, 6 Feb 2024 13:24:09 +0400 Message-ID: <20240206092423.3005995-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32a.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 This ensures we run during a cpu_exec, which allows to call start/end exclusive from this init hook (needed for new scoreboard API introduced later). async work is run before any tb is translated/executed, so we can guarantee plugin init will be called before any other hook. The previous change made sure that any idle/resume cb call will not be done before initializing plugin for a given vcpu. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- hw/core/cpu-common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index fe16d0d9df8..68786360ea5 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -194,6 +194,11 @@ static void cpu_common_parse_features(const char *typename, char *features, } } +static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused) +{ + qemu_plugin_vcpu_init_hook(cpu); +} + static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); @@ -217,9 +222,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) cpu_resume(cpu); } - /* Plugin initialization must wait until the cpu is fully realized. */ + /* Plugin initialization must wait until the cpu start executing code */ if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); + async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); } /* NOTE: latest generic point where the cpu is fully realized */