From patchwork Fri Feb 23 16:21: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: 775156 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp438846wrb; Fri, 23 Feb 2024 08:46:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVeBZ3byWTYUMlX3NSGSuafGOr0qWIOReRMZ//+Krphou5zmXEtwGurNrU1gmA3qHllAdwj/bksNKfSJFQWdTMN X-Google-Smtp-Source: AGHT+IGfANC8RX7AwVs2AA3cxJ61820XBNcxo4l40lIXh6mhZce/wVmyFc9dHhIwDY3JaogsUUJU X-Received: by 2002:a05:620a:5697:b0:785:b95c:a128 with SMTP id wg23-20020a05620a569700b00785b95ca128mr293820qkn.67.1708706784100; Fri, 23 Feb 2024 08:46:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708706784; cv=none; d=google.com; s=arc-20160816; b=gWLSDfTHS29vnRVEFxX9Dyp9OGeJf+MLQInIzOJQ+pC1jY2Z80S78slsocEJ412BJY qfQB7KruiSQON/oO3zHcPA9gygt9RLykFxioqeHrS6fAGsQcx8pdNp7p9YGr0ioDc1lQ M2xagbRspjLoQF/XFONaK4HQJ27pJkCVfzZ+g3cGL0YRDVLATqA3qiRxSPlk867FgDSE 8UM4lMwoVyVXNyjnWtJOGlaoel5KYGICWz2AaCRXJdLr+AlpYhT3wFNlMjRowYgPWIa1 XswCGZ8vgSY3O/ejRX46AWb3pmnaid4xVSiGWqOF2VtTXL0jqzocTjZj9dFvaAZfyoep wM9A== 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=Xq3bg3O489fduJkQRD4v3a7EWyBdeXHXm96vjazL+zo=; fh=/YEu+IjZM84YWRDAuPeJeqMoLNTdSzM/iYv/jybOCWk=; b=DdPvEKceY7dzmXWQVQnTTdDkrOlAJ7YLmKbTbeSDEYEgAprh9lKARAGIUZxt4rEGmD pISKvHZMIGtzU0uygln9y8w/toGqAcJNSkVXWYlI8kUAqiFjwYjABXjmaiMVSnZLmN+3 vzBdrhs7uQRlIH6+XI3QEntczYKsq30520OzOL7tGf9QMGuq2vZO6V4sbTZuUWFjXx6w jBDVkuLIq+Zrzpk21KyZNEu8FvbsT5gUKxNhVCkYTzr/W5cY5CzIHkwEnh4i9wRQyKcd bNPLO6JnOkQagD+qlSuVgfCHsRuz88LPlyk4952QsaRf6KS6SdzgtOdCH4/H3/zdJm+w gKEg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MIK0d9YU; 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 da54-20020a05620a363600b00785b148037dsi15493592qkb.32.2024.02.23.08.46.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Feb 2024 08:46:24 -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=MIK0d9YU; 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 1rdYfE-00084X-Dx; Fri, 23 Feb 2024 11:44:44 -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 1rdYJz-0004J7-3k for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:47 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdYJW-00069H-HI for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:46 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4129738cc81so3226305e9.3 for ; Fri, 23 Feb 2024 08:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708705337; x=1709310137; 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=Xq3bg3O489fduJkQRD4v3a7EWyBdeXHXm96vjazL+zo=; b=MIK0d9YU/+uEF/HLW/C5QTSGMEhMoU2796qkHHDP3PSQdS8DvjJs/3xeYN+VbEyUs1 i2t+06rlsjhnscoSUdZE4WYk79O+ZXBQa/QDyo78XTchSU43pLdLy4D1NxJTssmXbjhq 9SyJAIrLxv8P7xFOdTIlevkAFy3X6NT5cs612XVD+yWNjwq8V4UNehrgZIjk+eMhaAKv gpokbvhZImoNs85NHA11HDRGc9t9D7rbHX1js0gY0h/Gi/KFghrnJ+hlYpLlnABSuRQH J3NVKrJoXYCqXRVlsp4GxgjqZVi/AGAkDLAD3lAyBXscpuSC2OHRixwuQ+8710LF6WTR dD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708705337; x=1709310137; 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=Xq3bg3O489fduJkQRD4v3a7EWyBdeXHXm96vjazL+zo=; b=Hg7CUXY6S00X0h0BDwVWr+BeUquWKiZiCc3/zIJx5Cj8PG9iqL3X5k0lC9lliG+cge vIod26t8grqbbHotMuUdw1OcOxzwN3uEsJ9rYx4u0GBjCbE4EqA5FhtGQ2wxlREi4ukc aNFqjxJuG6wEIUNoVsMjiRu/VUXnDJl3JK510EDrQD+6oDToDmEkGLO4Y3XnwiDiyMLo mCHpKerqxul98thUMY5lO/1QNpxoJYfKg3q0M9aWbpC1TRklCReAVcGb1ycsXwY3RHkI du4nz7t+rPHUs8MfJjIZ+Dx/BJOPdhVDBOx3obPq28bK5/Ed85gY9JvLN0/Uypb8INqI ClHA== X-Gm-Message-State: AOJu0Yxz6HCjRqoeH3QjPshUSx9YUXi2EdObnEivW0KTrfXf/tsq8/U6 g1Qj5GPObvMcb0pT+/7bMIq8wHcTBcinx8YSpCIKmVOWz6DtJVIN4pNOaburqgA= X-Received: by 2002:a05:600c:4894:b0:412:952d:3c66 with SMTP id j20-20020a05600c489400b00412952d3c66mr218886wmp.38.1708705337016; Fri, 23 Feb 2024 08:22:17 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l28-20020a05600c1d1c00b0041276d96351sm3030020wms.3.2024.02.23.08.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:22:11 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 073655F930; Fri, 23 Feb 2024 16:22:04 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Song Gao , qemu-s390x@nongnu.org, Liu Zhiwei , Pierrick Bouvier , Thomas Huth , Daniel Henrique Barboza , Bin Meng , Yanan Wang , Laurent Vivier , qemu-ppc@nongnu.org, David Hildenbrand , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ilya Leoshkevich , Cleber Rosa , Nicholas Piggin , Marcel Apfelbaum , Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Alexandre Iooss , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Palmer Dabbelt , Mahmoud Mandour , John Snow , Weiwei Li , Alistair Francis , Yoshinori Sato , Brian Cain , Paolo Bonzini , "Edgar E. Iglesias" , Michael Rolnik Subject: [PATCH v2 15/27] plugins: fix order of init/idle/resume callback Date: Fri, 23 Feb 2024 16:21:50 +0000 Message-Id: <20240223162202.1936541-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223162202.1936541-1-alex.bennee@linaro.org> References: <20240223162202.1936541-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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=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+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 --- plugins/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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,