From patchwork Wed Feb 28 11:56: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: 776481 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp255324wrn; Wed, 28 Feb 2024 04:07:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWTxqbk0GXl3TqrUtFuzpbf5BfZOaWBBcUJBxU6+SSSLIjpneN0MmFnzNmFcN5r+OAPBvFouXnScRlBDzJULKsz X-Google-Smtp-Source: AGHT+IGpSsnxPrNsnRJoOj+y/T7Wt6A0t4iEH+NJ6BfHP7zPofVmeY6cZKEhYoz71J2omEdgKyKw X-Received: by 2002:a05:6808:1894:b0:3c1:b144:9914 with SMTP id bi20-20020a056808189400b003c1b1449914mr4729681oib.48.1709122057894; Wed, 28 Feb 2024 04:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709122057; cv=none; d=google.com; s=arc-20160816; b=A80X2W4YsQG7UaKduGld1tz0beznd1wYnIDKuN7MgJqMTzW+JPdsICOhfpujthhDxR +xt7CR+pjr8dvnQCYYG4jFClNZL//vscyDAw3r2GnJSkO5xXzhjgG8mFMt3npbodJBGo BUMkXYldBFG9dvD3884B23NpaMDGf++T6Mfux7HNHryvmBu74UQlNwmjfbDz0zRxe2Cv uOthRdoRDSCm0RdApmeW4+LmuC0GqseOEZ7UkkJTlRVoN/1hesAMeRMtE/93ag0JA3gw lFkw2HVn/wsS0WyaR01n2mRk7e/40dPQm0GwRLT9EGvC4JgOnPjfgL1M9gB4fd9Ujs2h f1jw== 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=ITjmGoGHy7/JLnU20+irN4PvElz9B05xt+jQzipQhG0=; fh=yu0InTeBwSZcLajIY49SmB6DXvx9wTO9ThO8p5pbR7k=; b=hfNFw/S4dMbd74cI8uBSB9T6HJAEWq5Kvcx8RBG2pmMIPCYe/rycN03cs+m+BYGwiD A6x0W/3K7OZt+1hkS7sblZdFpZEB6htdvVS4okBMJJ62/+tToNlPg7Hp1jsypvmwexXp jdCvsSwMV+tvuKJNihcPaSLkeOy/0Q/tkpRxgT1yAtLLwT9Vre5AvAjweh4GZvqcykta /HI9SAZj2LZd5qFeyrnh3vz4ZQfzSrzdc94W7D/b3wH8FDSi2vqsUFsSDi+FIvaS2fhi U/4ZGR8OtP79u8pZyWeXCNpPumyN5D0dzdaaT1IN87jEYRE95PUiJKiyhUFD+wWTr9fd 5L4A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DB+7yv9L; 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 a12-20020a05620a124c00b00787b7d22a90si9536526qkl.288.2024.02.28.04.07.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2024 04:07:37 -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=DB+7yv9L; 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 1rfIeO-0004dG-Eb; Wed, 28 Feb 2024 07:03:04 -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 1rfIeJ-0004OJ-QT for qemu-devel@nongnu.org; Wed, 28 Feb 2024 07:03:00 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rfIeI-00034d-4V for qemu-devel@nongnu.org; Wed, 28 Feb 2024 07:02:59 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33ddd1624beso496892f8f.1 for ; Wed, 28 Feb 2024 04:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709121776; x=1709726576; 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=ITjmGoGHy7/JLnU20+irN4PvElz9B05xt+jQzipQhG0=; b=DB+7yv9LofiFhURPv+uCUBY488uvitCzb5lC8jiFVQIu/4J1e5bzoMr5s/WYIGtYmD apwFOixs5BiLZ9NTLK3EjKojQeaDrEaUjPINO1hMUlTqdJUDrL6R8sfnY2oI/orIMlKc cy9oijNGfXWhAZMZuj2vg6sCuGJ4kXFDlL/NR3YsmyaDBc97B/jJdBf4SLmGGSfjBFX2 gxdcTFfTZJ0tfB3sbg/ZAUQb4BKdJ3tQhJTWCAxUtJc1qpfemmoO8oQe1Hf5sGrb4kRf Z9JXWdSA38PkTybVPtenchaPuWKmV74+jQzjpQ0kYduKO0OR9Qp0mu2N4++KQdayVGZX m7jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709121776; x=1709726576; 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=ITjmGoGHy7/JLnU20+irN4PvElz9B05xt+jQzipQhG0=; b=Ujt6/cWixgXJb5ETymw9iqlsHttSormrG/KjsKTUiFKP1HWGMrvlpmTKQkvxNowOsP nnrGtQnoJEKPVnqu8cDq5X0VDcPNyJafG+hb1nn7BgoCupd450yQUfkfqgR6X7W/RvRT GKY0GkTZBl8F+zmznc7LmZgda3klTdCHry7Yk6Qcw8cn4mbNOfVWfBnJk+OJJ2r3AVTM 54B1YwgeoiQB/R+YNmgNYLqqrF5iG6f/x0p3gnysEQb/1WD1SyhZbgTZIj0jJzU/x0Pz glczlTIBL88ECOVV14c2jPnX0ksHtdFKu048pI2QkrEFiwDrD8bIEKUyYiUoBF7TSaph Sd5Q== X-Gm-Message-State: AOJu0Yx+zyAwaSKhLZy7wTFM3YgaQAYnpfaZP14huh8zdGWZF0xNsFlU oz8GrK2VUw76KCB5lNPVnY9rs4d4MTw+a5vHfran6tRBWQECjviLZp/9ucvdxfo= X-Received: by 2002:a05:6000:103:b0:33d:1ece:d618 with SMTP id o3-20020a056000010300b0033d1eced618mr2006821wrx.8.1709121776508; Wed, 28 Feb 2024 04:02:56 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a26-20020a5d457a000000b0033dd56b002asm10205342wrc.73.2024.02.28.04.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:02:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9FF3C5F911; Wed, 28 Feb 2024 11:57:03 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 17/29] plugins: fix order of init/idle/resume callback Date: Wed, 28 Feb 2024 11:56:49 +0000 Message-Id: <20240228115701.1416107-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240228115701.1416107-1-alex.bennee@linaro.org> References: <20240228115701.1416107-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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 From: Pierrick Bouvier We found that vcpu_init_hook was called *after* idle callback. vcpu_init is called from cpu_realize_fn, while idle/resume cb are called from qemu_wait_io_event (in vcpu thread). This change ensures we only call idle and resume cb only once a plugin was init for a given vcpu. Next change in the series will run vcpu_init asynchronously, which will make it run *after* resume callback as well. So we fix this now. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240213094009.150349-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240227144335.1196131-18-alex.bennee@linaro.org> diff --git a/plugins/core.c b/plugins/core.c index caa66311351..2392bbb8889 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -391,12 +391,17 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) void qemu_plugin_vcpu_idle_cb(CPUState *cpu) { - plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); + /* idle and resume cb may be called before init, ignore in this case */ + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); + } } void qemu_plugin_vcpu_resume_cb(CPUState *cpu) { - plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); + } } void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id,