From patchwork Tue Feb 13 09:39:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772278 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169078wre; Tue, 13 Feb 2024 01:41:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVAP4LmKaoxsqaBaN0OdejrY0K/9obWk/XsoRuzs3KcaKJS9KEZsQTPAFtZb+/eXAzumQmLyAV0K295yCMdj+a8 X-Google-Smtp-Source: AGHT+IHYPwIW2Ay5AUI4jokBxiQGqODM2I5205uaeWsPfBupwF8CwUq1YpQfNsr3/vybQvPUJjae X-Received: by 2002:a05:6808:ece:b0:3c0:376e:e182 with SMTP id q14-20020a0568080ece00b003c0376ee182mr6400109oiv.14.1707817288994; Tue, 13 Feb 2024 01:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817288; cv=none; d=google.com; s=arc-20160816; b=0HE8G6XPS9j6pSJ9I//XwJXWZjk/rQguMsbJbZyL+YKp5wmk4EVl/rfoturuihrPbs OQNBG9OWt9ofdN0yt3GPnPJkf6BP7/0Zzjx6AZFUlLOMd8dleNAbiO9HQVzvRaBUq79B Y/S1HamN4dkxAETfP3+6xLp/v+h9RtBio2uI1A/iYVh4U6WX4NBB/wESLTbnizfc1FDh TxX474+5/bfoEHiZwU9YWpL8UnSa7/mRhb+0EV8OCdqRqX/OAzAc6+yCacHoQSHzECv9 k85EIvPPTr2siDEjUa5paDK7fi6EFNSHdQ/18ERbv8kHnSjV1S9MkIYkjOQYQfcTJ1g3 o3wg== 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=HXH7ocyncB0lY9SgnkHxBEuiEnRgV5eLtUY0jbLrGRM=; fh=rSjPQMlrq8GUb4hJlLfKnwaBbPlXobzEv5LTXdqVi70=; b=idxTN7kYGpReFQVdvnJB+7BZp+wgibKgFrOQmLew7jDYxlNhMbQoDTupV2CjbSX+KI KeMQtIMgvkJkB+lfclH/n6hKhWuRNo8OY1mrbOkWD9DSCdCyldpN9D/4D7cP0bX4aN66 NSODC2lKCZTAyjRqGP8vrT8vkt/Dc+m+bvXOok4me/HwNaeVNqYSuk1vnkfbrfzgAtPL itUNPAIBk/BwwZXhSQWh2SAHg7oaGUK6SagOGce1iKGpg/h6iIRMylH0+w3WDwxp/1nU WTqZ6GW3PF0RiiYLde1m3ah8l6vetkj0IZ+fHc6YkY0SdSf4JvgfoTBJWRZ7SiSm2u9r OdPg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HTv+B/a+"; 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=1; AJvYcCXZopZcXoJsfjUxGDM0Eaw+4FANiIUPEdrLUpJkFI5Y7k+0dIA3n8q7ttEj4G/1EdUSUbSKtdnMKKK8ZuRzl8+s Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f21-20020a05622a1a1500b0042c4c25cff7si2706399qtb.657.2024.02.13.01.41.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:41:28 -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="HTv+B/a+"; 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 1rZpHL-0000xS-Sq; Tue, 13 Feb 2024 04:40:39 -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 1rZpHK-0000xI-QW for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:38 -0500 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHJ-0000D6-2F for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:38 -0500 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-51032058f17so5003271e87.3 for ; Tue, 13 Feb 2024 01:40:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817235; x=1708422035; 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=HXH7ocyncB0lY9SgnkHxBEuiEnRgV5eLtUY0jbLrGRM=; b=HTv+B/a+diHFyi57DMKAZ6K0XUCRIn5k41ReoLgYTjpwR8cPQjwNBgEEx81pkCfYHZ a4YEW8LjxQcNklJ75tURYBRImqREZaB9inWguAMCw0LJm4Z222N+Gt6DGF3FgsmKfotI gRgaK4rx4qp/zwVKzLdx5ldOvPDW8lJashDmS+Fv1JxsUj6CPWnOPMxPreSQ3DYXO7is keUcjklVe+MMle/dqwhSZ0Y0DNEzEZIBmgHR51AptvgQFF2j8ykz+39tII94AOC+Rh79 /PjP78QNuUPYCCo8Fp29hIwGMsp6pagfo3sKI+vOFbheP1DtJIE4B1dC2juB5WxsJggu c1bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817235; x=1708422035; 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=HXH7ocyncB0lY9SgnkHxBEuiEnRgV5eLtUY0jbLrGRM=; b=tag1FlP9JoENxEV69x1PD1RCb1a28O0l1gVn/f4FiJfA2U7IJPJU8zcvH+FHF+5uAj Bjqgq8ZRaplntTHyDDiCAVod7CJC/ZBJCi3WeR4EKNyWDRqf9U3MEnEIfhAf1pJuqjUK M/MXSy1J/fsrv/m5G8HQGeQ1SqxTa/aJYYyEnZEmPwadzzJnCLroJyOSNNZJi5LMslxK dpOcrs9ZouLgtJVU0+9CL9pJ3q030aV1yJn/wvpBPxd1xTglmjIg/WuzwqomEzsdf0KC bVORW2GoguPihED0gOLcxz6LH+lK4Us0j7RcAqyP89NaB2VQg1+Gr2PMIt+blbpkwsZR 8big== X-Gm-Message-State: AOJu0YwRsmXklr2+Ja/WvXktSXhwdnHf76WSFh1n+c92zPtNr3ZfMFI3 g5bArHtZMOMetVTj/BRtwJkkfhqMEU3CNWwlb4U0Ouq4Jv4TiYBJvqo5nEOE1Drb+diBS23WIGB 7 X-Received: by 2002:a05:6512:475:b0:511:78cf:968a with SMTP id x21-20020a056512047500b0051178cf968amr5090128lfd.68.1707817234926; Tue, 13 Feb 2024 01:40:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVoz/QBEqFokc9fO3O9vMVUwfb1w53d8XYUvLlo14SacGcMUg0FNLBVN5nN6CRXs5csl9tz3zTaJTCCdVdFqIWzLV5H/CRB8Z/6xMYxpN7J9Gtik7Dg0MZkASteXHpnhuGKDO3zUApgc4msuiX9rsyplwdXymZKSWPp/8NGoTFW7CvCXnYPuxbhORi1yU7qXBIybbJUYrn3rcQxmO6lMATcFmHN2RIHUuCnH+x3E68a0A21ePC9Csbr7DNeOKxuMW+9vAvpND9oSTcMTkNido6FW7/cQ9X7P5zhSK7ZiwdgftcH0VCtDs5A3YFSDdRZ7bN18wQCHW56DyQy3st3xl9BxniULg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:34 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 01/18] plugins: remove previous n_vcpus functions from API Date: Tue, 13 Feb 2024 13:39:51 +0400 Message-ID: <20240213094009.150349-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x130.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 information is already accessible using qemu_info_t during plugin install. We will introduce another function (qemu_plugin_num_vcpus) which represent how many cpus were enabled, by tracking new cpu indexes. It's a breaking change, so we bump API version. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/qemu-plugin.h | 10 +++------- plugins/plugin.h | 2 +- contrib/plugins/cache.c | 2 +- plugins/api.c | 30 ------------------------------ plugins/qemu-plugins.symbols | 2 -- 5 files changed, 5 insertions(+), 41 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 2c1930e7e45..0e506ee644d 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -51,11 +51,13 @@ typedef uint64_t qemu_plugin_id_t; * * The plugins export the API they were built against by exposing the * symbol qemu_plugin_version which can be checked. + * + * version 2: removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 /** * struct qemu_info_t - system information for plugins @@ -644,12 +646,6 @@ QEMU_PLUGIN_API void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *userdata); -/* returns -1 in user-mode */ -int qemu_plugin_n_vcpus(void); - -/* returns -1 in user-mode */ -int qemu_plugin_n_max_vcpus(void); - /** * qemu_plugin_outs() - output string via QEMU's logging system * @string: a string diff --git a/plugins/plugin.h b/plugins/plugin.h index 5eb2fdbc85e..90f3f324ab6 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -15,7 +15,7 @@ #include #include "qemu/qht.h" -#define QEMU_PLUGIN_MIN_VERSION 0 +#define QEMU_PLUGIN_MIN_VERSION 2 /* global state */ struct qemu_plugin_state { diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c index 9e7ade3b374..c5c8ac75a9c 100644 --- a/contrib/plugins/cache.c +++ b/contrib/plugins/cache.c @@ -767,7 +767,7 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, policy = LRU; - cores = sys ? qemu_plugin_n_vcpus() : 1; + cores = sys ? info->system.smp_vcpus : 1; for (i = 0; i < argc; i++) { char *opt = argv[i]; diff --git a/plugins/api.c b/plugins/api.c index 8d5cca53295..2aaae4e47f3 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -353,36 +353,6 @@ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) #endif } -/* - * Queries to the number and potential maximum number of vCPUs there - * will be. This helps the plugin dimension per-vcpu arrays. - */ - -#ifndef CONFIG_USER_ONLY -static MachineState * get_ms(void) -{ - return MACHINE(qdev_get_machine()); -} -#endif - -int qemu_plugin_n_vcpus(void) -{ -#ifdef CONFIG_USER_ONLY - return -1; -#else - return get_ms()->smp.cpus; -#endif -} - -int qemu_plugin_n_max_vcpus(void) -{ -#ifdef CONFIG_USER_ONLY - return -1; -#else - return get_ms()->smp.max_cpus; -#endif -} - /* * Plugin output */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6963585c1ea..6088dd3714a 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -17,8 +17,6 @@ qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; qemu_plugin_mem_size_shift; - qemu_plugin_n_max_vcpus; - qemu_plugin_n_vcpus; qemu_plugin_outs; qemu_plugin_path_to_binary; qemu_plugin_read_register; From patchwork Tue Feb 13 09:39:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772276 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169077wre; Tue, 13 Feb 2024 01:41:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWraDSTpLLwU0ETNGWgVUdPC4YCcPMe1LD2uEnq8BLeCwW9Q4fuVxe9P0SNY9Mz0p/oX41GcX+vgEe985SRXak9 X-Google-Smtp-Source: AGHT+IEtFl17GlRvMuMC3Ygy4Q1XB9Z1brOkHCrlAQ+R++RRgVE+hz2zUKyb56CTtk9BHiv5O9P5 X-Received: by 2002:a0c:cd0f:0:b0:68e:eb0e:fd17 with SMTP id b15-20020a0ccd0f000000b0068eeb0efd17mr748216qvm.35.1707817288878; Tue, 13 Feb 2024 01:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817288; cv=none; d=google.com; s=arc-20160816; b=vfvZ4nf+4lxkvpfRhYCKad0/UYgmaQPKy2xY48t1lElxGm2CR1lOd6AoMOZXTbxLyV 2wJPccdBbQurul8cTsq6qLeToHqaaiw6NI40MPIoIk0sF2wMISImpFogy7pfacFj2mzV 1sUSQb5yQNSVUZghjIyAUvoro3MTD0Owi6hk/LyNugmrfYOFiKpgXvxiX9m8LOZZkw5K KAml/4QWHY7Dx5J0/qREXkQYrBbVrpuUPN2/EZ8Ojo+WTXsfXjgHYX0x0hZ7BtgHahjR 6UoO0laXVSAK6p46U8zuBqG7ez8Z6IqLePWoy27HXvk2+ynck81Tkp+QgSN6mIibNtlv JhSQ== 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=tr3Be+F/pb6UoTGk/xigsw32PICcW54rqyyS4zJsi9I=; fh=O1jN+kum9smkm7bkU+0imPG8pJg8hJLSRyGjiwU5qVM=; b=Cg4SFsjDaR5+n3U8/ue8OtE77NJ6Kk9VTbLyPE12icoQ7p4AHucC7ijWeGvoWNxjgA MSdzwKaJ1P3VqZOwKbeT2RLg03oDxtWSNllucCApLEDu2c6bpxtaWa0BUKEvv5EYTd8A xt6pdcbbX97yyPvuAtcskrm4Lz5FoeTiJ1c0VQ9y9gLATR4oN9baaByzQCg1PwTBsbyI oI4WPFdBXcRjtE0jIF9SPdvdQ064vlB+iMLjjl4WYxsgkQhMJaOa6c10WFMRBFVT0COz M1loWczVqlJq9s42pY2xmYZgo4aN6PbFKGsV2e7rjXS9zGiWOfu7Bji5xy5Ac9y/AzSl MFNg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kW7B4rIs; 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=1; AJvYcCXnB9MTb75FNl9X5KoxkasZTC0x9ZVzQIhB2HFarl4jcQ902FD8IkFB4TvxKIfHpZUa7FmQaY4GwZs8JqMYLNJ5 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m11-20020a0562141bcb00b0068c43de18ffsi2392748qvc.133.2024.02.13.01.41.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:41:28 -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=kW7B4rIs; 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 1rZpHQ-00014m-GM; Tue, 13 Feb 2024 04:40: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 1rZpHO-00012E-V1 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:42 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHN-0000DO-8t for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:42 -0500 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d0e2adfeefso41934911fa.2 for ; Tue, 13 Feb 2024 01:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817238; x=1708422038; 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=tr3Be+F/pb6UoTGk/xigsw32PICcW54rqyyS4zJsi9I=; b=kW7B4rIsdzCg86mF8yIUte+XlsF7qMMO8pte19yPK0dm/dRhqGNUU9NH/9K3e8xo1e 1hHs2+qMxPyAgO269xnBu8VGZUAV+srggyU2TvZZF3bhRsNj034bWkMFuX9n5GFjM8YY P+/eExWYaVnsHKOiR8G8sldXldCbi4iYMPrDhE+tmDb6VyjGVo5svhUzZ0Y0+bK4/0d4 MdwfaT9wRZ/RRpsZMG05db9WRkYrsbAX9h/2AS9zoCXGOJAfhCBDdUUiM12nVLPj8CXw 7kNAxC4k0sLhYRlzboBzxp1QTPvxfyNF2WvvqdAdDiglp0rbkAZ3JgVb8klMWkBc2N89 cwZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817238; x=1708422038; 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=tr3Be+F/pb6UoTGk/xigsw32PICcW54rqyyS4zJsi9I=; b=AsTH0yJdn0JgyhNO1TM8FGS5PqDG5ecVZrLBsKmamvQRW0r8gGKKz2BpFwYdfodOA1 hdRBxRFt6NX3IINXpofSS12YVBEfRJtoZuzTlvH1izrzRnMCuhBleyenqb0V4TKwmSaB IupZuVYOe3Ws78p82f2GBHNaduYu1npsV01XiZUvi6NFBb8mQJX6PLVnK0wzun1cZdx8 o3m0UQir6u9AGGeHsPl9T/FteCwhArr1vBLkROWlnqkKKvmtCofP4Murgho8nCuWhN6J YvHoMFa9QQWmaoGZOCHWZB8ur6lhOBlQlkiX02qe7zkFM87mwnBCGwwsFcwH6b2iUmKz 5r7w== X-Gm-Message-State: AOJu0YzcS9SZfLgnXq1nNd83fjJJf5BxE+0QrJTU62VD95lFWPy2PtGY oXXoUOzjLTV/K8oKe6sC87T2NNvn9Kuehb9+96oEDuy74A4YdzyfwRdu6/JchrnBs4zJ7s7mkdg l X-Received: by 2002:a2e:b5a7:0:b0:2d0:d40c:e83b with SMTP id f7-20020a2eb5a7000000b002d0d40ce83bmr5510414ljn.30.1707817238531; Tue, 13 Feb 2024 01:40:38 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVhsbef9t/X5AxL6Tl6B24s9WHqvyksnAG0y0rfdBUUcKOZWPNzPKl9176x5IwDlZJeI/RoRBPgGJI3pwfwF7UxcmuPKtd1ZTfWF2cUFVFRj6uuYJE5gDVAAqbsWW1erjwsa7Tt5pO56JTRHdRInnW/mSAw/OvxkNztNY7X9C8ewwFy68JrVs5iUOsTs90MoqKS1+fUMXw7j9qG0IipPns3ZzcrDd7DxzXDTqKq6nVqXLBTYgRZQ73g9anvmfFrEqXdrsggyRCjJOGx5c4E3aNqMC4GVwC+NKjOPflGPB7yxUJVYCp2J5U07urSLL3k+jQZQq+VXkEaE7O+wGMyE8Dju5DiFA== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:38 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 02/18] plugins: add qemu_plugin_num_vcpus function Date: Tue, 13 Feb 2024 13:39:52 +0400 Message-ID: <20240213094009.150349-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lj1-x235.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 We now keep track of how many vcpus were started. This way, a plugin can easily query number of any vcpus at any point of execution, which unifies user and system mode workflows. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/qemu-plugin.h | 3 +++ plugins/plugin.h | 4 ++++ plugins/api.c | 5 +++++ plugins/core.c | 6 ++++++ plugins/qemu-plugins.symbols | 1 + 5 files changed, 19 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 0e506ee644d..e94ae4d2abb 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -646,6 +646,9 @@ QEMU_PLUGIN_API void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *userdata); +/* returns how many vcpus were started at this point */ +int qemu_plugin_num_vcpus(void); + /** * qemu_plugin_outs() - output string via QEMU's logging system * @string: a string diff --git a/plugins/plugin.h b/plugins/plugin.h index 90f3f324ab6..00b3509f708 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -44,6 +44,8 @@ struct qemu_plugin_state { * the code cache is flushed. */ struct qht dyn_cb_arr_ht; + /* How many vcpus were started */ + int num_vcpus; }; @@ -97,4 +99,6 @@ void plugin_register_vcpu_mem_cb(GArray **arr, void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +int plugin_num_vcpus(void); + #endif /* PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 2aaae4e47f3..dbfc5e83729 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -353,6 +353,11 @@ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) #endif } +int qemu_plugin_num_vcpus(void) +{ + return plugin_num_vcpus(); +} + /* * Plugin output */ diff --git a/plugins/core.c b/plugins/core.c index 49588285dd0..9e64820ad02 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -214,6 +214,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) bool success; qemu_rec_mutex_lock(&plugin.lock); + plugin.num_vcpus = MAX(plugin.num_vcpus, cpu->cpu_index + 1); plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL); success = g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, &cpu->cpu_index); @@ -571,3 +572,8 @@ static void __attribute__((__constructor__)) plugin_init(void) QHT_MODE_AUTO_RESIZE); atexit(qemu_plugin_atexit_cb); } + +int plugin_num_vcpus(void) +{ + return plugin.num_vcpus; +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6088dd3714a..27fe97239be 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -17,6 +17,7 @@ qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; qemu_plugin_mem_size_shift; + qemu_plugin_num_vcpus; qemu_plugin_outs; qemu_plugin_path_to_binary; qemu_plugin_read_register; From patchwork Tue Feb 13 09:39:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772279 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169162wre; Tue, 13 Feb 2024 01:41:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWoEPecVaR35/jjgYXIk53ptQnjR91YCBX4PhpWTuVExYUWS0N+d9hQcChxy+iUJ6FkdlE42Z5w2Prdy7snQ1Z2 X-Google-Smtp-Source: AGHT+IHa7wI0gzFl3AqbDokt3jdtlFMLZGUG5mvsf1jVELgBxxk8i9NY3RpsxaOWmz3+KqmXqzJw X-Received: by 2002:a0c:e40a:0:b0:68c:cd44:2c8c with SMTP id o10-20020a0ce40a000000b0068ccd442c8cmr3263700qvl.2.1707817307992; Tue, 13 Feb 2024 01:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817307; cv=none; d=google.com; s=arc-20160816; b=dCjH8tuKq6S6vOz4JtNtR/jaYEan66te6doM+DtNh3znSQ9CE+rE0hrD4f7lHG1NQw HyvsDkSS6NUao06WfXpozwDkK8ZU4Fa283deBO3s4zJ+rcTOnvTcL1bcQt2BR2uviA0M a1Q40/XzTQZuMYLStdVUSgnxUZpMK8Hww2Xcb7ZVRonaSbTqHRyPThVZ3eZpytrI+y4U iI89ZWcVXEKyG5xzYugyd8qXTT4ma8POQb0GpEbwEUiUEJkQ2tt8ZfEL8pq+lrh+ZRtw GQN5aZqMhZQJlaVQDlAP50+kbOrS7iQtwy3LV8KPYaMc4xAasZ1+2hDvKEwMKBna2H4I 1LVA== 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=7OMHh8GGh8vwtiEG6gdakeI1gV4koMSCEXADRE/Fw5g=; fh=yqTesIdZxKVoELPI/qgEeiSV5PeQKNzB3G47cpylgwQ=; b=q2Rm6+tA2sNzJPGcQ5jzS9Xyojx18ogj/uI/e8v5RdlVGGghwUud7ETWnjavqpQxZj 6jWP44Pkpx3A0rdAm6FWH9fnEuGZ+tuu/LJtMEK7MrydS8grUnFroYuZw0czM8c+sD62 fWoy5XNmtV5UfwXUOmg3Lwf9C7hRZnmJ2sBkZs9kWtgJ6I42V3haW8c01G7a1MAnW0WT pIrr4guWNhW3UyUHYcT29W15saawIT2oTrzseDwOFGLk1rr5XdsDBqjYEL3DD6N24UoH qKBaKRHDfz8hpuefFepdJgbGT0QvWzN/M6k9bzM+b6Pi5j7I0TFkQk5jjYSqHoWvQb/h Ohzg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eovAERRD; 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=1; AJvYcCVVlJtwX/+XnVriqjI9oxr04LvzO/ei+5eLldMhDp67Qag8OsifT9d4pY4O8NTQJWD+OKr2FzN7al56lgcsru0u Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t7-20020ad45bc7000000b0068c46c2e1acsi2341781qvt.547.2024.02.13.01.41.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:41:47 -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=eovAERRD; 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 1rZpHW-0001CY-9n; Tue, 13 Feb 2024 04:40:50 -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 1rZpHS-0001B5-8B for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:46 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHQ-0000Df-3v for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:45 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-411c3b299caso1992195e9.0 for ; Tue, 13 Feb 2024 01:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817242; x=1708422042; 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=7OMHh8GGh8vwtiEG6gdakeI1gV4koMSCEXADRE/Fw5g=; b=eovAERRD/jRvQYdHC80D8MNEEeM7S/omJM9Lg9Eu4iSrp113B7m0qA458B8Ju53IBd uTfds5k5CxzJeREqjnl8xgipkgB1NXYWsY/GLtFb6xZxS10Y2BLh2JkO8Jy9OFbSCtoC RF4gJEIKkirrtntDE327DEAVanksZSn/kVu/VbSJJ8yokDOLXbHzzV2IiyF+SpZHm04Q 9odoRQSZ7AFEyNnLSslRw3GaW61Np8njOc3W2YGkkBQGBdH+1YW8wJ06aNStcvYC6U03 Zepckxg+Ydv4IWILr9b9AevlLBOJZ7MRl5KkhC9S2nA4H8ziJyYSsbwoMcIWlmGGkffm VDYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817242; x=1708422042; 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=7OMHh8GGh8vwtiEG6gdakeI1gV4koMSCEXADRE/Fw5g=; b=EEPRkidUrWA3z0/v3E0HdstarwDBH0ooeoQxSGfJBufAMJMskah7flmUhXyCVG2Jt+ xE2qjybEuyip60JWVqO0tXhJI4BirZWERXDKbgEnmm5/01ONTh/EQ8mIhcN6XlfIzdyX Ae1krW2z9QG60ZtN09k8/RE9OSKeN2EQ7/nN3NFqBB4H83DXZKjlvXNL82cALCH8QDAL HDBrm2IXl81tqLU40DZwmOy3ko13RIfxsBhtyhEOirMAOSGKMFUGdLuCUZ6cRXskQ9KF TOMswcZsv+O22LLeDxLz04EFSgCrqp6ZQrL33KNvO0+VWf2Bzw3lc4XO9CwQBDVgn08g 3AHQ== X-Gm-Message-State: AOJu0Yz2MRBOQwRact8nyhGSFQVhgrqZsZjmRXiUHIjPhtj40pXmn8Rk vmwFJgZgeBTIQPGrcjeCyPHGPiw0YIo4fdUvR/0ZbgPz+YOa3Wm/v1F47CNOtVB54sYa7xDRtLV y X-Received: by 2002:adf:f9cb:0:b0:33b:28e0:e09c with SMTP id w11-20020adff9cb000000b0033b28e0e09cmr7232263wrr.61.1707817241998; Tue, 13 Feb 2024 01:40:41 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXyswyAOchhje/+6uLfozCOJTI63q5ETnDHLLsSAtOTOtZv4Ss9YJf/3uLRN5eSDFT8HOuqnKtWANj21Hcg4DJMRRfx+G7dBenGq7FM+qA/x4nd1NEKw6N6cEkF8/Jfb8ctFYYa5WRWOg54L5g9FN+KUwsGfVcieUiCizxLN2QABwS/TmZOs6/D8r4CebmE7Uq0pYiLEhhSVTM2PWqN741Qbt5SLvp6xU2cvOv5y5ChBFP9IoP1MTwRqvQTJ+P/5cZkpqSbdMV0nj5FGGpnXXS18TaaUkOSshw62qVaXVPRdTbhw+V+Wl5E4NirXyvNrZ4sAzSmXJfP6ysv5LEozqf4WSQNOQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:41 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 03/18] plugins: fix order of init/idle/resume callback Date: Tue, 13 Feb 2024 13:39:53 +0400 Message-ID: <20240213094009.150349-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x334.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 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 --- plugins/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/core.c b/plugins/core.c index 9e64820ad02..609d9d5c184 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -392,12 +392,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, From patchwork Tue Feb 13 09:39:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772290 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169646wre; Tue, 13 Feb 2024 01:43:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWy1RrkdOH51yJttmDzfjlckUMnsZFx9rgyIvBNCCypNqF3GQs5GWhIFeDhkRm3i4Ch8r68nemhY5jL0kwRsV3K X-Google-Smtp-Source: AGHT+IFyqy1PktEePD9o0OYp4Y2DW3elo6idqIXAwBUe+av7rfNbn+8zRSeP6wM+BSoxxQTBXW5R X-Received: by 2002:ac8:5a89:0:b0:42a:86ad:8824 with SMTP id c9-20020ac85a89000000b0042a86ad8824mr14409305qtc.15.1707817410562; Tue, 13 Feb 2024 01:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817410; cv=none; d=google.com; s=arc-20160816; b=lLbN36EqzcgYft7iO6FzZDwIJ/Iy0Txxo5iZUFcTveAG39uIo8fDv9tRAK8D017Wob jz3MlTOgR9fSbJC24Wj/3HiW3rnVxLkFeQFNlS9/RH8e0jWj8RKwZJtATd9IZUR5h4j8 /MA5FHD480BLnB229jFl8fmiET/KDLir+GAVaQzckKTYfhT+iB2yEwyW0QUDWGtpp8Fd QngrKjwZr69gmQPjekkuLHNzBAcFvJWug5icfN9g2b58JGrhA7tNp/yBb00t97wiGa20 sRxKBhawHefa/9NOPSXERYLrPqTWaWzE+XnL9Vtg4wGGOfw6lsvx+Wur4A2ZPzq80bbC XebA== 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=MhKqsf2G7q2jxsX13Ny5Px+xNhV9GwuKJNdrlayG7WQ=; fh=1Ve8FykCfrG70rcXbGXfoF5PwczJy3FL95mEjQzMSzI=; b=n1JRl2nTvCwglCqoTBqDcNibeIDYqMeVnYzInKFiz+ZTtHXhoIrlQqY9YLcUhzQEbx ELYvQsDYYBp157xm5ojcI5e0CU5aM1qKU4oXMgkV80K9K4H18vR/rI1g1f8rTHgRWqC9 cUYSN9G4xdsqAZ0LJgpnunZId3OtGM+WwRKj1ruweTqXtlsn+KK3N1VuzlHIP6UciVQC ra2iqs6cETSaOrMH7L7jz5byN9NE/WFsXOJTJR2EYpDuh3UxA/IoRLCX0kKesv4WhKRL tsRyfWxH3Bzo1o39eHFSFVHjPLbz9sBbA+qn/Yp5lg30VHgJsWAXeQECVMxOSM/sv2fc WzFw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BjI9h8l1; 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=1; AJvYcCWB+ilMmWEqvfryzIOKhm72n99b/xMR13S0GiMDdJDK99VQYqBfR7e5Fqn9PugpLFO+kvciKKrkZh03WzbENiav Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c7-20020ac87dc7000000b0042c3ea16249si2660146qte.677.2024.02.13.01.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:43:30 -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=BjI9h8l1; 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 1rZpHY-0001D5-9J; Tue, 13 Feb 2024 04:40: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 1rZpHV-0001CU-OJ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:49 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHU-0000Dq-82 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:49 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40fd72f7125so33217345e9.1 for ; Tue, 13 Feb 2024 01:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817245; x=1708422045; 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=MhKqsf2G7q2jxsX13Ny5Px+xNhV9GwuKJNdrlayG7WQ=; b=BjI9h8l1lIDg6gdy7/quqtvVBW4iQvYZAsdI/48HrvLwjsIGEQvEn1rzF5MBlNC30i /WoX2VgPb+gn1X1+l5TjybvpjACu/WfM+ktH8GaLZWidBZbj09aZMf6j98bmgloe+Q8d kYktYnVX+3UV8kluIbszq584SZr4BbrYeWS6whFw/G9smjKiwGQ24YlyDBahiPmgqkg1 LUeEl2sqtKS3JWBRY5y11XJmgMDlU8qybTsCkIRldC4SPpUMkleGmoJAOv6j+IF6Q/Ow PWAbDryanXomwMwmbfYh3Sy4YyNiFBcvqQC624oDYUaZUls7HWWcQrpd1ysr4j1mg+KW BQ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817245; x=1708422045; 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=MhKqsf2G7q2jxsX13Ny5Px+xNhV9GwuKJNdrlayG7WQ=; b=oC9NdVQPZsvEo3F9TuQoRTwfmaQEBeWTMe+baOkn2LEtrycX49Nvhr5nwSCViRXyjz 7xrnPRF2Y3kVIX/vPYdMSp3fve5wxIgU2PEjNlWbLP9hawzavlRT3kjJXM5w7KXwIrGp AXP565I8wMBSva1FHM+QcGHSD+627wVjMiSgkAtS6BMNd5nhGOkwM/Hhghtq+hkdCps2 bd/agmSSj3oN73WsRoxM5J1Ei0CMDMMaBlXK1LWSVHfd/2jYbavT/HTAyu1HZyYgshZC A7nEpRoMts3I2P4nlMcETFWinKneI66ESAB5mUlio2WyPhlboTCCQsofu//pJzDn+cOt 8lbA== X-Gm-Message-State: AOJu0YwhGwsITl6X9ggbWP+pO1cOzPTWObC1I9HMZW4WeW2SYOZtBpob yUReczsBSWxjfPre5YjEbZJ4mzAT31kxP0YWYEj5EpgzcC04A1MyJQHSyvEJQKfoiHVKAB0IdYC d X-Received: by 2002:a5d:4537:0:b0:33b:4d7b:a736 with SMTP id j23-20020a5d4537000000b0033b4d7ba736mr6070659wra.19.1707817245440; Tue, 13 Feb 2024 01:40:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWVn+w6XiSx+v+B30oVHCbHeKj+uUIl//XmMnOo5Wcz6B6PvSRA5TpPvZldRS4sPD8geXwmk9rRGkqmxLwfGLKmT5SHqxL+gR86Hb+51xfrMWiU645mFW20JClXKVmHWv/2zyStSsdlHHSrY7DxGnBA+/NezAJ+fbcNNWwVg/U8wE3+Q4AZvDbqn6Ariia0pExUWiavabCpAxxQC2aeGMAvae3UM3pH8ZX0rJXBKS5vaNh1GywwYpWEritqon/mWXPB5a7PSdw8eFmr7nEl7j6/VnvypEe6Znn2vfsm8GoAA69hw13wC3+4FWQbA91IlHNM+t7oH1+wYrKXNL38qmvNP5zxAw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:45 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 04/18] cpu: call plugin init hook asynchronously Date: Tue, 13 Feb 2024 13:39:54 +0400 Message-ID: <20240213094009.150349-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x330.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. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- 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 */ From patchwork Tue Feb 13 09:39:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772289 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169600wre; Tue, 13 Feb 2024 01:43:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXleNw+1SnQicCBbWvTtCXz3O55PF8GjKw1u4i2/Yu6mre2yYnK86ND8t3SuBMjFDGQ/iloit1XrStrc+jMgA3S X-Google-Smtp-Source: AGHT+IHhxFkba1jH26gXGt6NFtGdrBxZUFsgFbDjsqVDHbnZJnx5McQC0vHepaYoo6STFCJlJZWA X-Received: by 2002:a05:6214:33c4:b0:68c:a0ec:1a39 with SMTP id mw4-20020a05621433c400b0068ca0ec1a39mr3522441qvb.21.1707817402536; Tue, 13 Feb 2024 01:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817402; cv=none; d=google.com; s=arc-20160816; b=d5iuf2Waqp4WMk53FJ0KOuzgYu2Kn/LREm8OXv4V5qu00rNy9ZNjQV/go4wDWPzHPq B3jXPF/nRZQyF7JoI5gjYDiXI1osEJNV3b6zX0DCS+HzQMV3I435zzAwyDTVtQimTiUv Jtqgiwuaz128wGqrdNOSSIrkCOmYwazrhBmYM4t9zaJVANfla7bKfl0S7aNm88dIaaV3 q3vIH2WUddgc8zDFaI1ay7/9yEyBW/viOTbR8eVamxmlnV3RuxwgXJHYcvDT/0yU+gl5 K7ddGQ3S95dIcDFkmwOLkVOHHK62UfqYJumdB6H0JXxFQKQ3E6EH4vwcNcJ1aQvYPoef rrXg== 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=vCBh+sFjh3zKr3oSSR0kXcIxKMfrzUcKpwKGEsMrXDk=; fh=7w4nfgb92Vfio8WXtKbbrCaOQN7w5FxkUt2F14nDchU=; b=MMrOS0gm0rUmtjMQviTFaMmeVAVwkai9Tz2ONvqQCYfKgGhQvqh3R4FrmoAnQS/5JE RKhD49eHo/zzVxAKdM9ry5aVa6/eh+WdTBg/QSO8LqFe3Mtzvk0QWtDwDyLT0k6SzIf+ h1C//WVRo951fG5prw940+a408I4hllAN0YIkoKnVOIlyWY63UujrK7AywsHa4+WJKOD SxOyWFiE2QNhA2INOSr4KB+RFKyErknIF4oPHxUxxtBbWkHav2+F4G+4EDSXjDHXgB9Z rMSWRyz3VySNw42H1mDAcfpCm79B1QSbcMr7pqe0tfo9blF4jZnr5jFmgJI6gaiT4Us3 6cFA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pGyBTzOw; 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=1; AJvYcCXLhhpL5GBXlAg0gtM8boEE4Z2xMYKc2hqyyWmFKjdYixO5BO8dAcZh6n4jtSWes4s0x3NKKhAkZcX9nOj787PP Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m20-20020a05622a119400b0042c4beb7552si2643688qtk.800.2024.02.13.01.43.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:43:22 -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=pGyBTzOw; 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 1rZpHd-0001Du-Ii; Tue, 13 Feb 2024 04:40:57 -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 1rZpHY-0001DL-W1 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:53 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHX-0000EG-1k for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:52 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33cdedb40c4so115643f8f.2 for ; Tue, 13 Feb 2024 01:40:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817249; x=1708422049; 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=vCBh+sFjh3zKr3oSSR0kXcIxKMfrzUcKpwKGEsMrXDk=; b=pGyBTzOwt1pO4wasGYZ663qBL63F5iAAzateDsIsees73x5CyuM4kdhAaGYpPbiGhv zso++uxasw4KtGU0qLsmaeWoLNjaHwvkgLPHhSkqrf1Z/JFx6RWR5BlbCm7e4tHs24k6 RXrKKQez9W577AaphQEgag+ruGVTu2ZAOp3J/ZKsd8dO4PuZXJsL7XjDV1AFRvdGJMj7 sYE5G5E9zIAGfqR3dbzK/EVdEBe0+IwrLhv6vWRCYJpRrhCezeFMPr/wvZUQz5gDmAP7 STVVlIRtAfyXOTODQfw1eOwF3b0H4meHyQYm9gDUbsLAVDOrskcDLTMK50iLiAYp2Aar psfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817249; x=1708422049; 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=vCBh+sFjh3zKr3oSSR0kXcIxKMfrzUcKpwKGEsMrXDk=; b=IynKsScfeq9TAeN/+Ea7i3nMitawZcRnyB3P11HiN1cWUlLgRXenlzHAb4Wn8Aajyh 7GLZRgBpRUESzc6734J6iL9jQZirJhNQt66GtvpahRM0N5tqXMuObNcOoBLFEbRWhPSh W0gfYDEGibCcDbd4edeVapNi6KJTP4DyfFz6Od3YV9v/cmjfJTXIFn2ELWBTrLbAuys3 U0C3qZROq6Tfm7f7tlJJdUaj/PrX5XC8UKLEpiKOoND257Bn8deYm2wOUrtQNIe65Ab9 qtDubVOFGye568wH8DefLagdgLHgBE3KcjAG7usAbJVs+AoSqhTAi2hJbdhRUNlSzXRD 6JhQ== X-Gm-Message-State: AOJu0YyMxCDE3tCGoaWkT/kqJBm2eskLvHkpkMwiUMcCBCzz5w8K3D3X HLuAF0njqzm9tSgjKniMk7MGDtxIBV5IcV+zaHlGPnjCjS9DdniiGruGaM5uUlShOMG+2zRHcga y X-Received: by 2002:a5d:64cd:0:b0:33b:80a7:6538 with SMTP id f13-20020a5d64cd000000b0033b80a76538mr5540062wri.9.1707817248913; Tue, 13 Feb 2024 01:40:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUoNh9OoWmD91vZ6JyXJYp7SRfT+u1wr4q5CDbFVCZSB6nUlbR3XD8qg5oTEvioJJJOIOOSCUDgcBtzuXoELGka8SU9p+cmJ9A6DA3SyMDLnoSSH2EkU6Ia8TI6s8tTcxR+FC4hOdDM9DdtqemOaXhM/dSoe7GgfrUreU7EXMSMjdW0I6bGzXvCDLDuNocrDYS00xeRmSqtD2BD/clv3qmQGngjVssoizK7PAv86sfeJXrWLp2X60fNOnpK5oM4zNaKbEvwhslTpp3bH4k7oEt6iiHG87C9LdTmxAiXH4+bKBTn4oHtqhmwkD0X7S7yiM8JnfhR6oXiEms6m3rq+UidwI1HUQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:48 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 05/18] plugins: scoreboard API Date: Tue, 13 Feb 2024 13:39:55 +0400 Message-ID: <20240213094009.150349-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x436.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 We introduce a cpu local storage, automatically managed (and extended) by QEMU itself. Plugin allocate a scoreboard, and don't have to deal with how many cpus are launched. This API will be used by new inline functions but callbacks can benefit from this as well. This way, they can operate without a global lock for simple operations. At any point during execution, any scoreboard will be dimensioned with at least qemu_plugin_num_vcpus entries. New functions: - qemu_plugin_scoreboard_find - qemu_plugin_scoreboard_free - qemu_plugin_scoreboard_new Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/plugin.h | 6 ++++ include/qemu/qemu-plugin.h | 31 ++++++++++++++++++++ plugins/plugin.h | 6 ++++ plugins/api.c | 20 +++++++++++++ plugins/core.c | 57 ++++++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 3 ++ 6 files changed, 123 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index b0c5ac68293..ccf9d2ebd2d 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -112,6 +112,12 @@ struct qemu_plugin_insn { bool mem_only; }; +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { + GArray *data; + QLIST_ENTRY(qemu_plugin_scoreboard) entry; +}; + /* * qemu_plugin_insn allocate and cleanup functions. We don't expect to * cleanup many of these structures. They are reused for each fresh diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index e94ae4d2abb..0994935d4a2 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -222,6 +222,8 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ struct qemu_plugin_insn; +/** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ +struct qemu_plugin_scoreboard; /** * enum qemu_plugin_cb_flags - type of callback @@ -753,5 +755,34 @@ int qemu_plugin_read_register(unsigned int vcpu, struct qemu_plugin_register *handle, GByteArray *buf); +/** + * qemu_plugin_scoreboard_new() - alloc a new scoreboard + * + * @element_size: size (in bytes) for one entry + * + * Returns a pointer to a new scoreboard. It must be freed using + * qemu_plugin_scoreboard_free. + */ +QEMU_PLUGIN_API +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size); + +/** + * qemu_plugin_scoreboard_free() - free a scoreboard + * @score: scoreboard to free + */ +QEMU_PLUGIN_API +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + +/** + * qemu_plugin_scoreboard_find() - get pointer to an entry of a scoreboard + * @score: scoreboard to query + * @vcpu_index: entry index + * + * Returns address of entry of a scoreboard matching a given vcpu_index. This + * address can be modified later if scoreboard is resized. + */ +QEMU_PLUGIN_API +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index); #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/plugin.h b/plugins/plugin.h index 00b3509f708..043c740067d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -31,6 +31,8 @@ struct qemu_plugin_state { * but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + QLIST_HEAD(, qemu_plugin_scoreboard) scoreboards; + size_t scoreboard_alloc_size; DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); /* * @lock protects the struct as well as ctx->uninstalling. @@ -101,4 +103,8 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb); int plugin_num_vcpus(void); +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size); + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + #endif /* PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index dbfc5e83729..76fbca685f4 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -521,3 +521,23 @@ static void __attribute__((__constructor__)) qemu_api_init(void) qemu_mutex_init(®_handle_lock); } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size) +{ + return plugin_scoreboard_new(element_size); +} + +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + plugin_scoreboard_free(score); +} + +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index) +{ + g_assert(vcpu_index < qemu_plugin_num_vcpus()); + /* we can't use g_array_index since entry size is not statically known */ + char *base_ptr = score->data->data; + return base_ptr + vcpu_index * g_array_get_element_size(score->data); +} + diff --git a/plugins/core.c b/plugins/core.c index 609d9d5c184..cd0c717e291 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -17,6 +17,7 @@ #include "qapi/error.h" #include "qemu/lockable.h" #include "qemu/option.h" +#include "qemu/queue.h" #include "qemu/rcu_queue.h" #include "qemu/xxhash.h" #include "qemu/rcu.h" @@ -209,6 +210,35 @@ plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, do_plugin_register_cb(id, ev, func, udata); } +static void plugin_grow_scoreboards__locked(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.scoreboard_alloc_size) { + return; + } + + bool need_realloc = FALSE; + while (cpu->cpu_index >= plugin.scoreboard_alloc_size) { + plugin.scoreboard_alloc_size *= 2; + need_realloc = TRUE; + } + + + if (!need_realloc || QLIST_EMPTY(&plugin.scoreboards)) { + /* nothing to do, we just updated sizes for future scoreboards */ + return; + } + + /* cpus must be stopped, as tb might still use an existing scoreboard. */ + start_exclusive(); + struct qemu_plugin_scoreboard *score; + QLIST_FOREACH(score, &plugin.scoreboards, entry) { + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + } + /* force all tb to be flushed, as scoreboard pointers were changed. */ + tb_flush(cpu); + end_exclusive(); +} + void qemu_plugin_vcpu_init_hook(CPUState *cpu) { bool success; @@ -219,6 +249,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) success = g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, &cpu->cpu_index); g_assert(success); + plugin_grow_scoreboards__locked(cpu); qemu_rec_mutex_unlock(&plugin.lock); plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); @@ -572,6 +603,8 @@ static void __attribute__((__constructor__)) plugin_init(void) qemu_rec_mutex_init(&plugin.lock); plugin.id_ht = g_hash_table_new(g_int64_hash, g_int64_equal); plugin.cpu_ht = g_hash_table_new(g_int_hash, g_int_equal); + QLIST_INIT(&plugin.scoreboards); + plugin.scoreboard_alloc_size = 16; /* avoid frequent reallocation */ QTAILQ_INIT(&plugin.ctxs); qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, QHT_MODE_AUTO_RESIZE); @@ -582,3 +615,27 @@ int plugin_num_vcpus(void) { return plugin.num_vcpus; } + +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size) +{ + struct qemu_plugin_scoreboard *score = + g_malloc0(sizeof(struct qemu_plugin_scoreboard)); + score->data = g_array_new(FALSE, TRUE, element_size); + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + + qemu_rec_mutex_lock(&plugin.lock); + QLIST_INSERT_HEAD(&plugin.scoreboards, score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + return score; +} + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + qemu_rec_mutex_lock(&plugin.lock); + QLIST_REMOVE(score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + g_array_free(score->data, TRUE); + g_free(score); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 27fe97239be..3f93e7d6b13 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -37,6 +37,9 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_scoreboard_free; + qemu_plugin_scoreboard_find; + qemu_plugin_scoreboard_new; qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; From patchwork Tue Feb 13 09:39:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772275 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169076wre; Tue, 13 Feb 2024 01:41:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXH3YhfK8H3/bu9+d+LiKRYCTRDZ1lMHOn/sjI8FDto4z3yOM7y5s+m/5j+7ssdkBkc+P3YNyjqIGfUvUVrPiyQ X-Google-Smtp-Source: AGHT+IFQQHfr02PelFRtfs3cLJziiJl9wbjRKWgsp4HbGIAb90feKJz4A3uF2hiofrxVtgv5L3DW X-Received: by 2002:a05:622a:254:b0:42c:7bef:c3bc with SMTP id c20-20020a05622a025400b0042c7befc3bcmr5204446qtx.53.1707817288845; Tue, 13 Feb 2024 01:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817288; cv=none; d=google.com; s=arc-20160816; b=mugUiEjASWsj/mY5J2pwuvkv62vTp2LQ10H2hr2bpeJ8BnkqlI3OUGhR6Mi2ZghmMF RUtmmz0AnvJ7fS9YAK8bEKsYT+cGJ3V0060+bH3x1nnt9N4A1l/FzN0Wzr3NCLUodImU s+jAAvru7AQ5WDRtDrHJVhQHxWO3KlekUXXsyEauFN7EeQlXpdY7NinmYgI2T2I6wJ2B qj4T5LCoBMeTXjw0A0yoaq6s0+UAtI8VPEratq6Yn1J/D238ptwU/9e15RLvNrNbyCIa Y72TARtAbguns0wfhzj96PkHKI2dEzUxA6FYhbISacNH6u4hP7oP2C/+Vr365GvDQrx0 mrbg== 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=0LuglNIxMpcc450MgwB+/bbbw1CGJEy0QfnhDLLQmYA=; fh=+oRXYNonfPPZ9W0YxBXGbRVBnjQ/dkVYPQhScNZMRss=; b=m7MTPlmBPO4xEagW9YM3ByWEB0Znsrl0RM+bKPxW9twmCxhGAlDPicpmiri2Lcp1gC lM5B+ZYw51aSyLcGVgyCdOb/I5JeYcCmoFTYGroTm9FkYuEfbZDL8BnTgBaXAA/IOp/C a2JXgD4hT9j6gZ14XjkcWP/akSkzXJ0mKjf28wiYq2xFT0pTVQESoKAGSjna5WgxNDtH WmLATfr35fVSOYCxVFMnxWi8nV0gEawe+B4jFR/4IUfofoV3Nv472bfk6jFQXCQXxAJU CrEg+obEA8nnBaNhyaNx3AB02woOu9acrTDVXhT1Nlrr/dq+dreztfEbIlGJXWE5q47D miVg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zgbr7kAN; 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=1; AJvYcCVNbJtzwpppAmHCVhclOHHVh7JqXgMiciG7bgMGUQbO/DUrxrTakDE74RGOIrgs6odL7BcyWsGP3/XwECKfC716 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f9-20020ac859c9000000b0042c7c277572si2641150qtf.517.2024.02.13.01.41.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:41:28 -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=Zgbr7kAN; 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 1rZpHe-0001F6-LO; Tue, 13 Feb 2024 04:40:58 -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 1rZpHc-0001Dx-4t for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:56 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHa-0000Ei-E8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:55 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2d0a4e1789cso49138081fa.3 for ; Tue, 13 Feb 2024 01:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817252; x=1708422052; 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=0LuglNIxMpcc450MgwB+/bbbw1CGJEy0QfnhDLLQmYA=; b=Zgbr7kANLtHQLmbyRvRDAG9Rdjsts9y1KFtyQn3hcWl7dMbI33H+lQe5BXqKmkJX6L yfYVa/vWe/9DMH8MfQFBPGO0o8rKqADfy2k4P//IOUgKVK17nJ2E4reAdLAUBqzSd4rR sGj2ECE8sDLzT/KT3B4sla+MkzEtgYxpl3aY6rffcrVqJjpUZCE2TlXS1lXLD75vk9NJ 7sMuPc4Jfd2kZ1rbVrh1r+Bb7wiKeO+uKxcch4PlO61Xx+lt1AlyKEPcGSwEcypkXtzJ aPBLG0yDNVG/EhcNJUxFkI6TaEKwhLXu2fC8x693QLgwjfelLwV34k+33+EMO7OvV1oB cTKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817252; x=1708422052; 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=0LuglNIxMpcc450MgwB+/bbbw1CGJEy0QfnhDLLQmYA=; b=emwVzVQO5Hp89wWiWXJ2EZH6rN64eeCZ57yES7LSYY4uzQCzU9Gib4kTFWfH4lE1m8 hIa+ta8U9yJbxXbCBAoDcRhH6nwkeQTyPxbho+sqsuIoj4TzxhI21lM4+RpArGF/WML4 N012OReCBTxyS42YabBCNM8pabBwiYGmBYDPH2C6sNjH4KaWDm5UbUxcCdKQFs4I14JG mthbUCxkReTqlHtFeTHLH1bd7modENKgV5zgsFkUMiQKuyyx/lJjiwbzR1pQxdqdI45U Epvemj+NPPZCkDIgQ0eFDgZ8Q03OaBL8rRLzu8Kc3HOCLfQtxyBPDLH1MBb9aPO8U5bZ Vc5Q== X-Gm-Message-State: AOJu0Yx+CFycZSCLTBy6Anvc+al0c/MmC3Ck/tfBJC1Gu224tWvbNF22 Y57Py60nGdQuNic43mPk1Sp9/ZbhHCwDLpq/C4pIB6U0XCfpVEE8CryPqH5wpzr4XkbQa/fvPr4 a X-Received: by 2002:a2e:90c3:0:b0:2d0:8eff:286a with SMTP id o3-20020a2e90c3000000b002d08eff286amr5711960ljg.40.1707817252422; Tue, 13 Feb 2024 01:40:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWn7y5+L/t77jcZLWD5M3etn0ob+uBjo6PBehIQV2hC4Oy5KM5+kRVqQXWcNjHFItGf3iaYhiytsdLipI3y3oRy9awFsf5BH/h7wcCGQcxWzQWZEoRDC1F8NAdKUKPHmP0A4DgKBtaB/7FDYxlphposuHpeOigm5259KuIPgnt6loIIbJImL90/arp9NypanvEDNz0uVtJBopUdwMh2qNqy79g3n/1NSDU/kYvYfPbLdVCI8Obm6PhYEt6XwLSAyGq0wDeFAmDJQtH5lCp5whvm5N/tsKKijdax00FD6iMvJXp838LIu4rDp0uHe+EyeBV31XKB2ihw/3c78bna3oPB1TUmBg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:52 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 06/18] plugins: define qemu_plugin_u64 Date: Tue, 13 Feb 2024 13:39:56 +0400 Message-ID: <20240213094009.150349-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lj1-x22c.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 Additionally to the scoreboard, we define a qemu_plugin_u64, which is a simple struct holding a pointer to a scoreboard, and a given offset. This allows to have a scoreboard containing structs, without having to bring offset to operate on a specific field. Since most of the plugins are simply collecting a sum of per-cpu values, qemu_plugin_u64 directly support this operation as well. All inline operations defined later will use a qemu_plugin_u64 as input. New functions: - qemu_plugin_u64_add - qemu_plugin_u64_get - qemu_plugin_u64_set - qemu_plugin_u64_sum New macros: - qemu_plugin_scoreboard_u64 - qemu_plugin_scoreboard_u64_in_struct Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/qemu-plugin.h | 52 ++++++++++++++++++++++++++++++++++++ plugins/api.c | 33 +++++++++++++++++++++++ plugins/qemu-plugins.symbols | 4 +++ 3 files changed, 89 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 0994935d4a2..a48586ef0c1 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -225,6 +225,17 @@ struct qemu_plugin_insn; /** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ struct qemu_plugin_scoreboard; +/** + * typedef qemu_plugin_u64 - uint64_t member of an entry in a scoreboard + * + * This field allows to access a specific uint64_t member in one given entry, + * located at a specified offset. Inline operations expect this as entry. + */ +typedef struct { + struct qemu_plugin_scoreboard *score; + size_t offset; +} qemu_plugin_u64; + /** * enum qemu_plugin_cb_flags - type of callback * @@ -785,4 +796,45 @@ QEMU_PLUGIN_API void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, unsigned int vcpu_index); +/* Macros to define a qemu_plugin_u64 */ +#define qemu_plugin_scoreboard_u64(score) \ + (qemu_plugin_u64) {score, 0} +#define qemu_plugin_scoreboard_u64_in_struct(score, type, member) \ + (qemu_plugin_u64) {score, offsetof(type, member)} + +/** + * qemu_plugin_u64_add() - add a value to a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + * @added: value to add + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added); + +/** + * qemu_plugin_u64_get() - get value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, unsigned int vcpu_index); + +/** + * qemu_plugin_u64_set() - set value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + * @val: new value + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val); + +/** + * qemu_plugin_u64_sum() - return sum of all vcpu entries in a scoreboard + * @entry: entry to sum + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 76fbca685f4..15edad6769b 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -541,3 +541,36 @@ void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, return base_ptr + vcpu_index * g_array_get_element_size(score->data); } +static uint64_t *plugin_u64_address(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + char *ptr = qemu_plugin_scoreboard_find(entry.score, vcpu_index); + return (uint64_t *)(ptr + entry.offset); +} + +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added) +{ + *plugin_u64_address(entry, vcpu_index) += added; +} + +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + return *plugin_u64_address(entry, vcpu_index); +} + +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val) +{ + *plugin_u64_address(entry, vcpu_index) = val; +} + +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) +{ + uint64_t total = 0; + for (int i = 0; i < qemu_plugin_num_vcpus(); ++i) { + total += qemu_plugin_u64_get(entry, i); + } + return total; +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 3f93e7d6b13..6204453d0fd 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -44,6 +44,10 @@ qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; + qemu_plugin_u64_add; + qemu_plugin_u64_get; + qemu_plugin_u64_set; + qemu_plugin_u64_sum; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; }; From patchwork Tue Feb 13 09:39:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772282 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169311wre; Tue, 13 Feb 2024 01:42:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXbddf7TuU2Apy5ukxj5RQ9NLsBCa1Lsfe3JaEhqHcVQ+/re8LwLtq+VeypkNFIudErqYBnARi/KSElHpePUfmA X-Google-Smtp-Source: AGHT+IHMyn0woFI8JI8/0oO3AIYMF0ZIGESfkGo6v/5Oqe/14W06+9hjl/WaerFFENJQPD/qmcse X-Received: by 2002:a05:622a:1746:b0:42d:ae41:a6ea with SMTP id l6-20020a05622a174600b0042dae41a6eamr1069523qtk.21.1707817343529; Tue, 13 Feb 2024 01:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817343; cv=none; d=google.com; s=arc-20160816; b=cRB2WPvPyYIjRS7acgkq0U2bmmpKNr+Jf/e7sqgPbGBmvTHQOGuY3afjpKu5x7R5w7 2gQlTwzCZ0T8asnqSstRzzNkKS96bCPiqmzbciMgCfaCRMfojn+E4k7j/XZznELuCqnN U/18Ii+PFfcqaerV2cZVRAVTIh9Q/EMomUk9XCf4apIQcRmY8swHI3ClsCg1/Ii30llR DkBYfBLF9E54WDOZmJUmKZdQE35Mos4yIXu1ezFqOskfbP5GopUj6iHf5XfXw1NGg5Uu yqgNP/KI/uqX3uPl85aQ1n7cvZDAgc6R9qMS5cAHAUADCZ2e4UaBuKd8+xjpxgUuXhhx o0QQ== 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=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; fh=VXretJ31gGIuRCSYunnii0McEHi0o4ce8a+IJeMTbJs=; b=Rt05IP1+HpZl1mfypen9oimBjIPNK/7BDnBwjLWoOppyQ6luN402MXFx77zp9U4yhY A/UPFfopU1g7WfP6ENWLSX+b8859ACGLi2mu+ZtQhre49FIDViy3WxzKBVO6P1WVbyxl 5/v8Kayver9bcmZn8B9DVE5GF3OaxRDx2F7GqqZ8Kb7Ca943o1kbHtg/VnjrDIuqf+NW c7pcTH7Kwioh0K6y6lmsCU8jEsHD90fNqLZBhVnYh4akfKgfg0u9TtjTGBDGvScSLZD4 IsIi+/9LTV2kEEMZhyZloPgDdlakd9bdP+BmbuioVNZV7m4SrY2ojl4FXnL0Z8Mxhdvy RaBw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hQ2iram/"; 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=1; AJvYcCWFBheBX08MqYopzHiJ3L6rltyy3aTIA4bKajHl53mHh22PrrhycPea2JhTtVcn3rGDFTm5oGumP6eEQGxBemZe Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l20-20020a05622a175400b0042beca41f7asi2584660qtk.397.2024.02.13.01.42.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42:23 -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="hQ2iram/"; 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 1rZpHi-0001I1-FD; Tue, 13 Feb 2024 04:41:02 -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 1rZpHf-0001FB-OR for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:00 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHd-0000F7-FL for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:40:59 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-410ee8ed659so10993075e9.2 for ; Tue, 13 Feb 2024 01:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817256; x=1708422056; 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=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; b=hQ2iram/kVpcCC6PEctwmLiIYa/kmYqINX5rWvQcJc0buyslbqUjXHtJ52ErO/6dae ERFScidoBrp3JGA7dkFZ+5JFlEnoDMiQHk0VU5X9E8/8QAaYdrMjqhTWR247krx2wNSz al4iI/KROY11uMJjt89U/ASZ//FexmxDoSW3agVdI5pS+YwZiFHk0q9+sx4icOLfMbtT 6z8B05Gv8iCxf8mLzPdpv1HmuOGJ9nB2KaGQmlY++hHTYP/2xn4OxndaYpCLGFDuEIwr HBVlfvsJD0t7y6Yk2C/C+0mt1ATLRL/wdH2X3OLLsNwDpyBCjChCkvKw8o/I/LJhRQ5O NHAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817256; x=1708422056; 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=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; b=k//naS9OBD4HMRIxQLPMCxwx3bnEE1A9ax+vW+NzJ0NJFWT5N4YMqJcwMPWFn9i9Oy XEp/15O9iRvBoBQR6yfpzLtHpd9oOw0+CfEqoiH4WsoWiE3tZG/g2pn3ouJq/Mn0Ofr0 BHXX96eddREpED+MuB/s2xJg07E+3GIurLNkW28OrSBxC8QGU53gP6cyIUIZ7xwCjXo/ CdBUQcAnkM/KnSbx+fJQo7FPMXV8IEzIfWPv4SjdDDo2m3gQGr4LoVvxSkjz7ficSYZv Oh5f0r5OOyjZSaF9EFlh402HbzZQ59r+fO6ni9fnEjCgD7zRSBFbASDBXJhcCZwC01u5 f7zA== X-Gm-Message-State: AOJu0YxCa6kWWOUlbIzxfUo8h7uQM6uOS7DaPzVWWDo5M2boUn7Bt0+O VVnV+jBKuQzrA3pJX+xq4xeZRloQ60R/Kiy3vwzYee3RxFrdo6tHSfmmUJzopp3pb7g4mOTeBTI U X-Received: by 2002:adf:f712:0:b0:33b:4656:5e5 with SMTP id r18-20020adff712000000b0033b465605e5mr7037261wrp.27.1707817255860; Tue, 13 Feb 2024 01:40:55 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUoRrmmGEOa0u44g/bsi1O7imA2tnVu1EFhpwHeM/d4KIGMYq10RvQECJxrFveFIQa7be1JOc1ba1bIYSKdnwXLAsz7S/3gfLuzVjf6AgA5cJzX3Xu+x0L97+KxwRk8lNGmOKMOFBkxZrPA9fM2gX7Of1tXnYqUJ2p0yGtIk7UB98WaZzosbqfj4cuWQOyiiZLprYvLX9WpgmaUEwpJZiROPPfUUibYgddOb/lE/BPyHZitmhj53LI49jrV6DzSkti4XLyhpAemkhqUuvp0tCBj4r38a+Ti8k0SSYeXMo+jt4hxapHKLjXwTj+xQIhMDZEot2+5iw5D1W7NbbVbRp/eF5o74g== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:55 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 07/18] docs/devel: plugins can trigger a tb flush Date: Tue, 13 Feb 2024 13:39:57 +0400 Message-ID: <20240213094009.150349-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x332.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 When scoreboards need to be reallocated. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- docs/devel/multi-thread-tcg.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/devel/multi-thread-tcg.rst b/docs/devel/multi-thread-tcg.rst index 7302c3bf534..1420789fff3 100644 --- a/docs/devel/multi-thread-tcg.rst +++ b/docs/devel/multi-thread-tcg.rst @@ -109,6 +109,7 @@ including: - debugging operations (breakpoint insertion/removal) - some CPU helper functions - linux-user spawning its first thread + - operations related to TCG Plugins This is done with the async_safe_run_on_cpu() mechanism to ensure all vCPUs are quiescent when changes are being made to shared global From patchwork Tue Feb 13 09:39:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772286 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169472wre; Tue, 13 Feb 2024 01:42:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWv+NGpC0fLcGNnNtB6p7kA13EAUl/+XeN4ws8Wn7npJ8UxHhR1R0xTcBIfn7MKQ55IjMwqMAos3IwsqwBarCTO X-Google-Smtp-Source: AGHT+IEslBZsidDUDzWY4yg8vyQIA7qGXP1tDCcvwFYAvVWAoeGMIZlRpGaF7OxqOInFaHt+cyxo X-Received: by 2002:a25:ec0d:0:b0:dcc:21ac:355f with SMTP id j13-20020a25ec0d000000b00dcc21ac355fmr2057530ybh.8.1707817378342; Tue, 13 Feb 2024 01:42:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817378; cv=none; d=google.com; s=arc-20160816; b=XezAd/uY38AzYvUpamFjYiitDgkT/FvfeQLJdr9zHOz7HPV4uWq5OFcXIS4mYyKYWy 8qmtTp8b1FXiFj72GmHoBgpljNHvP2Kda6egnisP1OozUf0laC9iZxmyGUVmTnNxSC0n ENc8o6QMpfqRFmdQJNw7WsN4O0xxv71lYQfMUtWhFIJv9FOR4hozrUEyWfKvOlLCHHp/ OxN0ZyMqT34iWhi736WlE1TgbGsAg4+EZStNeet1OWUmL325hoczOfFvVCq2Y6bTih5Q R+oJZG7/mjtjhKSUngXSbZZnIi+/LAG0fSX0DZ2ybvkHQnG3t9G893Vfi5dGT3KBpTC8 3Abg== 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=hcoN95NgjKvlQ9/9phTtzGHXlAEFGIlm3GnYnG6dWRc=; fh=fySx/Dyg7/kCyXK1NdYE72AL1vsDAgRi2eAsITkyNOU=; b=dk9rBzDVsarkDHpXiCcJVkD5yAdvvNPJrH4v4H2qVIXHSON6aQK2xmzQeGBQRP348s nfV+mxCY2yXsIKmkkNWdmUZOxGxIcDuid3YUElzno5OB/jrMvbOtFoNUCh3RepS3ANC9 5sALfK4G7MQcaha7H0PwYSCnqieMMfaymZ28ug5eo3vcgm/iFi9ROVfkhyj7pNuf+BBL T3qlei3SkbnDRc9Xr0S4F6b5J6ikyNQA48thIW2jGY+mvfTKYm7k7iBObGGagrPXDSkW qW3FeqIzW5RGF8SOBFNJ44OCcvDZ4eB8vCuAb4ZW7tDNyWXlUCwm9hl7Ff0ex7K0wV81 zv4g==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=py1Ih5Cu; 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=1; AJvYcCUGTt3aOxnWTKl+o5q0uCd315QYwyd1x8bJ64LIUKixIwYu4rclfwadw7vyfXQ4L1CSuPh62KSze9HvTv7QUFTD Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dt18-20020a05620a479200b00785d8458451si3711075qkb.630.2024.02.13.01.42.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42:58 -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=py1Ih5Cu; 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 1rZpHj-0001KM-So; Tue, 13 Feb 2024 04:41:03 -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 1rZpHj-0001JB-2N for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:03 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHh-0000FT-0E for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:02 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33cd57b86bfso326838f8f.1 for ; Tue, 13 Feb 2024 01:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817259; x=1708422059; 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=hcoN95NgjKvlQ9/9phTtzGHXlAEFGIlm3GnYnG6dWRc=; b=py1Ih5CuSprOCGf2O5+wOKHv3aU4Z/BfoBGGDfP9cLnYJVStoZYz0xZnjRyEETW138 41l9BFS1x8Ber320jJgNTBkAGDdk7yaHuXOUZmcy31Yf6xzcfC8joBXg/o3VIU6xoddt a/vXUrG49ui18ssEBkxxrja4auZ+aUb7S2HnvpS1DR7ck+BCrHVIMVU7hoNaraM8icJy do5eSzNcViW8UW4/HDuwQcLZPKAL9WuM4QrvuY9ZlaEbhonzhPEO23UZ1MUCTqDkqiC5 D+gyuJDVEM5onf2R0U+8KztdBrisGqKiUeXxLMqiD7gABfqBN3e5QO5gvCLMQqH/eQcq mMRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817259; x=1708422059; 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=hcoN95NgjKvlQ9/9phTtzGHXlAEFGIlm3GnYnG6dWRc=; b=RNRpFM9yNAT+Qkpr6WCYK/iVK6c5ZSXnzJSxRMGPCo/jeYdu6Yc2hnYTY5AToAQfzw HzSTuBdc5bkrrnT3L6ccSP7Q9GURyefiT/WjqtH/kp26OteP6xpvoJUkme7yxINQDGN/ XpjXAS1hUse3Dqg+HalGXJKkBUbi69IK/NQcFeWaxletuzRV7FEOqpEPlo/ks2PotIg+ GBlwplwExVfvQLFf2y3IUxzM1yVX2vvNWAnmzaDv4RmQaiPMsCsU5fZw8rn0Fgjiavd+ NtuQntOsUHFU5VsYOsLPTn+oNmhbSpfLGQnQQUL2JpRT3qtTfoe2DSi7Z1wCSbffke5t UJ/g== X-Gm-Message-State: AOJu0Yy0O9GDoVv6B11UUnNFEeV6S7GYbwZlfB+wmLBt0ErQR1rsTSs5 A1MO8HuJpIZUBW15rxD1pzBhlBIw3tc4O1ByoAOVPQxb0IFtwaCZ5XIDECpStyIbMLePtq0Djg3 Z X-Received: by 2002:a5d:4384:0:b0:33b:65a7:6b87 with SMTP id i4-20020a5d4384000000b0033b65a76b87mr6422656wrq.49.1707817259312; Tue, 13 Feb 2024 01:40:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVGg47e7vB/EmBY0Eskvjl545d1z/BEKtEMg72hfOWeZWkl/PS/sRJxk1Bq0Bhom7W2kX1E0he2QEbLppTKSqbYYuDWwc06R9x7qb9GJ8/SE7S5E82jmCuq74fdr0dKegTD5Wy2d7/988+QKL/Bd3RiDtcc2paou7Bv4ZdsmS5ECkZ0IVREy6KhOU3SgBt25b+Ln2yH6t8d/o2ptGJS/hxZEOuZYmBSrigEJvrKJRSrekmBWXLY0EBNrBmUf5SM0E32smnQpyVLZrIeHu9g6ylt+F8ipEZ6oMCxOQNsFzjdc3WFeMq4tWuZuW2HOKZp6MYu5M+OdC9me2uVG021Ne2cu4vZgg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:40:59 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 08/18] plugins: implement inline operation relative to cpu_index Date: Tue, 13 Feb 2024 13:39:58 +0400 Message-ID: <20240213094009.150349-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x433.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 Instead of working on a fixed memory location, allow to address it based on cpu_index, an element size and a given offset. Result address: ptr + offset + cpu_index * element_size. With this, we can target a member in a struct array from a base pointer. Current semantic is not modified, thus inline operation still targets always the same memory location. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- plugins/plugin.h | 2 +- accel/tcg/plugin-gen.c | 69 ++++++++++++++++++++++++++++++++++-------- plugins/api.c | 3 +- plugins/core.c | 12 +++++--- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/plugins/plugin.h b/plugins/plugin.h index 043c740067d..3bf1aaf5c2d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -99,7 +99,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); int plugin_num_vcpus(void); diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b37ce7683e6..c15627c5e47 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -132,16 +132,28 @@ static void gen_empty_udata_cb_no_rwg(void) */ static void gen_empty_inline_cb(void) { + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr(); TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + /* second operand will be replaced by immediate value */ + tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index); + tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); + tcg_gen_movi_ptr(ptr, 0); + tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); tcg_gen_ld_i64(val, ptr, 0); - /* pass an immediate != 0 so that it doesn't get optimized away */ - tcg_gen_addi_i64(val, val, 0xdeadface); + /* second operand will be replaced by immediate value */ + tcg_gen_add_i64(val, val, val); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_ptr(ptr); tcg_temp_free_i64(val); + tcg_temp_free_ptr(cpu_index_as_ptr); + tcg_temp_free_i32(cpu_index); } static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -289,12 +301,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) return op; } +static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) +{ + return copy_op(begin_op, op, INDEX_op_ld_i32); +} + +static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_ext_i32_i64); + } + return op; +} + +static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) { if (TCG_TARGET_REG_BITS == 32) { /* 2x ld_i32 */ - op = copy_op(begin_op, op, INDEX_op_ld_i32); - op = copy_op(begin_op, op, INDEX_op_ld_i32); + op = copy_ld_i32(begin_op, op); + op = copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op = copy_op(begin_op, op, INDEX_op_ld_i64); @@ -330,6 +367,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) return op; } +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op = copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] = tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX == UINT32_MAX) { @@ -395,18 +439,17 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + char *ptr = cb->userp; + size_t elem_size = 0; + size_t offset = 0; + op = copy_ld_i32(&begin_op, op); + op = copy_mul_i32(&begin_op, op, elem_size); + op = copy_ext_i32_ptr(&begin_op, op); + op = copy_const_ptr(&begin_op, op, ptr + offset); + op = copy_add_ptr(&begin_op, op); op = copy_ld_i64(&begin_op, op); - - /* add_i64 */ op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op = copy_st_i64(&begin_op, op); - return op; } diff --git a/plugins/api.c b/plugins/api.c index 15edad6769b..dedcbdfd30d 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -106,7 +106,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, void *ptr, uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, imm); + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, ptr, imm); } } diff --git a/plugins/core.c b/plugins/core.c index cd0c717e291..5984bc2568c 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -312,7 +312,8 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; @@ -468,9 +469,12 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } -void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - uint64_t *val = cb->userp; + char *ptr = cb->userp; + size_t elem_size = 0; + size_t offset = 0; + uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size); switch (cb->inline_insn.op) { case QEMU_PLUGIN_INLINE_ADD_U64: @@ -503,7 +507,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE: - exec_inline_op(cb); + exec_inline_op(cb, cpu->cpu_index); break; default: g_assert_not_reached(); From patchwork Tue Feb 13 09:39:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772293 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp170127wre; Tue, 13 Feb 2024 01:45:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnojYI6o+5UBRelYApT8TreCe4nCN3Km7OUaALexORkeyKprJGHQetdzGZivZA2J50GG1t X-Received: by 2002:a05:620a:895:b0:783:38e3:a0f1 with SMTP id b21-20020a05620a089500b0078338e3a0f1mr8721883qka.4.1707817508225; Tue, 13 Feb 2024 01:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817508; cv=none; d=google.com; s=arc-20160816; b=kQynzCqVsbQpf9nw2GC82s1ya9/eyLYuoVQgGKrFwtJAghUFcl8R8oY2z+uKk8t9sF +zPf1vlVIoG6dQhZ6f8uSxa4GjbsVBayqv33oPlq6nUfpym5EhjppBMH9D3tJjiPeFPY Fq0HU/g1i1WCzfxQFaVTFfW2k7s/Vn5kA6V6v7kQe5oBKh5Ac2dujD+7xj4VY2bPVmCd 7EXEJ6Mq97w1qDT2Zt2qhR6JFRSGfaIa5dnH6c9Q4zdqOvux0uzYPwjd29gDxwI+7mrR qrBQ1PIoWwlkrm/cPDm5mNqzaEoZZHaHm9M4c0pHH7XcSwTP1Wm0oRbxlpTIJnHFsXez SW1w== 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=PHzR1Tdp7wuD7lKMTx4Q92ukiOIQPur1oGG8syEeMto=; fh=58M1wxDJBAydsXaoRw0BbwtQKdMY5g0IilIRrgX0Tfg=; b=vlouK0qDWqV+FLeevwXXAoRu4jzbiSniIISBNzxlEhksJ5okf2TlvbaL0Mz6l+ynZl npUMKVhOyPxAzXQGA3ZS9wmvf4/4y65GuZ7jwi0YepoPYGB7kjAEboT5qaDMsEVBgYLF av5RwEZCL1/G0BwoCTWHBEn1fOJD0gu1NqNqkUrM9kEmucWQlRWLIQDp9tMYA6X4DyUx u8di2NHPocE2B3X+cXoYvT83j6C+9Y5QFP59o6Lm7tyblV/y9dgvqIL45mwFFMrRp8BX wWzOEOow1GXz2x/MppEaHQ+El4sLqUP7LS9TnYsZU4q/yjiLU/5DFvTZNRzyc1xtsvhc gSxA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w4vvAvaR; 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=1; AJvYcCWMOT8hbPmhf/EjiNj9rCyZK3TrxyitJmAItCkmOs9ZZV1BpPferWbzsgaQJ5AeqFoNH6QxbFJ0cZh5H5N6bJAg Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b23-20020a05620a127700b007834b7bf527si8011578qkl.351.2024.02.13.01.45.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:45:08 -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=w4vvAvaR; 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 1rZpHp-0001N6-7i; Tue, 13 Feb 2024 04:41:09 -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 1rZpHm-0001MF-VM for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:06 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHk-0000Fr-T8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:06 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-41166710058so10055485e9.3 for ; Tue, 13 Feb 2024 01:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817263; x=1708422063; 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=PHzR1Tdp7wuD7lKMTx4Q92ukiOIQPur1oGG8syEeMto=; b=w4vvAvaRiNHC3wSN/MAaubk4Yhr+JIUg6RGaZCPg1AYRetSD40lD5zoYjeA29KL8VE 1qB6qqz/L3llCGUYz+1UWmWYTdbJFhcIpu0NYW3FPp58DFsYz2XSsU3wNk2Gm2KUbRCS g2nmhDvt3PMmQ6zGxHZhBte1ORnCgcP1iISIrSGqMemBqrqFt+FSqe1y6zYZK5Ie7qJc plMl9u2T9BtOaqdgH/lfrWj12aRm3UWdw/I1A7qluhdpoKlO4Zjru81U50Wene7u4BDj o2abtVbKpgafvj8WbRSX2J9fkS4vwUExEQ3Ifq18IEJ4HfdqTezF+c6c0Ms7gE+1Gdlt +h5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817263; x=1708422063; 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=PHzR1Tdp7wuD7lKMTx4Q92ukiOIQPur1oGG8syEeMto=; b=MRI8gdiIlrQQjJlajkDgaNqLriPL/RDvPTEb3KlgMrwiWC2OpZ2EUAvLfwwWVnrkWP 7bwdzLwp3rjudx1nqPQ0xOfJNsJODWTPhqmxXE2U9ucdy2O1GyqB10yb1Fd/+8mFazuD UEcw92LiZIL4XMabOnft9ZwMNo45WdzYsoPmZ6Q5SALVlYeqZaGKpFBqPlOB4uD2d19r JtzEjqQW9KQoYdLsrLnC0qq5VtRrow/0lgLyV2ZxkN5SjROCl8HGGJzA6i1gOYwCy4PO SNv2kkNDo4SRvvJkledPmCOUYXoXoA/J07O54Ms1uP3zS1FZoOSWWEys7ZJnAae8JSo9 AxkQ== X-Gm-Message-State: AOJu0YzYkPAWMD3Leyp0J+SYH27kkCOV0BR5jkQgz82NuIXDvcfhCqcf xxDqFZWVVqIYR8qmxo+RWl+Ti/XcmxV6u3rNJ20kLhZW2cg2ppeAs5VeUeUaEm+bANqCPjh5Pf8 i X-Received: by 2002:a5d:6302:0:b0:33b:2153:b0f3 with SMTP id i2-20020a5d6302000000b0033b2153b0f3mr6693960wru.29.1707817262796; Tue, 13 Feb 2024 01:41:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXbgoO0qt0yqlfRkAiIYZIvxvt6WejoSmu/wW5m9r9GMHfaq+L1+di0iCNe/Gn6BsH49BVSaIPE5oCoPdK8BdUdmMyBsFn6/kKQK66Rwv+yfmP7MVmWGl01by7W7p0VrJtfGdSFrtfqNwceBtgQU7ftJkUorlBTwFJ4b1Zhjief6pLYaJL3lQveqNkPPHA4OfOEStLKeFlAEIzXoNXRxCEWxvWXd7niW+9xw/CMJyY1Ymdad63mQhylCfnR43f8du/PozFQO50YkY4OgsxjKski625DFhhQKoIamOrE4EWXo26dwuMw1Kr7WgtzWkYodAaXXpMymzEvUJElXKB+0rEWnxCXZw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:02 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 09/18] plugins: add inline operation per vcpu Date: Tue, 13 Feb 2024 13:39:59 +0400 Message-ID: <20240213094009.150349-10-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x331.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 Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Those functions takes a qemu_plugin_u64_t as input. This allows to have a thread-safe and type-safe version of inline operations. Reviewed-by: Alex Bennée Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/plugin.h | 1 + include/qemu/qemu-plugin.h | 51 +++++++++++++++++++++++++++++++++++- plugins/plugin.h | 6 +++++ accel/tcg/plugin-gen.c | 7 +++++ plugins/api.c | 37 +++++++++++++++++++++++++- plugins/core.c | 23 ++++++++++++++++ plugins/qemu-plugins.symbols | 3 +++ 7 files changed, 126 insertions(+), 2 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index ccf9d2ebd2d..e42353d9bb9 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { /* fields specific to each dyn_cb type go here */ union { struct { + qemu_plugin_u64 entry; enum qemu_plugin_op op; uint64_t imm; } inline_insn; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index a48586ef0c1..cdf1266d724 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -328,6 +328,22 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); +/** + * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op on a given scoreboard entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -358,6 +374,22 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time an instruction executes. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_tb_n_insns() - query helper for number of insns in TB * @tb: opaque handle to TB passed to callback @@ -583,7 +615,24 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @entry: entry to run op + * @imm: immediate data for @op + * + * This registers a inline op every memory access generated by the + * instruction. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, diff --git a/plugins/plugin.h b/plugins/plugin.h index 3bf1aaf5c2d..f6fa10a0f56 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -73,6 +73,12 @@ void plugin_register_inline_op(GArray **arr, enum qemu_plugin_op op, void *ptr, uint64_t imm); +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + void plugin_reset_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb, bool reset); diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c15627c5e47..25915a93242 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -442,6 +442,13 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, char *ptr = cb->userp; size_t elem_size = 0; size_t offset = 0; + if (!ptr) { + /* use inline entry */ + ptr = cb->inline_insn.entry.score->data->data; + elem_size = g_array_get_element_size(cb->inline_insn.entry.score->data); + offset = cb->inline_insn.entry.offset; + } + op = copy_ld_i32(&begin_op, op); op = copy_mul_i32(&begin_op, op, elem_size); op = copy_ext_i32_ptr(&begin_op, op); diff --git a/plugins/api.c b/plugins/api.c index dedcbdfd30d..be2badda9fa 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -111,6 +111,18 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, } } +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!tb->mem_only) { + plugin_register_inline_op_on_entry( + &tb->cbs[PLUGIN_CB_INLINE], 0, op, entry, imm); + } +} + void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -136,6 +148,18 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, } } +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!insn->mem_only) { + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, entry, imm); + } +} + /* * We always plant memory instrumentation because they don't finalise until @@ -148,7 +172,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], - cb, flags, rw, udata); + cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, @@ -160,6 +184,17 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, rw, op, ptr, imm); } +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, entry, imm); +} + void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t cb) { diff --git a/plugins/core.c b/plugins/core.c index 5984bc2568c..10ffdf6d938 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -326,6 +326,23 @@ void plugin_register_inline_op(GArray **arr, dyn_cb->inline_insn.imm = imm; } +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb = plugin_get_dyn_cb(arr); + dyn_cb->userp = NULL; + dyn_cb->type = PLUGIN_CB_INLINE; + dyn_cb->rw = rw; + dyn_cb->inline_insn.entry = entry; + dyn_cb->inline_insn.op = op; + dyn_cb->inline_insn.imm = imm; +} + void plugin_register_dyn_cb__udata(GArray **arr, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -474,6 +491,12 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) char *ptr = cb->userp; size_t elem_size = 0; size_t offset = 0; + if (!ptr) { + /* use inline entry */ + ptr = cb->inline_insn.entry.score->data->data; + elem_size = g_array_get_element_size(cb->inline_insn.entry.score->data); + offset = cb->inline_insn.entry.offset; + } uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size); switch (cb->inline_insn.op) { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6204453d0fd..0d8141b85f1 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -28,13 +28,16 @@ qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; qemu_plugin_scoreboard_free; From patchwork Tue Feb 13 09:40:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772291 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169974wre; Tue, 13 Feb 2024 01:44:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX21RVic8ys3l+OzG9CHLm+79nBiiI4gdfh/cw1MVyNVieWxHj9csji7tOCXDEi+6HuntDOpiszMfoCRRssCqb2 X-Google-Smtp-Source: AGHT+IF+Zdu5pRq9WF/dtMV0+PYF1S0ILd8N5gP4vD4V5oToOPw6wjFfIzLYjGAtCJ24tEd/rVrP X-Received: by 2002:a25:bfcd:0:b0:dc2:2799:981a with SMTP id q13-20020a25bfcd000000b00dc22799981amr7139141ybm.18.1707817480356; Tue, 13 Feb 2024 01:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817480; cv=none; d=google.com; s=arc-20160816; b=NuOJAZ+pmMjbJHbfXuT73N0zI0w2/+VqHjcBzB9b5rxAs+P/hH5Smmi9Rx68qAkhgW Msp5A0pbQiRFs6MD9Y6RL/0ej0T5POEXGUa/5q4VwVeuclUL+szreo/Mof7nWutHBCQM vZmWg819y9B/gjopp5dbpKuFhGL0xH175oaJgjWYoSvPUVNX4JE4V10fOhix0or/yA5f JPqikrRR5eJjtmEBW0NK224/36btIhuDeSMAioKmiqqmaSnRqdt5Z2TC1GUQJC61c0Qg AJLyk3z4H8zHEHTS6cUevZsupueMBkajxiI0vbCaBnWMbaR43akL6jLfSsp8pgbt/5Ij 71OQ== 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=4WWaJPsclEFPyc9s7y8yPMs7GjvBirSud+8vEqilY/w=; fh=8slKNndT3QRwuO4pnusQSluFRcrBA6L+6hWVExhYx/E=; b=MjXhZ0gVc2My1SHhk78D+x/xqM4rjff/BInI5o36KFNlcJqQcBzALZ96eAXEk7qSNO evKOo8bYakWBodcLexTWM2E+hvTTClAfxqt/bb1Ox387p4ZvFM5vsvUwmJt5cCtq4Hai owxCRyVZY2Ak5alqbC30Ec1qrESH2Sha6bcM10MtQGw7eHKNPHMX2JO3Cdh+H0ZTG38d TbvbLsuzVO/XKJZIFYfHnptOGwnIOHf38mK7AkEjLJASS+jx7Ks0bUKIAIfxz2y/kL+g aa1GK0H78Ijcgs/SdrS0m+432pvgpZbR0J1uK0Pks07adQFniXReBom4POtuQ2cY0jgM UPsQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KOogdEeU; 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=1; AJvYcCURYgJ6nzLivX1CYrjNPu4/Qjh+kemoQG4QHpzwih0FJYxW5IgFF/FJd7cViateStNy/Qr7UXyBzedx02vMqQIY Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l13-20020a05622a174d00b0042c7c75dd86si2681546qtk.756.2024.02.13.01.44.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:44:40 -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=KOogdEeU; 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 1rZpHr-0001Nk-Dw; Tue, 13 Feb 2024 04:41:12 -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 1rZpHp-0001NC-PB for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:09 -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 1rZpHn-0000G6-Pi for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:09 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33b728b6981so1527650f8f.2 for ; Tue, 13 Feb 2024 01:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817266; x=1708422066; 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=4WWaJPsclEFPyc9s7y8yPMs7GjvBirSud+8vEqilY/w=; b=KOogdEeUZOJIwP+bYB+vV47xy2h4msVqLG6TT84jJKBt9v3JSVD0dxHTVr+i+hZePU 1n/AzZ4m+QaK4FNpyKADnU7JzrMOUtEAAihg1dVL7K5aldyQHVLHffhRrciS5n4OQH85 GS2HIVTLs2kOycUpymZJwCC+5J1TMlOm89n0BwhEWj4SHFgBTYxXLm6c7RsR92hplcYA lDw2gqdUhXAUdfHnWpiS3qEOe83iEtKKzgm8NIv7N5kZZkHlT6c9egRny6+1YkmxuIvU qpBnCRMwoDRs/X7f4+CD3tecX564HiN6b99uDnaRZ/Uw2h9o9z57dzKJVjndXI5XGTza APbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817266; x=1708422066; 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=4WWaJPsclEFPyc9s7y8yPMs7GjvBirSud+8vEqilY/w=; b=X4Ob64SAjbsJRJD674N6NxIfeW7blMTJp6fPKIaIBrYLr+lerUVvuSO0Mayg+84Ia4 9EfzQoYneGpQ+gef4rL85PHxsZBG/CjxvHRwAatfEkn5TauMHqyktfc4cgNdsOjwTdAP Mv1s78I33eny1j1yi/GKp7lncYu28coQjufn//VUDd/GShLA66Baapu+4YVBzch2ziXQ 3y7v/+vB0MNtkmZXoI+ItLUmP6eIoE8gFAdzrkcvWTG4exkSQYYDBg57sdWFx2wCTTTD 6mksC+s8d8qc+lfx7Uts35EtG0bk7BOLsKElKQni4WhGoCmmI0EDK2KOpvXaXYq8A/SR QUVQ== X-Gm-Message-State: AOJu0Ywbu1l7Ov1A5nNhH63Wq9nfdlPwpqRwhT1Y8NcJFQbRzUADJYJW 9igTUrSHcwJ2HTVU/m9YFlmiPk5v3up67u9JD/iMsTpqzHUsTNSrkI5tQXhqdg4Ol/bUk/hMGwh D X-Received: by 2002:adf:fccc:0:b0:33a:e51e:ddaf with SMTP id f12-20020adffccc000000b0033ae51eddafmr7467153wrs.27.1707817266248; Tue, 13 Feb 2024 01:41:06 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW5F9RAHwFks1TNLUu2O1DvHEh+dKW816kvdwSg612CexAPgGV4FX5mgBFahrUQI1d/fezR4cMj1Fnd03WZdp+zAzKfvFQztW7VT16o8iWZKnoV8Ap497UeQ18TpVMhZ1cnxv1lN66LTooTS9ADbonCt+8rbYM3oDYueBEHdxtzHvlq9Czid8sVZmK7X4xB06boITF7qzIntHogBurTpuez9xID2Ylfpf9Oe281p+bcrpQ/UbOvIDF3JFCVuhUayEj0q6rpSjLzZT/d585lk0Z+5lKop1w/HvSVuDRil0CyP4WlqTvGiINKEWILP856NlEJaIf/Suk9upUuTZnHZcS6gRrZaA== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:06 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 10/18] tests/plugin: add test plugin for inline operations Date: Tue, 13 Feb 2024 13:40:00 +0400 Message-ID: <20240213094009.150349-11-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=pierrick.bouvier@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 For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added. Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one. Reviewed-by: Alex Bennée Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 186 +++++++++++++++++++++++++++++++++++++++ tests/plugin/meson.build | 2 +- 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/plugin/inline.c diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c new file mode 100644 index 00000000000..0163e9b51c5 --- /dev/null +++ b/tests/plugin/inline.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2023, Pierrick Bouvier + * + * Demonstrates and tests usage of inline ops. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include + +#include + +typedef struct { + uint64_t count_tb; + uint64_t count_tb_inline; + uint64_t count_insn; + uint64_t count_insn_inline; + uint64_t count_mem; + uint64_t count_mem_inline; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 count_tb; +static qemu_plugin_u64 count_tb_inline; +static qemu_plugin_u64 count_insn; +static qemu_plugin_u64 count_insn_inline; +static qemu_plugin_u64 count_mem; +static qemu_plugin_u64 count_mem_inline; + +static uint64_t global_count_tb; +static uint64_t global_count_insn; +static uint64_t global_count_mem; +static unsigned int max_cpu_index; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +static void stats_insn(void) +{ + const uint64_t expected = global_count_insn; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_insn); + const uint64_t inl_per_vcpu = + qemu_plugin_u64_sum(count_insn_inline); + printf("insn: %" PRIu64 "\n", expected); + printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); +} + +static void stats_tb(void) +{ + const uint64_t expected = global_count_tb; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_tb); + const uint64_t inl_per_vcpu = + qemu_plugin_u64_sum(count_tb_inline); + printf("tb: %" PRIu64 "\n", expected); + printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); +} + +static void stats_mem(void) +{ + const uint64_t expected = global_count_mem; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_mem); + const uint64_t inl_per_vcpu = + qemu_plugin_u64_sum(count_mem_inline); + printf("mem: %" PRIu64 "\n", expected); + printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + const unsigned int num_cpus = qemu_plugin_num_vcpus(); + g_assert(num_cpus == max_cpu_index + 1); + + for (int i = 0; i < num_cpus ; ++i) { + const uint64_t tb = qemu_plugin_u64_get(count_tb, i); + const uint64_t tb_inline = qemu_plugin_u64_get(count_tb_inline, i); + const uint64_t insn = qemu_plugin_u64_get(count_insn, i); + const uint64_t insn_inline = qemu_plugin_u64_get(count_insn_inline, i); + const uint64_t mem = qemu_plugin_u64_get(count_mem, i); + const uint64_t mem_inline = qemu_plugin_u64_get(count_mem_inline, i); + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " + "insn (%" PRIu64 ", %" PRIu64 ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + g_assert(tb == tb_inline); + g_assert(insn == insn_inline); + g_assert(mem == mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); + + qemu_plugin_scoreboard_free(counts); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_mutex_lock(&tb_lock); + max_cpu_index = MAX(max_cpu_index, cpu_index); + global_count_tb++; + g_mutex_unlock(&tb_lock); +} + +static void vcpu_insn_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_mutex_lock(&insn_lock); + global_count_insn++; + g_mutex_unlock(&insn_lock); +} + +static void vcpu_mem_access(unsigned int cpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, + void *userdata) +{ + qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_mutex_lock(&mem_lock); + global_count_mem++; + g_mutex_unlock(&mem_lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + qemu_plugin_register_vcpu_tb_exec_cb( + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); + + for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); + qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, + QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_MEM_RW, 0); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + count_mem_inline, 1); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + count_tb = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb); + count_insn = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn); + count_mem = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem); + count_tb_inline = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb_inline); + count_insn_inline = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn_inline); + count_mem_inline = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem_inline); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index e18183aaeda..9eece5bab51 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,6 +1,6 @@ t = [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os == 'windows' t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', include_directories: '../../include/qemu', From patchwork Tue Feb 13 09:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772283 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169403wre; Tue, 13 Feb 2024 01:42:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQrfvSXu+yuCbyX6lj8CB4Cb3qS/gyoXkfvMYW6o3UXFjtIwOQiWk04VnyXBM3SYdTbmgo X-Received: by 2002:a0c:e412:0:b0:68e:eccb:6ed4 with SMTP id o18-20020a0ce412000000b0068eeccb6ed4mr568764qvl.47.1707817363596; Tue, 13 Feb 2024 01:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817363; cv=none; d=google.com; s=arc-20160816; b=iFGpu/WnpZP0ngJ4NbIpBzICUylZJDFVfQAQtfon5ihuRp8Q55Pv8XhKOwfx+rL52P gtCvHvDM8cOqc/uLd++Nyrn77ZJnhS+mufJ/kqML8TaqQIMDmk40dOZQoPgyvBmg8psv xrp3/gNZdXChrhHtsvLNWc5xP8AjaEJ/nk2VPiqpP4MDtOUfUQACe/MYm0eDRMFOl2VM jnB3QyGwt7eAWhPqPk4lA9aJhTrwN9w8Q3TpmfJUBrvSnvuPveyhCJusHef7yNopiNUi gBJEOu8/JaCp567/uTdHFvLuvdmT/gLwgD5eC56fpGvBGHiaTaEFe4KV/ca648z6lHDA aU6w== 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=HgTl20rCSJYbUu3H7bqnk8bx/uKJfuAIG49cFMEfy7s=; fh=vnkRklZGtYz70hyPQbczVQLNHPIhpcBeXQ+Dh305Ers=; b=ApRxikGGsLNDlWLbqfZ7ysr8e9WZc7jsMjqTGpYoWHXcNn+wk3kB5PkYVUjlyjEDoe dZr1CZH4aUny/VX0iSQ093cs8AI4DC5lduS6umcZDLBuo4fDpZ12vXqi6CmBdkdKZxRS Kb9gKKbE6kPWS+3kE6y7BnFgksp+VngIXFeqhznZQeOl2x7Cveidq2TXvFCPsv2QHnzb U+HKMTccasfYAqIowY5IfAt1+fDQ+Tio177c8HugAEUv8NE7H6eljdYIpheTZJZBSF5G qWFaKx+Od4sQXDyCCW3UydHZPMwGCpun6gSLRuG3OuBqIxDPZV1nUiJoNdsMkG0PZU2t abIw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aC41rDzv; 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=1; AJvYcCUqRErkCy8dWXMxzvUa1KPAAuT6qqY87QTX7aZZUFPTs3yc7+RFCigIau/7GlH6mB1EQ6y0DyVIUjx3mTw2LneF Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i3-20020ad45c63000000b0068c4f264e8asi2500004qvh.175.2024.02.13.01.42.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42:43 -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=aC41rDzv; 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 1rZpHz-0001PX-7n; Tue, 13 Feb 2024 04:41:19 -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 1rZpHx-0001Ov-1u for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:17 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHr-0000Ga-8p for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:16 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33b29b5ea96so1953189f8f.0 for ; Tue, 13 Feb 2024 01:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817269; x=1708422069; 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=HgTl20rCSJYbUu3H7bqnk8bx/uKJfuAIG49cFMEfy7s=; b=aC41rDzvfaKdtNPFeel2IuZ6nQiAkzoGL+BmSEw7P3aJSQAlnUV1/hH7uKZJtiU7sZ sAdWxvdsjCoZQpQjCPNjv//7Ueyf8XFKQ3RsL8K6Rku08K+p0BvGUthxnLT3GdrSqOyP GHrPaVfHhnRmEdt2XSvi7yCPJ7uSy1Xt/9mUMNLYZnl9CC7VLw+AWiPjgStz3AKpKjjS sI4xTnoI0zZgyb8qQRizBkHjW6O5lk+MX6874w06PYiEacx6mbMwpToGM9a5loiWs+4F ch21IMyVVAs3SR9xhRf+TyFdBtu313RJrxad4lHTe2fWXXqM/oeg1Q0GMgcIxEN7TUdC 7TUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817269; x=1708422069; 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=HgTl20rCSJYbUu3H7bqnk8bx/uKJfuAIG49cFMEfy7s=; b=nG2DBTRuY1Q6XcV249Y3PgTsk9hr31dqZyKXc245ln97JRXYDESLofXUJVEu8+3+43 +lvZMVuhaqVu6yZlgxhzgZtCXqppt57TjbbVSUa5/pfmsw02UvVE3GVZVY4oUeHqnKiV uADWi1CQGEnHV39t1rYopGJ7Zwq8ukHk4uaoITAWwkRVuTOx5SyJKuu64gP07cbA5ceF HMoIyuqG12Yj+nNrd1UirL/GwsEfJbTuLI9S7NDM4opkaVyQIPjqNStl+100PcGqNop/ sB0yj4GkM5BhmWj/iQL9VTag//Quo+jeJqnwjRx2C6+buasLpb0NFm9QFRGWdOf2B6ms N33Q== X-Gm-Message-State: AOJu0YwPc2Lje73OAlrOe+8VvjYPyDzpPdvCTJGUlSVes100xpjY2i9d Pld6qYX2CFchz48zYZUm36PrbsoRgmjuZoOIhYOHHvE7sDnCFMnfBmdee5nXLZE480Bu2eXbAXx 4 X-Received: by 2002:a05:6000:a05:b0:33c:df0f:1b4e with SMTP id co5-20020a0560000a0500b0033cdf0f1b4emr680345wrb.20.1707817269770; Tue, 13 Feb 2024 01:41:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUjuRW6ars5OSynMcaYQtReqIdolCtjcKmklgqFA+nIOXlX74cPMI8hHHRtmwygaxXVrLFRINMleQfSujXduAFiZcBTbqRkiSS9ER/Tuoxyy74y3YxSX/6NLHcc+K8PAv9PUnVQydOwGZaSEh8xhtbFSlaGBD1Jass5SpD+D5lxypzNSTxc11RmYa0G21OPbmhz0aontcB2OvMH+wI3bTRnl7hfBLd3YR1WvSH4yqS/ncATQHHu6eEDn9TvIQwszWT/4nA5OUMtOHWMHvzKMkyyuHQoLLT3AIR4a9zE4YtvbT/+2qIZdS0D/mTZYjWDeOOL6C1Du8+H18VH96G41KmO0WqfjQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:09 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 11/18] tests/plugin/mem: migrate to new per_vcpu API Date: Tue, 13 Feb 2024 13:40:01 +0400 Message-ID: <20240213094009.150349-12-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x429.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 Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 44e91065ba7..d4729f5e015 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -16,9 +16,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -static uint64_t inline_mem_count; -static uint64_t cb_mem_count; -static uint64_t io_count; +typedef struct { + uint64_t mem_count; + uint64_t io_count; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 mem_count; +static qemu_plugin_u64 io_count; static bool do_inline, do_callback; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; @@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out = g_string_new(""); - if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_mem_count); - } - if (do_callback) { - g_string_append_printf(out, "callback mem accesses: %" PRIu64 "\n", cb_mem_count); + if (do_inline || do_callback) { + g_string_printf(out, "mem accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(mem_count)); } if (do_haddr) { - g_string_append_printf(out, "io accesses: %" PRIu64 "\n", io_count); + g_string_append_printf(out, "io accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(io_count)); } qemu_plugin_outs(out->str); + qemu_plugin_scoreboard_free(counts); } static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -46,12 +51,12 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, struct qemu_plugin_hwaddr *hwaddr; hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr); if (qemu_plugin_hwaddr_is_io(hwaddr)) { - io_count++; + qemu_plugin_u64_add(io_count, cpu_index, 1); } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } @@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U64, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + mem_count, 1); } if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, @@ -117,6 +123,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + mem_count = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, mem_count); + io_count = qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, io_count); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; From patchwork Tue Feb 13 09:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772287 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169509wre; Tue, 13 Feb 2024 01:43:05 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVoIFRzpn5OVnk8Re3p4P4HyvHCIb3AArEvIk7JDsZ+ta+T/tvwFajdE9An0vTGCDKKJovbIDtNxCJZYfs+i235 X-Google-Smtp-Source: AGHT+IF+wby2hM3SSCBe3jBPQTBXp19ZeUduXShiforR+ijfHkPX19YYG0PpbX3Q3bAl0zBhg6NM X-Received: by 2002:a0c:db05:0:b0:68d:18b8:a13b with SMTP id d5-20020a0cdb05000000b0068d18b8a13bmr2806961qvk.11.1707817385037; Tue, 13 Feb 2024 01:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817385; cv=none; d=google.com; s=arc-20160816; b=vN6844U/pZ6mgDD+7vBGCTkOfe7TkD47N0M8G5iSgVz1yKXlavbI6ul0Vfv9C+Xomm LQF9H5aIKV5lvM9zAEfeZL9/Bv9wri0KHbP7QWyFHQzHJgjNifrmWDMLXKvVBUjU9jp3 z91qOkw5j5mT9vW8oqDrxqQl+4evikpR7EI7xWnIMK7EUi56s5wCtwrrSGKeE0MDFb5b olararWSwgUTOI6YI/tnJKzDWUdZJ6O2V/jKJmdXPIxNv1hVbU/hDcpcsHcDK50ODqr9 N88tKCC9A8iOEG4/Kaa3cpgaVdsfzp0tnJJMyCgUrMjzCyPsKGZ7P5B62nPXZy5somes Cj/Q== 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=jIM1lNqnf5XAacffBXN4ljIlTpT3DH/ZoqvjHNJUJG4=; fh=bKGm/G5WL8czAb8NnxzMNzum3jOtE7pN3+veZPHMZu0=; b=e7ynUEGOqklFmLHiiYSfPf39MunAFPKjlolUa3LGXjhCYPLqZeEBSLyR4ic3pHh8/i J6qYlolWuu6J2oq+4Rzu2emLMsgLCzN6n36OZSElsoz5SHQDzFmQhVz8DlVl+cp7A9YI UpSyEZixJ7qMViHiHi/mxhDLHyVihApzIU6/iq8qlVZVMxAmXiHj7NVIJAzxDLm1ryTu trEtSb0fbZ4ANHLEyR+VybxeMTPcRe5+S8uw/92kCfllULicaGH4B4Nzuy9nvTreH1cJ h5ozb0LPKuCdQB+D009thoF6cwkWDQAnLxbGNUGkba7iaAoKPZCNAJHUq6LV7749WLGr +h8w==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TkKK4sqR; 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=1; AJvYcCVWUWPtA/lfIVCQJtuRTVx6A2vbIPIKw9bUaNtYGKFygTmlvquz68kEqW4FANgZ85Ypczs5YeHVc6pxWSPvbV09 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fn3-20020ad45d63000000b0068cd9f35a23si2371844qvb.542.2024.02.13.01.43.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:43:05 -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=TkKK4sqR; 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 1rZpI0-0001RM-TJ; Tue, 13 Feb 2024 04:41:21 -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 1rZpHx-0001PA-VK for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:17 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHw-0000Gi-1l for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:17 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-339289fead2so2658838f8f.3 for ; Tue, 13 Feb 2024 01:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817273; x=1708422073; 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=jIM1lNqnf5XAacffBXN4ljIlTpT3DH/ZoqvjHNJUJG4=; b=TkKK4sqRaIOH1fAS3Ai9NKvp/u46JIwA/JjOLGq29YL46vJBOWoh3jd1wlFl+uwfWF 2SjEnhm4mHZKguA/iA6U2SyruvBQQYPQrU+qaxjbh4RuaFFjfzsVk5W39dBYzsj/D6ee vzPZnze84hDIceW6sRjgL8z4UrkF/d/nU+Ol4DIKi8ZLYqU8CEUiW4JIu/tNoSzfxpqC RGnmb5EhNEnpu2v41qneusLOx9mqQkt2jvsGj81yGW/jcXSTkbA0ARkqK+GmhCLbVa04 6Hd6Ecrf0mRj/ojaiwW+jJx3jD5ypjZVktGHkiJkhboAzb+EZ3s3VXSR+EKKutdWodLB mOTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817273; x=1708422073; 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=jIM1lNqnf5XAacffBXN4ljIlTpT3DH/ZoqvjHNJUJG4=; b=voN7aEVSGQ+sDODPOLwtnzOx6yXm84jl+iMhlvdziBcKXvDStomI8X0Hzc19wC+HEZ 0DX5OvCEdcv0yo+/WSGMfJDtz0PlnF+/cZnBMAy1BwZDwpAj+dMbOfusYY6HyDjn7Q6I WuONrp6Rsbdr8XBkhmkbwW5jL+UMDj3mMSiIqEYXUOFNiZyqg9qM/K0KV0GJPJGTRf8X Ou/Pey4fI1ihLZS4xy1c5tFNX1Fh5bK1uXSYJVSdytOSk8RvHmnca77rvZ6LPbSflRq/ PxUho524g0HPL/kNePaOq+AdP5s3VVZGYu1isoCorTbG/7kZ/E5MFWBLVgOGx1ArD0aO KrGA== X-Gm-Message-State: AOJu0YwDTmgm83h954R7IZz8ka4ZzmTWe1byFvrKbLT5Xg2YEiRcLJyP /OExct3huIDombMVhc73GxGSGt7OLhqtLfAZu5m6AJVNyau+zkZSarn48lyspKPdYLVe21RobML a X-Received: by 2002:a5d:490d:0:b0:33b:4e38:b878 with SMTP id x13-20020a5d490d000000b0033b4e38b878mr6567177wrq.26.1707817273326; Tue, 13 Feb 2024 01:41:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXjpnVkbtq4yK7B9CkAVcwuCAxUXuqGyYMRMkN4dR+hlI8wlp3nKUZ9eEuR8nZCIkTDuqGOiC+SUPCmQBOjlBP4xpdyKayf41zujppD6p1bnXUSYXKwjopz/83tMDP1D8qS/OMrJiA7ylTX2vOjh6w/bJ/E9co44/2NtcZjgqcE/9aTf5rel6GLcPCNlUgWJ1EqBLUDg5dbXbtVdbYdxdxwieeZBu3zXeqMIf5rAiToz8zKjb2J7p4C+yRmdDQSFM75TIOaJ7j5D2fxISPKkOasrzjRRMiL0Rw03mHDcuaJQHolTDrJHgi+OO/JSlH/770PBGQn5xm2B6HFOfl9EO+hh8QR5g== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:12 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 12/18] tests/plugin/insn: migrate to new per_vcpu API Date: Tue, 13 Feb 2024 13:40:02 +0400 Message-ID: <20240213094009.150349-13-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x433.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 Signed-off-by: Pierrick Bouvier --- tests/plugin/insn.c | 106 +++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 56 deletions(-) diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 5fd3017c2b3..0d0a4cd1c34 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -16,25 +16,21 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -#define MAX_CPUS 8 /* lets not go nuts */ - -typedef struct { - uint64_t insn_count; -} InstructionCount; - -static InstructionCount counts[MAX_CPUS]; -static uint64_t inline_insn_count; +static qemu_plugin_u64 insn_count; static bool do_inline; static bool do_size; static GArray *sizes; +typedef struct { + uint64_t hits; + uint64_t last_hit; + uint64_t total_delta; +} MatchCount; + typedef struct { char *match_string; - uint64_t hits[MAX_CPUS]; - uint64_t last_hit[MAX_CPUS]; - uint64_t total_delta[MAX_CPUS]; - GPtrArray *history[MAX_CPUS]; + struct qemu_plugin_scoreboard *counts; /* MatchCount */ } Match; static GArray *matches; @@ -48,41 +44,40 @@ typedef struct { static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i = cpu_index % MAX_CPUS; - InstructionCount *c = &counts[i]; - - c->insn_count++; + qemu_plugin_u64_add(insn_count, cpu_index, 1); } static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i = cpu_index % MAX_CPUS; Instruction *insn = (Instruction *) udata; - Match *match = insn->match; + Match *insn_match = insn->match; + MatchCount *match = qemu_plugin_scoreboard_find(insn_match->counts, + cpu_index); + g_autoptr(GString) ts = g_string_new(""); insn->hits++; g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", insn->vaddr, insn->disas, insn->hits); - uint64_t icount = counts[i].insn_count; - uint64_t delta = icount - match->last_hit[i]; + uint64_t icount = qemu_plugin_u64_get(insn_count, cpu_index); + uint64_t delta = icount - match->last_hit; - match->hits[i]++; - match->total_delta[i] += delta; + match->hits++; + match->total_delta += delta; g_string_append_printf(ts, - ", %"PRId64" match hits, " - "Δ+%"PRId64 " since last match," + " , cpu %u," + " %"PRId64" match hits," + " Δ+%"PRId64 " since last match," " %"PRId64 " avg insns/match\n", - match->hits[i], delta, - match->total_delta[i] / match->hits[i]); + cpu_index, + match->hits, delta, + match->total_delta / match->hits); - match->last_hit[i] = icount; + match->last_hit = icount; qemu_plugin_outs(ts->str); - - g_ptr_array_add(match->history[i], insn); } static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -94,8 +89,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); } else { uint64_t vaddr = qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( @@ -117,10 +112,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) * information about the instruction which we also need to * save if there is a hit. */ - if (matches) { + if (matches->len) { char *insn_disas = qemu_plugin_insn_disas(insn); - int j; - for (j = 0; j < matches->len; j++) { + for (int j = 0; j < matches->len; j++) { Match *m = &g_array_index(matches, Match, j); if (g_str_has_prefix(insn_disas, m->match_string)) { Instruction *rec = g_new0(Instruction, 1); @@ -150,36 +144,33 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "len %d bytes: %ld insns\n", i, *cnt); } } - } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_count); } else { - uint64_t total_insns = 0; - for (i = 0; i < MAX_CPUS; i++) { - InstructionCount *c = &counts[i]; - if (c->insn_count) { - g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", - i, c->insn_count); - total_insns += c->insn_count; - } + for (i = 0; i < qemu_plugin_num_vcpus(); i++) { + g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", + i, qemu_plugin_u64_get(insn_count, i)); } g_string_append_printf(out, "total insns: %" PRIu64 "\n", - total_insns); + qemu_plugin_u64_sum(insn_count)); } qemu_plugin_outs(out->str); + + qemu_plugin_scoreboard_free(insn_count.score); + for (i = 0; i < matches->len; ++i) { + Match *m = &g_array_index(matches, Match, i); + g_free(m->match_string); + qemu_plugin_scoreboard_free(m->counts); + } + g_array_free(matches, TRUE); + g_array_free(sizes, TRUE); } /* Add a match to the array of matches */ static void parse_match(char *match) { - Match new_match = { .match_string = match }; - int i; - for (i = 0; i < MAX_CPUS; i++) { - new_match.history[i] = g_ptr_array_new(); - } - if (!matches) { - matches = g_array_new(false, true, sizeof(Match)); - } + Match new_match = { + .match_string = g_strdup(match), + .counts = qemu_plugin_scoreboard_new(sizeof(MatchCount)) }; g_array_append_val(matches, new_match); } @@ -187,6 +178,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { + matches = g_array_new(false, true, sizeof(Match)); + /* null terminated so 0 is not a special case */ + sizes = g_array_new(true, true, sizeof(unsigned long)); + for (int i = 0; i < argc; i++) { char *opt = argv[i]; g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); @@ -208,9 +203,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } - if (do_size) { - sizes = g_array_new(true, true, sizeof(unsigned long)); - } + insn_count = qemu_plugin_scoreboard_u64( + qemu_plugin_scoreboard_new(sizeof(uint64_t))); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); From patchwork Tue Feb 13 09:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772280 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169160wre; Tue, 13 Feb 2024 01:41:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVGke1ViaFYCSQDEwpi7XSutv92EYnq2MaGtEyvIuW/PB3jhONikwasteer1cLiLsHiWzJmWtdo71d9WbpJkFw7 X-Google-Smtp-Source: AGHT+IEuRStUvRU6IGw6U4yn9/LP+OSN2tDvCW1Pk6DofCdyz59NR09FEdT/gnr0tSVr/HNBS/fh X-Received: by 2002:a81:6204:0:b0:604:9551:f595 with SMTP id w4-20020a816204000000b006049551f595mr8334296ywb.50.1707817307970; Tue, 13 Feb 2024 01:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817307; cv=none; d=google.com; s=arc-20160816; b=zyP3e/AtHNi/Gxki5qzxm/ZecRUlXq/vbqFQ0pOXgBApRcCeQ7/yWdtXnNnmzQGPdY TBMJQT67kcPUZKhEatfAOfO2zQqdeLMldMZe3aU3UO6u5G+MQbJAEEcx72dfy+KBs7+9 rtrSnNMNirdXKCcrbeAVHkwNQhGkpvtCKrdICvvbtuYtfav3zSxk32FrRjwQCDpAUPMC 8h3uDLQ2SYSMM5FY5XGoFCkQ0v+PsLMLhsNRjB7NR9A+Ms5VF4IlhGGzYK15CWOyFiEU Hn2n0QbYbvQUS3wUWSeZLRVdd4QH3s6RayCDp0zJHtLwtC8gzcfvVImGZLiSqSeFLTrx o0fg== 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=vpn7ZrX++QOMXIPnhSOuAzbdhuGwGNkpxbx03u36x+U=; fh=+gEWStulcRykR/D0TibQP2Oj3ITT4zto0+3oL+jbYjY=; b=kotiMw9HPtzcjxcTRsakrvQKWXHA68oPycKrFX+rIfpyd45eKZZAffy6x7BnrOkzrn y0+G1h/tOPgOjmnT7P5wRn9RsxYswoHs/puVSsF5Tugj9UMr3w3j/d41e3Oo2rPJJWl2 kmKUIilOZbMmEaYSdcPbLv/R677eTDUnWFhuPdXlEnRFQ3D46eRUtBEFLBuXsocyB3/9 2FiZR2OnITJl6oGFeRQyjnKwPATM+cYD/LAD5X4ibfe7edyuhEUS8qoH+beVITYh6Yhf ywSckkdTKk80c0Mgk+OCgZWxFYsSJAEC9DlWQkzg5tetnuy4cVk8jRk+zFC2NaFrWzZ5 VxPA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UzZ4kuJF; 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=1; AJvYcCV//7HSH01m19cSCG6fCQ5XI5WqWLpZf58ewfh8rMriJOcDybVTQDR5KYuS7DfIqqp9qBf/doYtVSJjjuuV39CH Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay7-20020a05622a228700b0042a3927b852si2643344qtb.294.2024.02.13.01.41.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:41:47 -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=UzZ4kuJF; 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 1rZpIG-0001jM-L6; Tue, 13 Feb 2024 04:41:36 -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 1rZpIE-0001fd-Mf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:34 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpHz-0000Gy-6N for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:34 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33cdd1d732dso226206f8f.1 for ; Tue, 13 Feb 2024 01:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817277; x=1708422077; 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=vpn7ZrX++QOMXIPnhSOuAzbdhuGwGNkpxbx03u36x+U=; b=UzZ4kuJFQYlhQIoCIN9V83nvS6aOcalgjdDTplW6+YKrlJvkTje9EgT4sn5phzX8VE ac1ozRBrpjqAkzxNjOGQzcmbisww1L5bHYtu472RpE2DaTBfZvR3nbziPkUBiypUefJV vXC/L3d8zRGx0YyXLsQpEHZIOodVp91LflpC74yqotDSaN6SwTJSzQp2YRRV4SXEJp52 7V8oVG/2pQqBqdIGuGU65itR2mb3XhuWaTeGyYC36XBlGacSeyHp3LZhMbDd+EHE/ht+ 9w5jEwayRW4oawfGN0JIY2n52diCN8VCZg+NFwb5oXndk9kWnvSK5YFmRxh5YnxvyDru MXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817277; x=1708422077; 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=vpn7ZrX++QOMXIPnhSOuAzbdhuGwGNkpxbx03u36x+U=; b=ESw9K3ayd2XQs2yGPT/XsNzwpEGQLSuONrmTMiOTVtaRuIPqO8u0c/ZAfFzT/E0q0i gnficOjN8x/ymtzRJjc+YMZJNWE3NaKDyAjzY9cKR3NMkwgm8bwep8nYj4aBLvYqiuhd 2TdqkR3+9LgZOaOurYGa8iESRx00x9s4+3FjqLq3R7uxOqLFD8tJycIuv4uWSuelH61x Zjv/+9x1ThAFJ5LNke263dTpHvOoJ0AFNrOFlkWo12GgdRB2nqqKLAUz8L/2CmEb1kGp H9d683okeF9rrudkRSOB0qHrjA3db9LC5Yh3xTXSVCgstYihf7VomW8EI16HY+OlxhvX DsKw== X-Gm-Message-State: AOJu0YyDEHaiUzmAjeq0Z3zqVu+3NKkj176b1JXH4tsiDSYAvomzKgTz VAnJBexiPWHUJy4Gb/Zm1BAyS3yjly5/KlHRjjvKC8L2QJhdrJ/sp8QtdYnespbbAJcjss8eemW W X-Received: by 2002:adf:f245:0:b0:33b:4908:9bbc with SMTP id b5-20020adff245000000b0033b49089bbcmr8235584wrp.40.1707817276833; Tue, 13 Feb 2024 01:41:16 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXdsVz76ZbRWZUdS2RPjmqjygpveiHNswiu9r1TPuz1jbRP4+0cD3o1eMztLeM7as6ZI/u3B2ECO5HNEI55o9eK1/UC5jTaIjIBlJjE+8RSAHfIFGPof4x6EZAOAnmNOLJYm4D5z01pKgIshHHYPXMGNAcVQbgs1SI5QTaqfk13N8zTsofwf/yAVukWL9Nn2IEAU+oluFwROqSjzeR6AX5qzVqjXimmDgQpyiIDVlrIqiTMCBYCanbDt4lN5qYe2RvK2yJjKXSqJIkNLIDNeb8gg82YSqUr+/ALDv5gZDsb3jIlWIDSUv0xmOu41Z/b37/UzKk7f+YkWI8BKFkPesv0CqboWQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:16 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 13/18] tests/plugin/bb: migrate to new per_vcpu API Date: Tue, 13 Feb 2024 13:40:03 +0400 Message-ID: <20240213094009.150349-14-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 Signed-off-by: Pierrick Bouvier --- tests/plugin/bb.c | 63 +++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df50d1fd3bc..36776dee1e1 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -17,27 +17,25 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; typedef struct { - GMutex lock; - int index; uint64_t bb_count; uint64_t insn_count; } CPUCount; -/* Used by the inline & linux-user counts */ +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 bb_count; +static qemu_plugin_u64 insn_count; + static bool do_inline; -static CPUCount inline_count; - /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; -static void gen_one_cpu_report(CPUCount *count, GString *report) +static void gen_one_cpu_report(CPUCount *count, GString *report, + unsigned int cpu_index) { if (count->bb_count) { g_string_append_printf(report, "CPU%d: " "bb's: %" PRIu64", insns: %" PRIu64 "\n", - count->index, + cpu_index, count->bb_count, count->insn_count); } } @@ -46,20 +44,23 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report = g_string_new(""); - if (do_inline || !max_cpus) { - g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - inline_count.bb_count, inline_count.insn_count); - } else { - g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + for (int i = 0; i < qemu_plugin_num_vcpus(); ++i) { + CPUCount *count = qemu_plugin_scoreboard_find(counts, i); + gen_one_cpu_report(count, report, i); } + g_string_append_printf(report, "Total: " + "bb's: %" PRIu64", insns: %" PRIu64 "\n", + qemu_plugin_u64_sum(bb_count), + qemu_plugin_u64_sum(insn_count)); qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(counts); } static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count = g_ptr_array_index(counts, cpu_index); + CPUCount *count = qemu_plugin_scoreboard_find(counts, cpu_index); g_autoptr(GString) report = g_string_new(""); - gen_one_cpu_report(count, report); + gen_one_cpu_report(count, report, cpu_index); if (report->len > 0) { g_string_prepend(report, "Idling "); @@ -69,14 +70,11 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count = max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count = qemu_plugin_scoreboard_find(counts, cpu_index); uintptr_t n_insns = (uintptr_t)udata; - g_mutex_lock(&count->lock); count->insn_count += n_insns; count->bb_count++; - g_mutex_unlock(&count->lock); } static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -84,11 +82,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) size_t n_insns = qemu_plugin_tb_n_insns(tb); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.bb_count, 1); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.insn_count, - n_insns); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -121,18 +118,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } - if (info->system_emulation && !do_inline) { - max_cpus = info->system.max_vcpus; - counts = g_ptr_array_new(); - for (i = 0; i < max_cpus; i++) { - CPUCount *count = g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index = i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); - } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + bb_count = qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, bb_count); + insn_count = qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, insn_count); if (idle_report) { qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); From patchwork Tue Feb 13 09:40:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772288 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169598wre; Tue, 13 Feb 2024 01:43:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXGbeLhCak6Al1BEusXLyAj+d5XdlOh6GN+7mQO3/i5bD/HPA0vjzPbiE0IxVy5kKOa/aP0bPncPDfU6qGZJwVK X-Google-Smtp-Source: AGHT+IHhv7TpmaH5AMCl0zV2d1S5YACWwRE+sYu9j6rrbhvVES/A6mLgg7xZ3tEM49aOP8JP5EUg X-Received: by 2002:a05:620a:146e:b0:784:93d:c905 with SMTP id j14-20020a05620a146e00b00784093dc905mr10222067qkl.25.1707817402185; Tue, 13 Feb 2024 01:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817402; cv=none; d=google.com; s=arc-20160816; b=Gr7mEkj3QZfnZGzyAGHyQHCy4VZSelYKoJXmaFxnBtnTQ7QdMBzB0ROAog8U3jrGeF I3SNQ+oV7wourJ/16qgvD8BVcerThOZsBBDMD6WlZDZb988X8o+P22bJjfvOZIUS1L9O /GchW9PzDzGyhpFoow4CkwSXn1I7H1AQaagaGYyURYLDsRXHjO29Kqy3dGKr/4ltj3LC CAj2SB4H+crFsp2uZGLF36D0yrIV+JmVvj17SfFMJHIwDoXv91ou6D5omh+LBWj1iSl+ 8z/1Le/ZeaBiypB5B75tNJf8lhOfxQ8z59XSEQ8QUhO0GBNhZfMKPUqo8xeaGZ2PzHh8 6rCA== 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=RwJ8e6wUH7fqyic9sqG77ZVCFxcpo7vgFJo8+jFAkz0=; fh=/oznn7ha+IAV1pFOj8QQdlOLiRShSay6Y7rxrbqLeDU=; b=YZ+5urnSo9xOHDHG841RAK7EAUExY6f5zm5sWzPynCQJAO6bH/QQN653OM63NkMBF/ RAmr2wNkrOsHMfHZkEcauNidMH+e9RuJqJYPomqEkNzqICb3vqpxg2Nh1UfWbKeIX2vl uUJOJ469OGDePxjfeYrBhty6Wb+UzeJI5ih/k91DUsihp5Ol1FmfOf0rQJRqwc09y3o7 HHz/tMnqNBBTnrMpRhUlAt9Piic5rcaSdkVBDzc2vO2osG3hJwVFpbFBZeUmyYO1cJw1 nbVv4gGt3jKUq54b6OilYw6mh17eF3DSLQGW2UPfEoG5AVS4UpM8/xhDoBxeXdelgY4q uHUA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pYsOMq9r; 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=1; AJvYcCVILFqnEWGJAtDFdFeYINAGH7gbmD7ZnDT0FQ/Pi8ehz5Gw5no/fx1Q8ZAJmTb1sGQPotEDNVHBCniEu1LaVdWz Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q13-20020ae9e40d000000b007871e94b64dsi670571qkc.530.2024.02.13.01.43.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:43:22 -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=pYsOMq9r; 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 1rZpIH-0001pv-TW; Tue, 13 Feb 2024 04:41:37 -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 1rZpIG-0001gP-9W for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:36 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpI2-0000IY-Ul for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-33b728b6981so1527777f8f.2 for ; Tue, 13 Feb 2024 01:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817280; x=1708422080; 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=RwJ8e6wUH7fqyic9sqG77ZVCFxcpo7vgFJo8+jFAkz0=; b=pYsOMq9r5LK5zEufaOE1Vs+5rr6DVHoYySvsquC0cD/D4e3AePjNkSqE/a/dtqtGde lAikcXzHzY0VB1qjsJOGSHHf8lViXQJ21Kqk+0zzf3fcMw4asLqoQplAb/xtVLV0x+Nc sNSQurxxzMEYODwkZm9ilpYzu6HgwoTa/YnezbYxx6nRJN11llfcvM4olAZhyX5/2vNB q2Q/O82jrPcxTcNz1QZPWn4yn3ZltZFMvgNFVyz+umwM4AACaZKYta9/998iI6lS8MSG SO5YNoyqXt41JCMXEXI+FiqGlppNX8Vj7ceP7AE+9SmPkRaFdOy3mvnIessca3Cimy9W PIxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817280; x=1708422080; 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=RwJ8e6wUH7fqyic9sqG77ZVCFxcpo7vgFJo8+jFAkz0=; b=eZslycFAFj7lHX7cHKwTV5IyiBMhymHL1H9yco4xrOCNGaJaJ7O6aKJXRJSeQropyM 5HejIi4WtwRkCdH3bwAlbcNgKj6WZDui2+GjMj6ZOSgtDPMXpKXW8/chgplw4DeYJImx HhPQnqdSFCsf+AmFP4q9ClU6+lWPFbdzv3evOisS5vojFXsztkUGX52jS1xwMH1pxW/1 uc1aJJPWOCbupx5lVRNwLyUkp2SKllSSpHnYsnPQBzPl5/RCrgdjyu0OEdZE4jgPzxMI TFeOXYGZIFOO1fBabBCXBaGlnWJZ/kxh68d9wfviuUyvlaAz6uYjoaoReVmGgRl+53/l yfhQ== X-Gm-Message-State: AOJu0Yx2ykm7Lbat1jFY0JV+f1KY21QS1OtJpWo0ApYaABS73EiBTGOi Mw6Aa3AB9G8jxkk2Dv7JjVxaGMH2WqPe97Qw95JXa8yKOyGZjnvqe3RNJqi98oPWHbAEs77tWo3 l X-Received: by 2002:a5d:65cd:0:b0:33b:64c9:da80 with SMTP id e13-20020a5d65cd000000b0033b64c9da80mr7067643wrw.19.1707817280275; Tue, 13 Feb 2024 01:41:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXzI+3Fr8yP2Nl0cGZMr+a1gwMipsAS4X6+I2yJz6hGzRiY/Kn4OB44gsT7WfpILvOGessXLfI9iPZXS7iqD/nbybaQfA8grEGPMYaXANZ48SbYZcVawZ4xOVj5DYMCMw8LabSforvUY41KgwrMP8PjvJEMweeFkm6eg71cmtkXmT0ORUuA1+LcjSJfQfeW8stA+jryNhrrKwhOLXUS+AxRBIOgykXXsiOwnd4gedqAX/hjGv9wJI+qVHUgRQnJIOCJmuuZ6Fei7BeaA/HBBXWPakbyZ6KVq0NdUXdZ7oJ6+1DDQE90oK7/hGYFaReAIwsJmNb5UjhHJNuDxDNKu5Xxb5hcwg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:20 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 14/18] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Tue, 13 Feb 2024 13:40:04 +0400 Message-ID: <20240213094009.150349-15-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42c.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 Signed-off-by: Pierrick Bouvier --- contrib/plugins/hotblocks.c | 50 ++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 4de1b134944..02bc5078bdd 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -34,8 +34,8 @@ static guint64 limit = 20; */ typedef struct { uint64_t start_addr; - uint64_t exec_count; - int trans_count; + struct qemu_plugin_scoreboard *exec_count; + int trans_count; unsigned long insns; } ExecCount; @@ -43,7 +43,17 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) { ExecCount *ea = (ExecCount *) a; ExecCount *eb = (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + uint64_t count_a = + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(ea->exec_count)); + uint64_t count_b = + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(eb->exec_count)); + return count_a > count_b ? -1 : 1; +} + +static void exec_count_free(gpointer key, gpointer value, gpointer user_data) +{ + ExecCount *cnt = value; + qemu_plugin_scoreboard_free(cnt->exec_count); } static void plugin_exit(qemu_plugin_id_t id, void *p) @@ -52,7 +62,6 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) GList *counts, *it; int i; - g_mutex_lock(&lock); g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts = g_hash_table_get_values(hotblocks); @@ -63,16 +72,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) for (i = 0; i < limit && it->next; i++, it = it->next) { ExecCount *rec = (ExecCount *) it->data; - g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + g_string_append_printf( + report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", + rec->start_addr, rec->trans_count, + rec->insns, + qemu_plugin_u64_sum( + qemu_plugin_scoreboard_u64(rec->exec_count))); } g_list_free(it); } - g_mutex_unlock(&lock); qemu_plugin_outs(report->str); + + g_hash_table_foreach(hotblocks, exec_count_free, NULL); + g_hash_table_destroy(hotblocks); } static void plugin_init(void) @@ -82,15 +96,9 @@ static void plugin_init(void) static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - ExecCount *cnt; - uint64_t hash = (uint64_t) udata; - - g_mutex_lock(&lock); - cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash); - /* should always succeed */ - g_assert(cnt); - cnt->exec_count++; - g_mutex_unlock(&lock); + ExecCount *cnt = (ExecCount *)udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(cnt->exec_count), + cpu_index, 1); } /* @@ -114,18 +122,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) cnt->start_addr = pc; cnt->trans_count = 1; cnt->insns = insns; + cnt->exec_count = qemu_plugin_scoreboard_new(sizeof(uint64_t)); g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); } g_mutex_unlock(&lock); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt->exec_count), 1); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, - (void *)hash); + (void *)cnt); } } From patchwork Tue Feb 13 09:40:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772292 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp170000wre; Tue, 13 Feb 2024 01:44:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWszcIkRNNx3KUMPAFT9mQAlL6f6rvTNTu24eHJNw54zSOulb0qDNHgH35Tn69ThTas243bMQ56fLNuu99IxLE0 X-Google-Smtp-Source: AGHT+IHb6hNtJ06dkCZnwmlbFFZGBmun+DwAoXZwxgOCd55qxZGIwaPMsuRtjZUFkIQOYgzu10D7 X-Received: by 2002:a05:620a:2043:b0:787:1e7b:905f with SMTP id d3-20020a05620a204300b007871e7b905fmr864455qka.31.1707817483651; Tue, 13 Feb 2024 01:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817483; cv=none; d=google.com; s=arc-20160816; b=J7do2mDPzebduxS/Wgq7DDXHURLdv3YeOULp8641deUSTWa1kVj1tSp3XOBcNZ3Pcz 8zkBtqWlJ44w8aHyg4xAa5LLUageCFgtSW8wIAWTAsX/2/x0Q5+7TXRgbdT5YuA5+nly G+3HaFqz0JAHNESMMW07YAB/aaOsQIBEL/ursLtjM6PFkn8s775ImH8AInBc5OcwsLzc pGyNk7QaHzMgsHD07sh76fXxYw5x/qc0vX5Yho4CDZPPbFlT+z/JQtg4pukCPi02RZ6M eSQ+N2FK005kgIaamUIiOKga3D49UjEj6IcNGTc143OuPM9n2Df8ir1kypM+GFzqlevj CRag== 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=KLrDeSzxAfz0BkmoOA2bd0HrCpMytbURUXRn/P+Vjdc=; fh=E37dxl1QvcSmoa8YjAPfOqmTXRQ8uvNQ9GSn12ILALU=; b=pA5rwloGRxFiUy2qKCQ/GE9AKFBuL3nK0PxyohEc3Cj5Kr00sv/gvzvHPs/XiVj9yc lhGnLSpMg+Ad8mkWzCE1brWsdWvnj4HGUJ+hnbNJPVxKHM//qKRZ/9OqWSFGPZE4uNRR ykiHDmLnQqBcVLeXwZwA0zwaQuk3rFLEBbAPXW9fhcGMuh2Zk+/Jtn7zUKNAjiozEhnv Kec+EV0nfCwvsH15RHlzhWcI9jwqiIKYu+3Ss+3TERiX8/Y9QnMxymRYIINwDqaRZPc2 mEwruzVo4A49SY2xSAgUrPrOI40Sb2ahTQ1bMzxAguB0GP3KbCGXbAS+54tXNAGCmvog Aiew==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jpzXerFU; 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=1; AJvYcCXYMXiWoemLF1bzT5Kqf5DAzU5IEUfSkx/JqTP2WhiF7nz0v55Bknz7C6arg3zg+wZkrsSas85nbD6ABXcfRRJW Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id vr11-20020a05620a55ab00b007871fdd2b97si568065qkn.218.2024.02.13.01.44.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:44:43 -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=jpzXerFU; 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 1rZpIV-0002Uw-UE; Tue, 13 Feb 2024 04:41:51 -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 1rZpIG-0001jK-LF for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:36 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpI6-0000Ih-Vd for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33cddf4b4b5so139884f8f.0 for ; Tue, 13 Feb 2024 01:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817284; x=1708422084; 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=KLrDeSzxAfz0BkmoOA2bd0HrCpMytbURUXRn/P+Vjdc=; b=jpzXerFUIBX/1Bnt29k5zb7z5C+C+qvQU/BYQXRPvnhOzQQTCcw7cYdo68KfDqsETS /zUphpkdvfGQgYgin8K9qnjLeq6nWyoGnct5LU0D55ggz8fokW9kvXDokr7dcs445N/N plAvrWwAmbxYiodS4ODqwpCjikL3L7XNkIqtOc7E3KgouZPnrrA7kEOSJ5uhuiBMSSyy UdAQn1UcsPVm7ziKc/Hn9MyXDiZ3S53/CrM2H19ybVGo7AXQLk32rlSu9dWyc8HizLo0 xW+PmJMdkKTyekyOmAa1A3e5c59wJWQAAxuEV/iyuBVNNfJiaKKiMsfojEUIyjjte59X lhpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817284; x=1708422084; 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=KLrDeSzxAfz0BkmoOA2bd0HrCpMytbURUXRn/P+Vjdc=; b=iZtuj0ziyRqqgaoXTo3yM5bXwQD2ZexjxKCecbx2lCSL/Bi8DUiQICw4KFUNnLszJ9 +RcZu/cUgGyrHVVCUVmtg9ueeGF5OQFhnmbco+MQY7rgQUk/Kau9lfxhYwWqv/DW/U5X xjRh9xFTl0IHo329isE7FwVJDhA2EpwiFrHjHg2Kgr85GbAr8sJRoo3orIftjQQ/5XPD w0teb+RpHyhH06tQxDhb/Cg2Y1y9FirYsgBQDNWN+3cq6yM+KkluWvSGcQV8DBToMyDA SVtV35rb/YFY7j7yWGYyEYk7R0jNNaTKLNnWaXKm/RTo/Sim3fh0GJjcPSai+KOvuEWk 5V5A== X-Gm-Message-State: AOJu0Yy1Q8ZP76o4jmhk3TqpwHKNgQX0QW2/jmSETqbXHye2yH5/ZI2K tavsiCcPzVboVWpTv1UIOQkzDR5nEZUvsnGINv4kvwK+ePfcI/foULOqvEnEnto9Z027NuCxqyL 5 X-Received: by 2002:adf:ee8e:0:b0:33b:2e44:6dc8 with SMTP id b14-20020adfee8e000000b0033b2e446dc8mr8500549wro.25.1707817283778; Tue, 13 Feb 2024 01:41:23 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXY2S2RCcFV8HJLYUHATIpyQA6R1I/nB2lpVITmPyUoJVUhLq5MqP10WwB28DzD1F+1QW1iB9ibNx5CuSGqQ7WjFXmn/WXXvuDJyvvC//F45nFUoqzosCUmOXh8QuFd5RVujSYvEOmsn+SEYSvTa/TNsStBI4svFjVBoaDITVFg7As2k2CuOlW4AnYg+281ZbxIyYX/a6Yc2MBl3mdT0ZV3CoQVQIMEUM+w3hUyETyZKQJ9ugifeqggvRfAwXw/S5UaT7r3x7RhZk2iBJqe9mFlXZCepp8KjiyZPs6MYGQAPBtdWNIHGH6qsS3P3Ge4AJTJqaIJvvkNs01R1q94sxdVPSeeRw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:23 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 15/18] contrib/plugins/howvec: migrate to new per_vcpu API Date: Tue, 13 Feb 2024 13:40:05 +0400 Message-ID: <20240213094009.150349-16-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x436.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 Signed-off-by: Pierrick Bouvier --- contrib/plugins/howvec.c | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 644a7856bb2..2d10c87e0fb 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -43,13 +43,13 @@ typedef struct { uint32_t mask; uint32_t pattern; CountType what; - uint64_t count; + qemu_plugin_u64 count; } InsnClassExecCount; typedef struct { char *insn; uint32_t opcode; - uint64_t count; + qemu_plugin_u64 count; InsnClassExecCount *class; } InsnExecCount; @@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) { InsnExecCount *ea = (InsnExecCount *) a; InsnExecCount *eb = (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + uint64_t count_a = qemu_plugin_u64_sum(ea->count); + uint64_t count_b = qemu_plugin_u64_sum(eb->count); + return count_a > count_b ? -1 : 1; } static void free_record(gpointer data) @@ -167,12 +169,14 @@ static void free_record(gpointer data) InsnExecCount *rec = (InsnExecCount *) data; g_free(rec->insn); g_free(rec); + qemu_plugin_scoreboard_free(rec->count.score); } static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report = g_string_new("Instruction Classes:\n"); int i; + uint64_t total_count; GList *counts; InsnClassExecCount *class = NULL; @@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class = &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + total_count = qemu_plugin_u64_sum(class->count); + if (total_count || verbose) { g_string_append_printf(report, "Class: %-24s\t(%" PRId64 " hits)\n", class->class, - class->count); + total_count); } break; case COUNT_INDIVIDUAL: @@ -212,7 +217,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "Instr: %-24s\t(%" PRId64 " hits)" "\t(op=0x%08x/%s)\n", rec->insn, - rec->count, + qemu_plugin_u64_sum(rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised"); @@ -221,6 +226,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } g_hash_table_destroy(insns); + for (i = 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j = 0; j < class_tables[i].table_sz; ++j) { + qemu_plugin_scoreboard_free(class_tables[i].table[j].count.score); + } + } + qemu_plugin_outs(report->str); } @@ -232,11 +243,12 @@ static void plugin_init(void) static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - uint64_t *count = (uint64_t *) udata; - (*count)++; + struct qemu_plugin_scoreboard *score = udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(score), cpu_index, 1); } -static uint64_t *find_counter(struct qemu_plugin_insn *insn) +static struct qemu_plugin_scoreboard *find_counter( + struct qemu_plugin_insn *insn) { int i; uint64_t *cnt = NULL; @@ -265,7 +277,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *insn) case COUNT_NONE: return NULL; case COUNT_CLASS: - return &class->count; + return class->count.score; case COUNT_INDIVIDUAL: { InsnExecCount *icount; @@ -279,13 +291,16 @@ static uint64_t *find_counter(struct qemu_plugin_insn *insn) icount->opcode = opcode; icount->insn = qemu_plugin_insn_disas(insn); icount->class = class; + struct qemu_plugin_scoreboard *score = + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + icount->count = qemu_plugin_scoreboard_u64(score); g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } g_mutex_unlock(&lock); - return &icount->count; + return icount->count.score; } default: g_assert_not_reached(); @@ -300,14 +315,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) size_t i; for (i = 0; i < n; i++) { - uint64_t *cnt; struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); - cnt = find_counter(insn); + struct qemu_plugin_scoreboard *cnt = find_counter(insn); if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt), 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, cnt); @@ -322,6 +337,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, { int i; + for (i = 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j = 0; j < class_tables[i].table_sz; ++j) { + struct qemu_plugin_scoreboard *score = + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + class_tables[i].table[j].count = qemu_plugin_scoreboard_u64(score); + } + } + /* Select a class table appropriate to the guest architecture */ for (i = 0; i < ARRAY_SIZE(class_tables); i++) { ClassSelector *entry = &class_tables[i]; From patchwork Tue Feb 13 09:40:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772281 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169286wre; Tue, 13 Feb 2024 01:42:18 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV6syYGR9OZyOsQBixkXAKGVURr3goN2UTvwL4gU19Smp+pyDSCjQU0mQ13/UYTSudjf1+G3Xy97GPlR15A+nzB X-Google-Smtp-Source: AGHT+IG6uA9xVaR3YZGejf1mZuJd2r0wie3hEEqoMYE1EpXrWBx6QXThPnOl0r2mI96rPITGP4hO X-Received: by 2002:a05:6102:18cb:b0:46d:2f9b:2b32 with SMTP id jj11-20020a05610218cb00b0046d2f9b2b32mr7334893vsb.15.1707817338088; Tue, 13 Feb 2024 01:42:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817338; cv=none; d=google.com; s=arc-20160816; b=eKcINlxOyp3DiasQgjfQb0UghaJ55lp176wA1rM0keohZI2XOP0hPo5q4dsSKmQMEK PoEtwep5t4/4Bch2A1dQy6lKJfJZ2WoCY9ivgrzsWhTndqcMfoWel8GPAoMj0UufJWwz j8kH8N70MWsQbzAmDfbXl5/KOhoFyyNszyveMZzcLmgb57QvgM9NP4B0+fpxHOMCBU1X VO1Vws8ha4yJI3P2MI1voGWl0NdjYJqu3F8SOZ9DYFzac57zkYo9eC2x8N0qgr2CrZ8x gqrJkYStgdlnJJKoDG0xWUUhGxzb0d48jPyaiPvq5A3Ibr+1uKpM6tl8ePqKul0VR2IO Vi+Q== 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=FX8AG3Ps8xAkefZTvhN1LBKlwzFSEA66N1+pg+4IJGo=; fh=fEt4u9pvYVhurTjJL7pR8pV1BMWEPCu9fX6Qbpr8yAw=; b=uxnWbOj+JIk9fplfDOvUM1xquTeKE4D8CnY+WoZqFtaRE6aKfcO6u40yVTp20yLolV jGrsJ4iKW+4cQN6wrsewVGycgTjCxH+mfG1rjLPbye0XXFXrCPEKpH/dLpytbxjvRJjR CHCz+smlc+IfdRpE/QyHHXu5fVJaiDGeKgjv3t9Uai1+Aq57LFfTpLM11pbNUoV7Td8B WUu178BKJQDudr9VPLh4ca/fNHwHW5aVelLZ55YuUwmOJWzkLn6y6LpPBsyglFmFtlXm 7nx+PL2lfccvLWjjXsBP4cmstp95Rh2vuzbNIbQtKQWOG7qURBnQEmVe76xW7jNF6tC5 QHUQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g/wV5ndg"; 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=1; AJvYcCXrIdeGiNzVGxUGbgYOOzMvWJ31vepo+ObwmuvRgBVwVsYPP9YIOav3RL5xXcoM4Ht8utd9qASuUuMDVP+Ux7Pp Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c6-20020ac85a86000000b0042c44c065e6si2593925qtc.733.2024.02.13.01.42.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42: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="g/wV5ndg"; 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 1rZpIM-0001zU-6c; Tue, 13 Feb 2024 04:41:42 -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 1rZpIF-0001fy-Np for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpI9-0000Is-6M for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33adec41b55so438904f8f.0 for ; Tue, 13 Feb 2024 01:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817287; x=1708422087; 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=FX8AG3Ps8xAkefZTvhN1LBKlwzFSEA66N1+pg+4IJGo=; b=g/wV5ndgySjR2tSIni1y6cSk7bje1gpINb9n6eCoxsqSm9Z7RZFpe0RzMOdNX9XmOp VVZmP0c0f0QJywaX58oLQ57LjC8HVTX9ec/CwvxeaRUHv3ZClEamkMsYzgxRh4gGHosk bdeqOSSKNRUmLMIe/lwYO+P9bI8odyskqOoChaTkWy1PEB/0w1c45JMsOE8hwzaJl3fI ekTynjG6qHvzDk/WN1ECOsylLIPLLmdjLgiOAb9b+TXP2GCGukUJy35h315GODIiPLL/ 7/tURaycVya4zf7dlOKECNlbH8onCzLt9R4Yyv/t6CdYKwYyBuxuM1yE16r5eVo4HxjJ uOfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817287; x=1708422087; 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=FX8AG3Ps8xAkefZTvhN1LBKlwzFSEA66N1+pg+4IJGo=; b=URm0bkNbyvC3aOFdf3inzkgyH4mEevI5GJgFES+LjfxiqE9BF2jFzZ9Y8ZfGSqJhtS ZNrjTP4ZtI3Gm8emSHooE+6UPAjN1AxcoCTPHDPcKPu+mhx/eujx83GR62OT5+FV9aKi PpaN1yh9kGSf2SxOFiUyF8vJ8Nq+F9ovbIJo6BJbtJqUA5iSNsC9BYmLjKl9xEI2mhF2 XhRUoyLpfCxv35VLTccc/+suh3PUFlIT7LtNHjbhz3z5J6lFFlfADZ1liLXGus2CjWiY WKkdH0v3oCzEKxGtJ6aIYh9cqa4CpbIefRZDEBCWvHD45bPXtL1IFcyR5YNKQTZzoY1K 1udg== X-Gm-Message-State: AOJu0Yy6LDP+/EBRvK9VLsmccSgZWJleSglzDZA1scSqYsPCCKweT4U5 er7v+91GJhTobjRGbxRqWmkSu7gAQrLoN04VIAyp/ra+4HDzxAserRbUF3QDbkOzn3726/2l6SI A X-Received: by 2002:a5d:6e55:0:b0:33b:3c79:9182 with SMTP id j21-20020a5d6e55000000b0033b3c799182mr6702834wrz.3.1707817287288; Tue, 13 Feb 2024 01:41:27 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWQ/nrcdm5oX93vAwJGHq2W8VMFzg+QICcT6RyDCKIxECNIWfr8m+DpIWFWh7NsxhjkUF9xGq5BmKRAj3oJy+NHy9P0Rvl0Sq+hIESzjBZ1lprLytWb+4iQLlVtwdvNu1idod9ZeFbnyzxmltTrGZdaGDWI88CJQ4NxEqKfw+jChkKeUtf9HZ3vNFaSS4lwwC8tIMEzHC45PjwOee/UR8AQtpKFyxWvgkHtiYv9mN7gQ2WROwcc30dZfkTY9j5nP1pA9NqjO7rT9E7rmyGNCNsLs4aaXX/0O3a/HovukGuIh0VUjgTlb7Cp2dAih+hty3PElMM3VJLdAZElXksmo4sGGlZWtA== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:27 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 16/18] plugins: remove non per_vcpu inline operation from API Date: Tue, 13 Feb 2024 13:40:06 +0400 Message-ID: <20240213094009.150349-17-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.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 Now we have a thread-safe equivalent of inline operation, and that all plugins were changed to use it, there is no point to keep the old API. In more, it will help when we implement more functionality (conditional callbacks), as we can assume that we operate on a scoreboard. Bump API version as it's a breaking change for existing plugins. Bump min API version too, as we removed some functions. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/qemu-plugin.h | 58 ++++-------------------------------- plugins/plugin.h | 2 +- plugins/api.c | 29 ------------------ plugins/qemu-plugins.symbols | 3 -- 4 files changed, 6 insertions(+), 86 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index cdf1266d724..9b11098ff82 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -53,11 +53,15 @@ typedef uint64_t qemu_plugin_id_t; * symbol qemu_plugin_version which can be checked. * * version 2: removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus + * version 3: + * Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. + * Those functions are replaced by *_per_vcpu variants, which guarantees + * thread-safety for operations. */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 2 +#define QEMU_PLUGIN_VERSION 3 /** * struct qemu_info_t - system information for plugins @@ -309,25 +313,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; -/** - * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op - * @tb: the opaque qemu_plugin_tb handle for the translation - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time a translated unit executes. - * Useful if you just want to increment a single counter somewhere in - * memory. - * - * Note: ops are not atomic so in multi-threaded/multi-smp situations - * you will get inexact results. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op * @tb: the opaque qemu_plugin_tb handle for the translation @@ -359,21 +344,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_cb_flags flags, void *userdata); -/** - * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op - * @insn: the opaque qemu_plugin_insn handle for an instruction - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time an instruction executes. Useful - * if you just want to increment a single counter somewhere in memory. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -597,24 +567,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any memory access - * @insn: handle for instruction to instrument - * @rw: apply to reads, writes or both - * @op: the op, of type qemu_plugin_op - * @ptr: pointer memory for the op - * @imm: immediate data for @op - * - * This registers a inline op every memory access generated by the - * instruction. This provides for a lightweight but not thread-safe - * way of counting the number of operations done. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access * @insn: handle for instruction to instrument diff --git a/plugins/plugin.h b/plugins/plugin.h index f6fa10a0f56..c547c5c83ea 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -15,7 +15,7 @@ #include #include "qemu/qht.h" -#define QEMU_PLUGIN_MIN_VERSION 2 +#define QEMU_PLUGIN_MIN_VERSION 3 /* global state */ struct qemu_plugin_state { diff --git a/plugins/api.c b/plugins/api.c index be2badda9fa..45eabab8686 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -101,16 +101,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, } } -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -138,16 +128,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, } } -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!insn->mem_only) { - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, @@ -175,15 +155,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm) -{ - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 0d8141b85f1..a9fac056c7f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -27,16 +27,13 @@ qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; - qemu_plugin_register_vcpu_insn_exec_inline; qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; - qemu_plugin_register_vcpu_mem_inline; qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; From patchwork Tue Feb 13 09:40:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772285 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169467wre; Tue, 13 Feb 2024 01:42:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU2RzgtebflXQ0//Gjffk2Hd0yKypNkxIC210rDyWI20pnTGn/M49sp3gz410V8FCl2tEao4G+/OClsR4+ejNj/ X-Google-Smtp-Source: AGHT+IF73RbcOYG5C5Uospp8e17cJB6nUkLX3EGzY93yqllL2usiZkdzjxGnjis5SJbs2SE5xRGu X-Received: by 2002:a05:620a:5621:b0:787:1652:bdd4 with SMTP id vv1-20020a05620a562100b007871652bdd4mr2397259qkn.47.1707817377413; Tue, 13 Feb 2024 01:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817377; cv=none; d=google.com; s=arc-20160816; b=yhDZ7Yp4RnklRpPMj/AlyS8QS6+XeDb03lBbRc2JhaUaBEvSvZNaz3DlTKs7pPJEEC HoI9isQJlpiiq34XscnqpC0nHAlCuWWJY7hbSWHwyE7Ho7J/1dq5A1nyNLEY39vyzAdi IBYMO6IO6Fj9owXbjL0VUWq7QYxj4eXAQLjRlx5SVsSTXXnBklFR0dlx1xj/Fsbq1gNX PjEjTxYBgI4JSb3sCdZaqlxkcyBGt6Cmtw8xI6na6WoDc1QbpFXaNmcM8BjtZjdx8lbL BFceWI2ENOkL9AO9d8F9RerY6zXuOq/f1CTYQeNY75QF20cZPLZjqdw+q+vB9W2kuJZ7 7RTA== 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=FtKR50om3lz2f67CJh+jhse66BPOqMojGHQCZZJ40RI=; fh=t+mu3RkQnV4ZSsdaRHXt9lmD/dtCXxlZRy6cYgZsCXM=; b=rhch+SuriVcl8Duab3egD0CwDdWmlxhrXQOQTb7E7fA+KvhOyMA3N0ykNV5/3Yoo8d 7Ddn8ApVpMErCJ9xAWQSqnmRDuqs2R90D57ApVLQ6pf4jKfuHPN8Jmzx8PiGXmudbS6x OwNu71ZW3i/+a5dV4LOa36F3DEhEUYYdVv5o3Ff4uoI3nduVJ5xNOQN63Ym1r+eHdsd0 ST7+kpuutn4Hl797Iq95b+85O7lbIEKpgmgQNnYoqfRNBsVx2m0fjZjoWvx9Z46MncGB RrECBtKzY3ilR7o+UWMuWSTr0hUkkwDPLGbYUELH9qbWx27IZeyMspm/cApF5v03lA7c qTNw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tGpsDd0X; 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=1; AJvYcCUHiATtGJ0V0SFbFo48vuISsmy/af/vAmYpYZqD3mPCNaolkoH4Ll8PYcBqWhqfxSewkc8Oi7eTRD1JN3UG0+zC Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id vr24-20020a05620a55b800b007871b460c08si1140478qkn.282.2024.02.13.01.42.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42:57 -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=tGpsDd0X; 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 1rZpIK-0001xF-Ah; Tue, 13 Feb 2024 04:41:40 -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 1rZpIF-0001fp-BQ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpIC-0000J0-7z for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:35 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33ce0802f17so95049f8f.0 for ; Tue, 13 Feb 2024 01:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817290; x=1708422090; 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=FtKR50om3lz2f67CJh+jhse66BPOqMojGHQCZZJ40RI=; b=tGpsDd0XMuxcbaNyKMoFmMJZUbM+ejni7rejQ8U5i7shL/Fn+kgt78mGQYnv8oHqKy LYQCGQamHVJvBJqunKbQFjnY0efHGE0DVPMPlVa/jZ2bJnJvdDtB89K6t990bwG+2tDV JU8m7OwmvQ7o0Q84ksxaiChhahs9/7t7uDSG1OsICgHZG8LKZm1U3UjCpjeKZuU1Iq4I cvr7AqTye9oRNFO5DU664CJcVmMY6wBIvKENYj0ox5JBI9DfFktGguALUuwWbQPeaKfF qWXjwYPScSVh/I8sVxnAVCcd04YaLE9cDxwS21bI/7ZWsCZJRiADsNzSzXBEJk3bhKwP ea4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817291; x=1708422091; 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=FtKR50om3lz2f67CJh+jhse66BPOqMojGHQCZZJ40RI=; b=jrKpNaA1uGOgU8Gsy3ExZKsfhequKBaOaKCBLgQn518wZeFys4NcY8E2fu7FD+1/P5 Df4494EDuZALEuAOP6t/1RPYK4J91lDI7vWD7k7TzTOq8UelxezTBNA/vywStR4DAxtU jVtP5svUts23QLanvK60yWJpzqRRJgIT6x8K8zB3ae1OT7Tl8jS2+pjXm4bi3pG2DCai HRqNk+AzB9pqBp2odrN46jMPvpEMhcPsiIhmkCzfU9uCDjQyiP1GfG9cWMdq/5XTVYHA NWQrG0Q1APcKyRkbk9B5Lw1Twu706mzhC0+ROD7KhRkz8MtdbvU7Jdv6i0VvlzwOhYC3 t1KQ== X-Gm-Message-State: AOJu0YxV6iCWCOTUa/nTR6PIrE03YvfP43iWyvL7spcwA2PsdPKPdMjJ oPPpqszVDMUcUYsSASlgjqpTGJBAqd4bEPKoEtu3QoUq2b3/+n9wNTQeg4uugXQMRgZTrLcGHEE z X-Received: by 2002:a05:6000:108a:b0:33b:25cd:ba9 with SMTP id y10-20020a056000108a00b0033b25cd0ba9mr5196920wrw.70.1707817290762; Tue, 13 Feb 2024 01:41:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVIFr3bKkOm/GqsCsb4PUDcBYvPrjlC5NO1dN3lhld/63qalz/asPo9nM6+nyaJhgod3l7xp8vNWYUrFKSlT/PTxBYRvH0pi0acsfd59MhHpn2w9zcnADXwGrxd9ePwTHYvtUgStOEseUdUvHFc8fTtNtO1kUQ4t2EN4Fr/hs2vKL2eAoP1YATlIYTj72q6MS1JOyvk155kgMWoGYWMuyTrXhPL6iQqFDyi/iWsz1Bt1OWuxLwkdd+N5bYCapaoV+dhFfFwMdNUZfvST/92jP3SWM+CknjjiIYCIQDSbIk1JCAPyk9vh960zoXcPC+/7MaQnJ3//+S4Lk+WpRPPAe7fxVNWRQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:30 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 17/18] plugins: cleanup codepath for previous inline operation Date: Tue, 13 Feb 2024 13:40:07 +0400 Message-ID: <20240213094009.150349-18-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.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 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- plugins/plugin.h | 5 ----- accel/tcg/plugin-gen.c | 13 ++++--------- plugins/core.c | 29 ++++------------------------- 3 files changed, 8 insertions(+), 39 deletions(-) diff --git a/plugins/plugin.h b/plugins/plugin.h index c547c5c83ea..7f391329bdc 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -68,11 +68,6 @@ struct qemu_plugin_ctx { struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 25915a93242..3d8943cef2f 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -439,15 +439,10 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - char *ptr = cb->userp; - size_t elem_size = 0; - size_t offset = 0; - if (!ptr) { - /* use inline entry */ - ptr = cb->inline_insn.entry.score->data->data; - elem_size = g_array_get_element_size(cb->inline_insn.entry.score->data); - offset = cb->inline_insn.entry.offset; - } + char *ptr = cb->inline_insn.entry.score->data->data; + size_t elem_size = g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset = cb->inline_insn.entry.offset; op = copy_ld_i32(&begin_op, op); op = copy_mul_i32(&begin_op, op, elem_size); diff --git a/plugins/core.c b/plugins/core.c index 10ffdf6d938..4b2b030d76e 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -310,22 +310,6 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); } -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, - void *ptr, - uint64_t imm) -{ - struct qemu_plugin_dyn_cb *dyn_cb; - - dyn_cb = plugin_get_dyn_cb(arr); - dyn_cb->userp = ptr; - dyn_cb->type = PLUGIN_CB_INLINE; - dyn_cb->rw = rw; - dyn_cb->inline_insn.op = op; - dyn_cb->inline_insn.imm = imm; -} - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, @@ -488,15 +472,10 @@ void qemu_plugin_flush_cb(void) void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - char *ptr = cb->userp; - size_t elem_size = 0; - size_t offset = 0; - if (!ptr) { - /* use inline entry */ - ptr = cb->inline_insn.entry.score->data->data; - elem_size = g_array_get_element_size(cb->inline_insn.entry.score->data); - offset = cb->inline_insn.entry.offset; - } + char *ptr = cb->inline_insn.entry.score->data->data; + size_t elem_size = g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset = cb->inline_insn.entry.offset; uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size); switch (cb->inline_insn.op) { From patchwork Tue Feb 13 09:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 772284 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp169465wre; Tue, 13 Feb 2024 01:42:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXPtq9qC55l4NBv55QlP3BieYeIeSZMfYLdksAVnSALDyGGJ0BPAUWRs3XNmSR/zLFmsEube1yhzgppbCPtmpNB X-Google-Smtp-Source: AGHT+IF+hXimd4iJNXtCXyoJdp0Id36g1wDfN1kRXhvO9Q1D0ot2frQB3vQEYQ9vMR0ZyzlO2qb2 X-Received: by 2002:a05:622a:4d4:b0:42c:46e3:dda4 with SMTP id q20-20020a05622a04d400b0042c46e3dda4mr11738097qtx.18.1707817376992; Tue, 13 Feb 2024 01:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707817376; cv=none; d=google.com; s=arc-20160816; b=MBw7lqFMJR/M/qP67DdbwmLj60ZRLGqSrLT1ltngxaE9IPGGLMuKfppZX9XfAggZXX iQu+F5yQ+m7GGsafohhtqjjgasTLtHRJTYoD+SYerbvq0F2HqAtdYevI8CT6OQek53pj 9FOscD7tf7V/yeWdD70z+img+M0d9Ph6SGv7KWoiYgv3OtoZjqyXo8LoTfMG+CM2tALC 4uzigadroPRGAEvg7ZaIetuNQ4PasHWY5v8OLIpHk0//0O6reuz4gYMgtUCBFYc2Gt0H wKYBiOCzak5qENRRL/dMTuWW7zy2A1FN5bkXK/aQvV5PspHZkvU1Hil69s3QhmIqQ5bV st2w== 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=9D4k6QS4DbxEf/czoo6ZOLuGzDbZtd2vzfrrW34BdNw=; fh=aOKQ0oZkR9YFUB7XS9NB4Oc3hR+4WhNVIgRBOG2mrGc=; b=TX3N8ZO0JHjmzCY0Z9GV1MSWIYPaumTOL1/Ga40OpAY02N/pGzkdYIn2ZaPkcOUYwx 7ewv1ZKrD7PkPDIBD4vGMlEGe3zeI6hsm/ys/tBcDAHfgFE5HUZER6AnA2nvq+52RyWF kHsOlDyU+8lZ4dtdM8d8mfCLmUX8CShoZKusgqpVzeQ1T3rYx7AvSbSQh7Q3pGKKB06X cqjcDpxZ9LG9RTlp7Skl59fJ9zB3otH5GvWgjKfwoIHWdUN7MRE7QKRMkpbZ7HKahoFD NOqhJWoPY0y7CmM4lyFo1Lc0S3/ZZf3Mcjvr285Fe13tgFs1AuFiwnZ1aTMl3Yeb4Bhy d0Yg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HQ2GL0xm; 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=1; AJvYcCWTuYhrSZpaRUbOI/Kmk52rTTd5MklgeuH82f3Y+HgR/CRggbqlqxoQMtEmNZXMSCxzt5KBgV+/JcVRdZb+gjEh Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y10-20020ac8524a000000b0042c721831f6si2246874qtn.234.2024.02.13.01.42.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 01:42:56 -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=HQ2GL0xm; 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 1rZpIR-0001zk-0X; Tue, 13 Feb 2024 04:41:49 -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 1rZpIJ-0001xN-Ne for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:40 -0500 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZpII-0000JZ-3A for qemu-devel@nongnu.org; Tue, 13 Feb 2024 04:41:39 -0500 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-51147d0abd1so4661564e87.1 for ; Tue, 13 Feb 2024 01:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707817294; x=1708422094; 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=9D4k6QS4DbxEf/czoo6ZOLuGzDbZtd2vzfrrW34BdNw=; b=HQ2GL0xmS6dpzvNG1zKMXH05NUJyj9M587S0cZqwwnS3bYWaSDCd0Yx8yqhFXTreDE PFMCosJBsUjZ+ZCKJUoCOWJrac3jHz4UId6jutSz8OJS+MHlaplPgS5MCkgysw/m+PvB 5V9a5+Ps8QgmPNHc0e4ljzcfNNmlaMUhh/cGULomRXJHx641dX4+PH1ToLeXmy2516pf NTLCPvWY9HhvzHAs9Cx+N9pk7XwCTedTQON2trXqNSZuWQUwkwI0nwayPAfMvI1mqega 1Yc4IrGIJRxZMehYGdti5oI2JcDBVCWPOsq/7TVYalZ1hA2cAJazK9ZoA6cyfkaE4Ei3 BvyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817294; x=1708422094; 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=9D4k6QS4DbxEf/czoo6ZOLuGzDbZtd2vzfrrW34BdNw=; b=JKILGcEE5gNEArgXfXB2eWfQxA0aOddHUrifDdbV8caDkpwkSxPN94BTUMCg1Rz+3e 3REHMLoG5rAmFr/TT7JDIXJ6b1rHqFPCkJDcm9I5r7VRLaisnrJfnEViEde3mnWW7y+0 FxsmAyLRuG6uhdesH8bme3Qhc6/SxYBflT6N2US5cpj+sWEvQU6oAEo6i03VW0DzsSG9 CGzr0/L8njWkms2faz+ymAYubFPKRdiFsn/1XJFncotTg/JK0MKJR0qiFhf3ySfKvr7a SEwFcoQDdG+y9T4kmfCNnh7HO+VmRl9vsLWlTU0Y3YIUZ4fymVgTuP5CuFBOGl9GVk7f n21w== X-Gm-Message-State: AOJu0Yw2d5gAZ/EAVpBQ2a0O0pq8LODZP1ffm7lsJYNZNrXLDqRtQus/ +vBbvSyXdu/u7GG2+7FccKRkc9QdDP7NcvvlICntKS+eStzumqV3aQz38szzN3x+RVBVbvulOSF H X-Received: by 2002:ac2:4288:0:b0:510:323d:6402 with SMTP id m8-20020ac24288000000b00510323d6402mr5717195lfh.45.1707817294222; Tue, 13 Feb 2024 01:41:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVfFrIXxKlxXokUE35s03grQlHknVsb6DsagIwUeZbRDNEM3CxNFaKCK52jurF+VdXOulH4H+0vl3FQ8WVFg7e/uuhrYoFUxkF02DKYmtBk7OUloSiPoW+1rVzlKaNlkkU4RbbA4Nb3RRNtmtp/uNiFDsuVJxPNVPtOUS3S0+Em9yNDHGGTsKCNuxAIHomMRR1Rh2tJ1TgtHj/pBAYO5AZzFFXzJX2lSdanPKNvieAmb4RflXVFvjq457WkFEb3vvNZw3GIOgz6VFVJW7LohBAv+22rsEAGPEh52vbQY7r851D0cF/wO5fLUPY2EOmnof7uk2vY3V01wkp2SToZAatld3+XDw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0033b728190c1sm8550261wrb.79.2024.02.13.01.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:34 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v4 18/18] MAINTAINERS: Add myself as reviewer for TCG Plugins Date: Tue, 13 Feb 2024 13:40:08 +0400 Message-ID: <20240213094009.150349-19-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213094009.150349-1-pierrick.bouvier@linaro.org> References: <20240213094009.150349-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x132.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 Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index dfaca8323e9..80528d3dc63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3676,6 +3676,7 @@ TCG Plugins M: Alex Bennée R: Alexandre Iooss R: Mahmoud Mandour +R: Pierrick Bouvier S: Maintained F: docs/devel/tcg-plugins.rst F: plugins/