From patchwork Tue Feb 27 14:43:23 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: 776249 Delivered-To: patch@linaro.org Received: by 2002:adf:a113:0:b0:33d:f458:43ce with SMTP id o19csp192486wro; Tue, 27 Feb 2024 06:49:18 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXiMvpQ578ybQoynH5bqnDt4Zt1niyLYzAMMlMRmOSNAIJKoHX1D+f8tbR4WVgXeGGuwjgMf+X2WLKKAuYlndrE X-Google-Smtp-Source: AGHT+IGtHjYgoroNPfukV6h0fVdEcQR5SrXruGoOYHFaWOBQeb7Tpsiq9OdflJxOPjjaZrOMDpb0 X-Received: by 2002:a05:6808:3012:b0:3c1:5527:5af9 with SMTP id ay18-20020a056808301200b003c155275af9mr2283740oib.57.1709045358737; Tue, 27 Feb 2024 06:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045358; cv=none; d=google.com; s=arc-20160816; b=wEYsw7EfLuPHt3EdT27dPkn6NK8tAelT3c0eD6GIp5Ui3tZvQUThWsBrQw0aJ3TaP6 zlRtRF/cOwOxLIp3j0nF71em5FJHCMCLGOvngVGTFjecq8Dr6vOZE5ieuNHDaFDyPvb5 IDE7YFejjzU8diLLSh0TGTP3xOZFsomFJzn3xHJla0SybSdxHpY1LPW7qTcmDteXI7qC fRdzxpD3JcmeLpfHKmOOIJ7ieyIslaaVbAow+Iu1aS/J9x6LMD5o+NQLgtWal+uIv9xk v+yBJoz9oSTvO8xs62z7R4q4/8eEu0/qSsUxYiUQMN1TvWaX6awnmF0FUnNpHr+q6/l4 aLBA== 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=42urZuEDMQCp17hh9k6/exkRQrnxeYXQehaPHkChZ3M=; b=p7+WG5+R+L7rH6OP7F59zMvyG/ohpCStkgRgjBMLZ63cErINPO3fjxJERCNub6SUQc ss/ffJE4jNvLzVBBbGuLL3R9w/YfXyFeNLDCBMAJlaeIZRCRiaJyEs+/10efRv5BTzte v0c+P23bh5pYVjVkh2GpZNZGSseTk7kVpXTSOrmHVOTHboQAiIye6eERAn35p+cFTecd +sDpZC8HlDwBxdO4sBs+6s3BJs4IOOnwGonjK9v2tnxJwdO0omiVzDRqtbwiE1GMP2Vs dA8dOIL7WLco8TkZB1mEpCVm2W9nyDQ3Z6fWqsVFOecdppaYl3s8go/SKuot7ooYNG7u UUAA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3J5VTxO; 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-20020ac8720c000000b0042c73eda258si7334893qtp.72.2024.02.27.06.49.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2024 06:49:18 -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=L3J5VTxO; 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 1reyhd-0007Kv-Du; Tue, 27 Feb 2024 09:45:05 -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 1reyhG-0006P1-Cw for qemu-devel@nongnu.org; Tue, 27 Feb 2024 09:44:45 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reygR-00025N-0H for qemu-devel@nongnu.org; Tue, 27 Feb 2024 09:44:41 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-412949fd224so23006865e9.1 for ; Tue, 27 Feb 2024 06:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709045029; x=1709649829; 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=L3J5VTxOC6jMoyQJ0Kkk2Z1Z4/v6tyTaBJkuSAudOgKY9DGK0MBDbHh8FXceOnlAsW z+L2nD+oedCwz7A0DHpgaYwsKXG699Vrk0pc9mWF3nFUUn82eNMBXO2SI/AFwPgon2OF KCOmP+jC4+rvNoFVAMi5YMRmARisqBMss04jhbLoswJQRBy+FjucxLIlpplMpg9JYZYE sEj0ING/vRxulvlhr9aXDRORWPAArzZiFZa8wJsnooz32YWxv40DAZptBrau1fSqi3YX Zv8t3P6FHQu3AknMF7w3QkXcMwdDJSY/AYUUhb1b5O930GxY38V4xTYQAQYJTJtp17aG Kt4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045029; x=1709649829; 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=RpHBQcyFAyWWZvO9ga3jqyMbPHz1X8NiT0zVunGyB07jSyMIGMKCW9O7hq78iIMjHc Q0yxLtYkKfj2CyorxifS6qyuwVWP9XCQSoCNr0iTGCEaNflJe7XqgcZBjcR7MhRUBpbg 1gJd5GkyzQOBT9bOPlVk3xj4BEnX659tbQELiFSLmAYCD/1TUkDi9GOHBxFTl9JKN/4p UHuaWoxpmFUT3xdTlEum3x4AkskdO4f3ySJjFT2Ib7dDEOA8XnWBHgr9ZDRw5vUgLhlW AebrRVriuPh3SGV0f1Q+2A+yhPEsNuHN13n/r425V0oDsYYJb7GEzsoH/H+HnrVYsUQk whcA== X-Gm-Message-State: AOJu0YyikXvj59/ToJjucx3trfhBBj1Pj87HRc2YUe0v0Ysq08oq2FRw FLv4UvQPUpoepdXUrL//vQWdgNBZvo6gOo4cnW1I9iP7fmnvbvgqwu7lf7SdOvU= X-Received: by 2002:a05:600c:35c6:b0:412:a3f2:d641 with SMTP id r6-20020a05600c35c600b00412a3f2d641mr6178315wmq.19.1709045029237; Tue, 27 Feb 2024 06:43:49 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id fm6-20020a05600c0c0600b00412a5b6ac5csm5958110wmb.36.2024.02.27.06.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:43:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 333CD5F911; Tue, 27 Feb 2024 14:43:37 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, Yoshinori Sato , qemu-arm@nongnu.org, Liu Zhiwei , Michael Rolnik , Yanan Wang , Eduardo Habkost , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , David Hildenbrand , Paolo Bonzini , Peter Maydell , Song Gao , Daniel Henrique Barboza , Laurent Vivier , Warner Losh , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Ilya Leoshkevich , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-s390x@nongnu.org, Kyle Evans , Brad Smith , Nicholas Piggin , "Edgar E. Iglesias" , Pierrick Bouvier , John Snow , Alistair Francis , Richard Henderson , Brian Cain , Thomas Huth , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Bin Meng , Daniel Henrique Barboza , Weiwei Li , Marcel Apfelbaum , Palmer Dabbelt , Mahmoud Mandour Subject: [PATCH v4 17/29] plugins: fix order of init/idle/resume callback Date: Tue, 27 Feb 2024 14:43:23 +0000 Message-Id: <20240227144335.1196131-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227144335.1196131-1-alex.bennee@linaro.org> References: <20240227144335.1196131-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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,