From patchwork Tue Feb 6 09:24: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: 770378 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196252wrb; Tue, 6 Feb 2024 01:27:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHy/AzHwarclRdlxlWyITDId0FBdcyZG7ZZW7HuAG4A5MNodX/JcZRLtlkEdEofB1I12vV2 X-Received: by 2002:a05:620a:146b:b0:783:bd6c:90cd with SMTP id j11-20020a05620a146b00b00783bd6c90cdmr2114802qkl.19.1707211648528; Tue, 06 Feb 2024 01:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211648; cv=none; d=google.com; s=arc-20160816; b=HSg41NutXC1mt/q2H3XwdYjsDcRawLaQlSluGvyqbNnlzaR3/9HNSY5RLzwnGs3Eq4 SN87t41nTKayM6nlhgAj/altsNgUfwvi70uab2OEsmzyGhpyHmnKfsE7ZjLXSEL0GICc pbSihy5TaKlum9GSIbK5yejxfba7cTmKhlk3jdCxXTFZLJzixt/0InfQ12lX++byVMnE lfaW/oub+T28tCG9fyDeo8Oe34Nd89OrH5mqE3YRmtSFVkqLmXQ5BBY+l8Wr88UEBl8K uHbAzs3yzDeGQlkxKZEz2jaklcBT9ZPCTX/sWuWlgR34khh8gHrMHe2jARzzRJqKxLaP LDNQ== 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=Fd7k4/+baDPstKHFcIL+1Z1MgASvzWdo2AHRV4mfzes=; b=TwknzDcSxj83rVf6EoihRPJxUA7Q2FyMP5R5WPfnvOv8o4xNjM5hI1e3+5jraZ9uIj F/PcRFsqmsIOeRuDbN6N8YdvInX5ekIH9Kk3AlE8Q8JyExJgSMIFraOKzlIAW8nm6oK0 UcPmUL6kNtcBxgGrnyy5oz1hZ1vzm7CQF0QzhqV0sbSmbW87TK6Sf6NP5eMhw6UK0AL6 gNLP4qInbEqK8rIiaw4SkkSPCsWfnlBF8AcpIXAA4jB8Xdn/ZMi4PjIaDwXL/k8MATyb rpmpPzX6frYfMtXcay6kSsMUTOCAfu0F+HHQCH78UbEZf3N84U8TUYdXTia7TtKS8/tt 3JIA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=slicdj46; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWaobEAn73Dm5f5gnrtp5mU3IGLlA5cGh58DB+7TWZNQxOOrTcq0kMpaD0gt/0EdV+PbeXaP+3bTi8jj39TjCCj Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p24-20020a05620a057800b00783dcb0b5a3si1818020qkp.608.2024.02.06.01.27.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:27: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=slicdj46; 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 1rXHh5-0004cx-AM; Tue, 06 Feb 2024 04:24:43 -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 1rXHh3-0004bb-02 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:41 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHh1-0004kX-6s for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:40 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40fe2d3d5cbso3069555e9.2 for ; Tue, 06 Feb 2024 01:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211477; x=1707816277; 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=slicdj46WLpzASEsqejrWUXQEBz7dohFkXSJw8KsUdc5EGVRXARLBs9Sls/IoKlFLe 2EwvPi3xCay63wK5ZCw7jHXulMyiUkgsS6AHjKskSF6wiS0O/Xicrd5t9pxKYn+BBc0H KqjIdMfxXMjFBTd7dwPyOmhbMU+m/WFt1y8LD6XvFn8i455OqMoDw0VRd04nODUVzk+l M+6cWsXVO9X5eXM2N6cVd4gPTGM8k1tVxkCe2ux2WVybKX7e8owep+IctpahewIPCXrB VMtvAUvz6QbVaCwbKZ2oIYVOi8DEDDbnYZ2xO5dQXo+X3A4+VJ18/vwhCd1Rd0O0qSvP zHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211477; x=1707816277; 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=I9QcKV2koWvA+YFLoSmxEWjgRaAriOyMJ1j7+5KbNcpLIBCAhpRCRkK7DKiIx2J6WA Or8JWfhsvC4fe9Bg50QFiONjptyZw4jTCf+hWPGYJSDTt7SmoCYCpfDSKlRQEmuUPd9R fIxsZ7f8022elq//SU3VtoPT24QJRVHh3KzkVjvoqbQ7SVTBIsvfhh6jtYicu7BsZTnK 5Pkzc83fgWt8/AUQiF2XJXpE3YbS/GP5c1GQi+L+Xp3fvivQ4gOnrcNSOXfGi16QGcly MsR2CWAlzGbBLW+snpnAZfAnIpr4GCt2q9Lp+GaACP/aCCLJlvF/jkRISFqQapXltkyL 424A== X-Gm-Message-State: AOJu0YyZ5kURfa48DlR5mu0AYIYJfIDd9pqqx6ok1vVO/D2GAvztXeKs gSX/Kb8TEIlgb95CoQG+ZB7QsXKrFzl7gjjws/h7gzsP2TSi1+WuOZiCw6fo+PLArOh5Otx9Hsp s5as= X-Received: by 2002:a05:600c:4fcd:b0:40e:d2da:fc6b with SMTP id o13-20020a05600c4fcd00b0040ed2dafc6bmr1719988wmq.38.1707211477459; Tue, 06 Feb 2024 01:24:37 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXBnk1SOLUSowyBb+G/8ptWtFV0dXinU/A9ascoqNxK09UtRIN6La8DR57nYr6numsiNm1ApPzzRDgjcR28P17TXsAOkV5/Y6t+SpjcrYtuQR8wPpYAqT8IuvtcMVJf7qluQTDiGsFK6FHodR4/W3oFd4L5nSvXOXZn0BvjS/+WdTKKbG8i2Q8GaTNtnkufC2N4OdIpEBQpKMX8pfbYuG3VHaHjVQFXWoAxDMyypIagdEaUTNz4h3P2CUTRlQNtL5carar5BKahIWiZ9r56JtfgkS0nWTRXl17KWh6hn6pzn7mIAa58+urwMvY93F5taQz89/OMhD1F6nTmrAhTeZ2gHZESDGk/bg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:37 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 01/17] plugins: remove previous n_vcpus functions from API Date: Tue, 6 Feb 2024 13:24:06 +0400 Message-ID: <20240206092423.3005995-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32b.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 --- 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 6 09:24: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: 770362 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195694wrb; Tue, 6 Feb 2024 01:25:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4iS5GPge06cz9EF+eWp678esSxYBMbN52Kxl5tE1amexNHs29Td9qJ+1HRG+SoZRWFY/f X-Received: by 2002:ac8:7fc4:0:b0:42c:3986:d752 with SMTP id b4-20020ac87fc4000000b0042c3986d752mr259795qtk.53.1707211523565; Tue, 06 Feb 2024 01:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211523; cv=none; d=google.com; s=arc-20160816; b=BZZGSBvTkrZyIBPvFHTIkBZDetNDemaZBC70v8BkiLOi9STaQ7CLx/qOls/vLIQY1u fFolPN8yD1S044cRw6WDe5oG9VOzJg1y5ns8Ipz94GP7sR2xlIYEZgRB0T9CX+mBuZOV GympMsnOPmwoDcPDpJ2Vb2mVFnFK3Wevug93CaK8EJzt3fHuOAYm6HfWh2NMRaj0txVk /8WbvAw/TItcV6wSg7aesK6ZnVJfBB5ekwTHL/GG73HrwSef0yKb8/wn2vEASbG/sfie egGa4dUM9+Z4BTkODvksk0YkOAxAUi/nT/sPDNkvZkdGySpeP6iKkqhptOPV87nj6pHn eD6g== 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=F5+CXODo+z0ZEkqNBB4zW4G6zAstbTiLdQHgyxA73wY=; b=i+ZgHH5vXDx3Fq8Lc3ms4TxvGcfFJ8HtkmI7PU5oqbrdYuli4nTgA2a3HKICOpiqIN J0bM/HG69F456IKkNZRTiti0kRWLzesTVw6BXyPlXo9zrFnABrVCa4jTN33TX9M2zYpK yuKPKD41c/Ij8zy0jvDfxVtzSEIz4kmdT2ZfxuaQ8KuiluJ6+ne1BisejhFF8DfUPY8m jZABAcUaZb955lthEdpgvIo/sSTxGphDvEfelI9b14mbUB8ICAwR02CKGbFGzPvAmjAI SwgF+UMVqlcbWobawIFpVkM5aXbPLbwO7a3WwBoY/MRBDbMlE+aUi7+sUSW1E4IuwzXb POfw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tg3htUDo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWTDxPUVo8jRqK9i8mLsFRp7PLPf1sg6jjHFTBWCpUPSyH+q2tAKYj06gWyhDS09FbDrQ0yvTY7qCcegkxJ+ueu Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p6-20020a05622a00c600b0042beb9dfae1si1985848qtw.35.2024.02.06.01.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:25: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=Tg3htUDo; 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 1rXHh8-0004ds-67; Tue, 06 Feb 2024 04:24:46 -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 1rXHh7-0004dE-4r for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:45 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHh5-0004kw-En for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:44 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40fe282b8e2so3433825e9.2 for ; Tue, 06 Feb 2024 01:24:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211481; x=1707816281; 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=Tg3htUDo9r92+5gZeugfoI+R2AauBsIDVelezMWLoZSPQZ0ubQ5vTVikE8fWadclLf lPlYFNtlxfbwTAsCfT6LEetsPzkfqa3BN3qwfRejqLB4HTa+BKzbJwPbkmgPExk2sfWk DJYGYWKNmZM6uflP7HKwq/f6mhc4hDZIQsfjAuRWmFE0kygQkQS8gOfvXO4/b5fWFVbH 0PBXU7bVOCXsekqUxgt/mh/gQTfRvRzHs97Zp2Ue+YJ8JhyPPjg1cnPwW2eCkPgBDzEv +BSXsGp24w02LS83B2o9+88Bm9cpze1dP7Xwq9L/s8n1K7GEbyINNH1ssU957cG/oTGS CGCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211481; x=1707816281; 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=Comb/bjAOrx1OWzwZwXqzsXV24XmnE2Q0AdK5IdWiJ7Kgaq0lXFPwNyx17m1oVpoaO 1xPpLjQATLfl/044Yqwr8DJkto2dCW85/bL1UGiaBEz346P4hanAfFFQ9r+3mJfdUUyR lHhIxyVuiooHJoib4IDrdRRbzDAGhlZfvlBSGOXx5Xity0gcHa7OHPIS7O8u78QiCvxd fj4PK5sfp9kvew3joNfB+SAhS7ACGyWFZpciWQKkxHpbPVSGQozm6PtsOLpx2NS1XETq XYsN/2abaQIHEJgDcsmjNtFazBAoWLcfSb46v4bCg0DZE+v8yRaNzFk8yH6Ru6IvmItH DyAQ== X-Gm-Message-State: AOJu0YzQ3J+zxb4UDgav12M820ZZrNvHgUs1zLDe9r4XeCf6QWMG/WfY Tz7JlAb5heeUJd1/oDB2kx65WP0pVzAr9tDPY0x8AnWv5FtnuUo4j6iM/XWrKQnFiBn7JVDMz5S R4lg= X-Received: by 2002:a05:600c:3b11:b0:40e:fb8f:76b2 with SMTP id m17-20020a05600c3b1100b0040efb8f76b2mr1227643wms.12.1707211481006; Tue, 06 Feb 2024 01:24:41 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWAdSywLF8zYD6TJZg28zqfmrAJ/ySRwUTjBTDZTJtNtCSoKxH2rEmjDqha6JfHGZ2evLeoPZxSjnd4dMnOTLQgu0czccd2qTX6nluMML0q/PBvZEAnQSBEgUKFuqnQ5rz8LDik4gLkw0ErFL9VkNWUzq6ZK455w3ueRZ1zOQZYGJUEvGdWPaCbqS0LNxGuhxauYhaSYkRVDdvCJ2w5gUv/FErVeWgrtoS0afbfsBASdfl3A9rzICOowTjd6BtOKbzpTMwOhRzNpidG34KP4k2aTShyBETcpafBA4lRnSsJFrEuYPAMrwB8D76wkCldqxkQFTS4oyp+IBaxp761ysMs9WIg/lcXcw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:40 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 02/17] plugins: add qemu_plugin_num_vcpus function Date: Tue, 6 Feb 2024 13:24:07 +0400 Message-ID: <20240206092423.3005995-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 6 09:24:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770363 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195718wrb; Tue, 6 Feb 2024 01:25:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHu4gl6vpo+YeI2ToOG11AlVZ7WnoCdmNjd2cRanAnEYJPdIRqkjM4sKgissdlLBOeEp50F X-Received: by 2002:a05:6214:5009:b0:68c:92f4:9161 with SMTP id jo9-20020a056214500900b0068c92f49161mr1825306qvb.2.1707211529333; Tue, 06 Feb 2024 01:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211529; cv=none; d=google.com; s=arc-20160816; b=QEJk8m4oy1weN3ga1xgq8afszRC2K+xu9XvY1UaBF55X07uim1nHElhInRgTZ/QQVl oHh6cHgo79VFokZ+SdZxI1YDOYIcRB7VYaaMtL5rBSsAp5wlJpLZf6Tm68+4U77vDROJ P0NTKiSywUAMiHtdqDlCU6ZtEb2a0/Nd3zgyzCDv9yqbisST5nUxOL0I6Yvst+BqSv7Z lD6YivQG1gf0lnOUdEW86v1xgV6tA5r7Uwq1lkS/2l7Gf9+VPWe3zEnLZILngCXsp89B gvtVkUKYiqahdHAW8zM6EyHAxMfDZm83zzgq4XnDJAtSRlcqCtuF8IMneyr1j71FvvXQ lxeg== 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=OOjCHa75MANot4L1VfuMEJ5mVel7QNiDk7VkpGP0Ccw=; fh=omnlZlqFEXpMhvFhKqw1/ENYbkAA28eavvJd+sidOtA=; b=ZeRznMhC9CTNOyfxW7hLmsQyPERVOfpfnMJNdduD1Wyz453AOHc6PY/u84SMj2HLKi 9zY7IcRrp90C2Uoocmzdy0Y2lvUIKfJ9O6d94ikUiqEYzu7QO2Kjrd8MSSP/5Xr+WpzP AWT5XcLInj482aFyVitNeiez9b2hhR6tlxE+aoGLLHKmTXH+RJLMvYF/9TgBD0Hd3YLN mOy5uc8cJ8pJwGhQ9S32yalC8IunS0LOpo7aT9oSKpq1lGu4uLThwdNEc0BEQDQahcUp EQEz4GpNrVr3gZJmf7VrciLFEeIfU4s4xBS/Qb+0JbBfXVk09fdHF+QJczgYIucTUGrU Luiw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SGmSTl5s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUboqP/wTizr0ChMQ/drVkW9oNt+eXYoBLf/LaxXgel0Um7Uj4DtC/Tqwt4cuUkyqQqaSkBQ2bh+u6KkK0JlnRy Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p1-20020a0cfd81000000b0068c8c3747cbsi2028800qvr.72.2024.02.06.01.25.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:25:29 -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=SGmSTl5s; 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 1rXHhB-0004ee-S1; Tue, 06 Feb 2024 04:24: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 1rXHhA-0004eO-9y for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:48 -0500 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHh8-0004lR-OT for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:48 -0500 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-51117bfd452so9043676e87.3 for ; Tue, 06 Feb 2024 01:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211484; x=1707816284; 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=OOjCHa75MANot4L1VfuMEJ5mVel7QNiDk7VkpGP0Ccw=; b=SGmSTl5sB4hQSkBo/ODYgfltAy6KXXmSjomiI6meGAY/rFT9fRs0vu1jzUEDIKgQVp 5SxbFBvaXFqTJuGymzZzDdM4JqrNtKIcUHhJSx++nyKDVmLCkdkEyjfTV744f2sTRPSJ hRCjZTCjDZ11987CnZ1E9/1/l/kRGDWuKBJJvHDYFiZWxZhX+0Aua8SIFgV7zz0Oe3Iy zUa+wAksjqZq8eb0hInyB5881AH4o2T49Z0ZQqG48qIkpjcyigFNwgz4gBDP0tCHlF84 +QeC4/kyINnU7SDYTixq4LvXD3aeJJa89PaBGpVbBYTtHdAxC8uTo+cxud1fQsMkmJUH 3A8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211484; x=1707816284; 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=OOjCHa75MANot4L1VfuMEJ5mVel7QNiDk7VkpGP0Ccw=; b=TsYQHak5XOUjh9X3ET+Ui3I+Sl+Bo2nFRlL7B55JwgHqdYZo9Oqbzo937o4EOvUOdo cLIVbQX9ZhY7Q6011wwKjoVHvPdCSVvX03xQ549Cil4rh3BcUiZrpa0PKiwCppZ9D+za BIQLBsieYYKPVHxYf47lbX4CC8hDeF/z6xfS4UM/2bhK6a9WJai2J6jvV1pQupmFQms1 Q4Q+TWmcz7ypfOkpHuCU69m/RXgLvwgpRgGSpk4195qgVN+KF7/mDyzkcHR7bmauHZC3 yQ6WOAqUgxAQN6onnfZCsF7vInnZbzaXzWe/Aoh1/zXzS5iBudLxhbWk7WyPHyOjca8C 0AMQ== X-Gm-Message-State: AOJu0YywUTJqq6IbZkvCQHL6SdFzZjE/Y25BgApzkAEe12wSWOEZTdiX b/OuhzTXBkllZyBcOa1P/0ogyBnN+nr3DRte8xPT36tDqJDqBEUjEM2Whe6tkL0KIFvMfArnYD0 DJI4= X-Received: by 2002:a05:6512:2354:b0:511:5e6c:c021 with SMTP id p20-20020a056512235400b005115e6cc021mr934899lfu.36.1707211484482; Tue, 06 Feb 2024 01:24:44 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVZ8XsdngNyJzoHXkiKTJsXFuDTeOcZ8IzLx+j3Yq4L7E7SYmOfiEy+7Ea9tR+kBft088hsB3P2KfpUgjO4doJjwVnhrBlrqUWudJwOmbMrBeAz9pTZc0u4Anfs4zj3PyR36uXBMH4RluO2J1vG0RfKwaXdA96L/NcUir7O5U3S2UjkY7Zcxfp6zfuTtRmr6jlZGNcFGzGVUszXJ1rm8nRmGy6y6+bcaSHuA9mYnrzqQqfusvQ8KmgaB8Lo47Hm1rVQncJ9yb26Ob4dKZtYZbAQCgPjK8cofei/rkQf+Yry2v0+iKOCpwX+TSgHUKttRvXeEf6zSQ6LChDcSrh6fN5OU/S5VmN5Lg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:44 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 03/17] plugins: fix order of init/idle/resume callback Date: Tue, 6 Feb 2024 13:24:08 +0400 Message-ID: <20240206092423.3005995-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x133.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. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- 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 6 09:24:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770370 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195959wrb; Tue, 6 Feb 2024 01:26:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IENq3+JNQzupPbKiqjf4Fz8gcQGT8JBBAnTEceMt63SGLHDanDYSbY/oViRgpc7iFcqQqN3 X-Received: by 2002:a81:7e45:0:b0:5ff:604e:2bf with SMTP id p5-20020a817e45000000b005ff604e02bfmr908969ywn.18.1707211586519; Tue, 06 Feb 2024 01:26:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211586; cv=none; d=google.com; s=arc-20160816; b=Kgh8QEpvU9xBkj192v/KOQ/OVffgyjPC11WP9u6bFVrxLtrExYWivtLPGu1dyz2OPR BSfO+QI3wU0jIpNeaYXDY0Vy7Tq2uZMZbIqdFv5RFO2DLpP3qwgh1IhIP8pW3ngRfrJg UEJY4p9vOt18M7l+vBbc5sjN0GIyGe6jeivcMTRHkQIylnxvX2afgvhuI8YQeMv6p3Ue luCnnkjNv6rAWsSbDwanRRm2iDP7mac0nSnq5mwgKtgiJ20QxjSPfBvbKiGGG/lDNdaY 02QXBTjtSThQUAWISKzL5jYAigYaNbYTig4w4R+XYVfaXYO53lGHeYQpXfb/cojmms+M cIqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; fh=e8FPCRZZUQOuk0A5nAyvsWISKYwcx9/rSKFSKKQSsfI=; b=TZ9dHI/Zx/BxCqGbgZEWPxDygHXBQ6d/7Fd6Dy7ezXNVpW11yNRJhqItX4WUQBjBsh uZaSGs9G2I8K43sC7WDel5Is+mHu6GK+0VXK0TM9aBJ3mhVDFMJuj+y/LNFe4h3g4DSU /r+xQ32yCYiekRU1mL7Kpro8xvcKJN3JkupRGHLW03Ee16T1PsTixuVYa5N3Jn6DsQQ8 k79C0xV4eIhhJNQSXhnxWBXR6u8V+D+/Bwml3dhLjWhUuhBdeg8oSeTO7i9y32Pa2dFk vdRh/IN28yHuG+W9yIbgSBaMQ5BaPCS6JN/7p1Uicr/0OVYsDc1enpqyfZsfpqAikFNk E1XQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAobvPOr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUeHuRl8vZMJ6akRY0fCMtdVDUvQwLaB71HT67WCqkGrVyTQ+IYJgyYJpGZgTBdbHt6whVHjoPmT7NUphhYyv1/ Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5-20020ac85945000000b0042be7c435casi1960440qtz.763.2024.02.06.01.26.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAobvPOr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXHhE-0004fE-D0; Tue, 06 Feb 2024 04:24:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHhD-0004f3-Kj for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:51 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhC-0004lm-5B for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:51 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40efcb37373so5295055e9.2 for ; Tue, 06 Feb 2024 01:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211488; x=1707816288; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; b=BAobvPOrSVLCqzZs9YIojdLcNYEo4qrpzC+1ku9rr5vEv/VyPztINsnBqwzPE2hnDl 7JBoltfa6MYoD2hOiGruNUFVFPGl1bdNPQVpcaMdmBKS61nCGo4FeDLDzUGIH9PBxr6x CnY47modg9aYM0+KRKbFfIw+ywp3/NdK/v13tO8GV8Twsk7lVhrOcMxLdvlzCbDsILQa EK65ZuOu/bsw9qaXi5amyPVc0sOsDtbXyHyt5pIH43GbofN8jzTl7IrLOjT0e2oQoBul Ji6oBJJsuW4i8ZpZ/HBuHZISUWQgPBqjUyC76YYvB1ib/m3Q9yFyQArfQFpqhye0V/zt V3AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211488; x=1707816288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=URZi/NmqB9fEf7SSooAoQ9VbUa1hGL9MClMwYN/jkYI=; b=icJAvQkU3ZMNzZXC7Beu/dojVJbjkg1PXTSvtP3DMEk3EglMkRurjLk/6A5uLKi5tJ FSfhro5u26yDvpQ49ywtDXccdKjO4vCLH3Ga6VoYZMXQsUTWG2YR8HBfW3ljlgHc+Eli CLNljiBxY/QKRXyxPi8PQfoHHqjcqURAHbahoT4l0VbHEM5BPD4kNFxNXAFeMn5TeCIm UPNLl7B+2RuLDaF9MGfpY0DwVW/ELZI9haitcuKLkzB0KY/rYauTD810iBLQc8cRwwdc Em4Qj3ijHHaHR6qlJyqsr4Vo1o1KuQ5eoX6UbvaQt9jEOIeCFvmjK/PX39ViFnSJkiaf 72qw== X-Gm-Message-State: AOJu0YznanoPqxRNE6jNrK5iFBPr0fTNHTwWjqsJ5NOELAXWqWz8QkE8 vPvY+LQKg9MyRfeOARXoQwKOTaIquM957WFVblh0yTTHWvL9Sj6btTx4adpMpS22LaWo4P1TqFv yysI= X-Received: by 2002:a05:600c:3581:b0:40f:de6a:2a27 with SMTP id p1-20020a05600c358100b0040fde6a2a27mr1649274wmq.40.1707211488060; Tue, 06 Feb 2024 01:24:48 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWBDcU1Ik2599Slt5Dh5fJWg9XnNYFiseY8sQ7UJfX+CKhPEA6t1dMS5F/7D4DTVDxSf+6dqhEOhmqHfu9BzZMD7pJMmmSjop9BAll3gYvMTd03XlgRoYvzLo2nqfTZpF73AYfO8lwlCRSdNSfDq3thmlqyQCXukMRWuHjbp6QDZxbQNd56sJGKm0YP/ciD2Z48VqOdmfRWHClC3Z5BJVfpvbR3+XeURcRFHKXG8SL3Xj8A3r8KadR8TqlIXV7sH3AcPb0g51DCfVx+BiL6zSjNEZlndvTjC1VVey5WtTlnyhIkjCM5Hj+O61liJl8t13rYDbcZJbXYwqictDEy2GNvWaJeKbZIJQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:47 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 04/17] cpu: call plugin init hook asynchronously Date: Tue, 6 Feb 2024 13:24:09 +0400 Message-ID: <20240206092423.3005995-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This ensures we run during a cpu_exec, which allows to call start/end exclusive from this init hook (needed for new scoreboard API introduced later). async work is run before any tb is translated/executed, so we can guarantee plugin init will be called before any other hook. The previous change made sure that any idle/resume cb call will not be done before initializing plugin for a given vcpu. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- hw/core/cpu-common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index fe16d0d9df8..68786360ea5 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -194,6 +194,11 @@ static void cpu_common_parse_features(const char *typename, char *features, } } +static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused) +{ + qemu_plugin_vcpu_init_hook(cpu); +} + static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); @@ -217,9 +222,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) cpu_resume(cpu); } - /* Plugin initialization must wait until the cpu is fully realized. */ + /* Plugin initialization must wait until the cpu start executing code */ if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); + async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); } /* NOTE: latest generic point where the cpu is fully realized */ From patchwork Tue Feb 6 09:24:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770364 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195806wrb; Tue, 6 Feb 2024 01:25:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKJphjLjS/0pDlL5hppdlHwPsnnVwTO/zyA99MIHj+I93R45OH18eC6dECOXp/WAh0R9X+ X-Received: by 2002:ad4:5caf:0:b0:685:3e78:8723 with SMTP id q15-20020ad45caf000000b006853e788723mr2413723qvh.28.1707211556421; Tue, 06 Feb 2024 01:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211556; cv=none; d=google.com; s=arc-20160816; b=lLIVYF4ACQz0Z/GMbKPMvzhLZmOeFgmFDD/kaqyRubrkjh7aG+L8E3nFOy0L/PFavV L2qHwNnMCcjIMsVeO0muyrQnZPneux9Cl444U8jrxj6oldKDlZNVOfJIpgsVx0SFJx7H KPq68HAijPoKYENsjJXGrTtlDh5cAW3TszmkvgqOp53FPGbmi/Llb9P9yxerAJ1R6JiP 2nmjj0XaB+T4WZ6ABLwTsoYuC9igfzzHNg9lZfh2WmMISz8aJfKMh20jzKK+U2+KCDkQ 64qBapJS8uj4roF+z09NKdS9mksl1/LA2YXaRknSkF24FSqz2P4Abz3tjyxxK9I9rEFC Ie0Q== 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=RqcOdG+TO25rW2RA/w0FgjbgxpUpC13Aauz7MMRyDks=; fh=G3ZAPOP3BIZtmzOK/rBLRmakw1S1LzhSwpG0I7C1IrY=; b=XSJ7mM5Vma3/d6Xe6QWzV+8iEcPP96WWBheiZB13+Tvk81uBSsKUvhw7fkyDdzkn16 Q/ZB870rrzhyZ/uPgKKXJMZ9qMLnEKJkcoDp5SqVcPQB9m4dJLkGuE3ZHjPVpLcngXbI WTCvjE/hRinPUJ71Ek2nnmitcn8AhnEtqmPCTzoUoGaMO2gII8iL4TQ/D24F8wef0zfH ccx5H6a8DJOI7GZl76ODhCwjXTc1y8TnfRl2j54e5bYfMKz1pROTEKm8SRATsicPR0km C1rqLnI5mgoLwGIte89zZAch0aQSbPb0wvrcEc80XZyqWdPyIBZPm8NSZKGzIW5sNMzR s4og==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnqsRDBO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVNa+x+vQrVWyqgEyAS0PngwWDNpCgAP6yw+iWBu/iqKSf5vW0BVXbxgw6rvPWlM99j2Efisn9OyjYUQuMwObyU Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id df16-20020a056214081000b0068c5562da8asi1884168qvb.215.2024.02.06.01.25.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:25: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=tnqsRDBO; 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 1rXHhJ-0004fz-TL; Tue, 06 Feb 2024 04:24: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 1rXHhI-0004fn-1i for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:56 -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 1rXHhF-0004mA-So for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:55 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40fdd65a9bdso12809285e9.2 for ; Tue, 06 Feb 2024 01:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211491; x=1707816291; 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=RqcOdG+TO25rW2RA/w0FgjbgxpUpC13Aauz7MMRyDks=; b=tnqsRDBOErl9j4NhdnKbDMQmZVf4M+scgI3qYxbd6kiZL5GvOrnWv05FCzKFF4ZF31 acEWj4h6mmaF13xR9MZVVu5LSdrAJ40tcKpH+peAqWJKZiBi696vG1AkI8GBy/UHBBRn GiqE/HpSZAugg/pEAtOWO2glvpat6LC9IAbbxnRdLzc8uZO+VETONdBF+xNhE98zzEPT YP41QTn8XRXQnar/b4UXr6WxI8h9s0Aj2MApL7MAi4dfGlFmTgGeIAslyoSwzuckkOjJ 8Z/bCtH1lSY00b8r8ggpiBoNMizWvw2QdsTAwvhgXGTHTtzFn2N42ghWrRXN9slUjPLN EY+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211491; x=1707816291; 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=RqcOdG+TO25rW2RA/w0FgjbgxpUpC13Aauz7MMRyDks=; b=cIuqdKwR3trOQPLzwCnYxJuG+xPwYKAFNBn1gPL+eEqQSkcuiYYusipyLAN4Xms4A5 e8Yyl77kS7XZ9auOJ7+FHuBVkGicvxV+Nlbu81UIFeOqqRIGLn5a1sY9SeEVTvCKBw7A znxh7kWgA23T9SdZE5IqzBxqALUCYYpZdTy9tPVhv+HpGBy255PKU7BYjg+B6GBqcqla azmyc7aZXuNmevmyuMKNBzbtnYAfNdxxsckTAiASu9dXcLc31RkxDf0ZdrFebuRYOxA1 J1wJOOYXuXV15MuU4HuuV20iRMgxeCTE56hynQ9MpaoHdcr6444DrGYUY5gi69MVzQHn w4Ug== X-Gm-Message-State: AOJu0Yxuc6b5oIR8dIReQTntdH3u98BZ5LwixR3urtp6GdX0u2+3ENIb 2duBHNWI98gMMwYusVPXOzpC9fozkiDg3+SN/zFq+P3JS0t/zpMNukh+k1+yhETp6d5OocDs2Ke t5Vo= X-Received: by 2002:a05:600c:4691:b0:40f:d84c:ac68 with SMTP id p17-20020a05600c469100b0040fd84cac68mr1619120wmo.11.1707211491624; Tue, 06 Feb 2024 01:24:51 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV/H74HIjJSo4WTZq6L0iCE1vPRUOeJQ1J/eEBVP2871sIhpnuDTp5j2MLRQmSA9+dzYvtc+PBD9WqsO6psDKkWaG0di6iRMbHp1/RfAdRFKOy9oBfh00XatSclZC0PyD1Plvrf88tiqTT+XelBD7qaTGR6yDt3ahdlVu5yJoe0MNM7wcnvL9L2Xp2hWkK1/E1cNoXW0Zdwvc4ro3lypHsSWZwoLsu9UoXe0eI4D23lGACxu/WxM50Bhf1tVg9IeMd68yOGn2Os+9VUOft96U+cTt7E2oojUdGbMx3hOJTHziDA4FQR9NpsRaPdZWCs313UPAGrUYLz0zijpVlwzmz7rPkdI13K2Q== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:51 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 05/17] plugins: scoreboard API Date: Tue, 6 Feb 2024 13:24:10 +0400 Message-ID: <20240206092423.3005995-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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 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 In more, 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 for all operations 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. 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 --- include/qemu/plugin.h | 5 +++ include/qemu/qemu-plugin.h | 83 ++++++++++++++++++++++++++++++++++++ plugins/plugin.h | 7 +++ plugins/api.c | 53 +++++++++++++++++++++++ plugins/core.c | 67 +++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 7 +++ 6 files changed, 222 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index b0c5ac68293..af4aeef4d78 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -112,6 +112,11 @@ struct qemu_plugin_insn { bool mem_only; }; +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { + GArray *data; +}; + /* * 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..a48586ef0c1 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -222,6 +222,19 @@ 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; + +/** + * 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 @@ -753,5 +766,75 @@ 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); + +/* 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/plugin.h b/plugins/plugin.h index 00b3509f708..fd93a372803 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -31,6 +31,9 @@ struct qemu_plugin_state { * but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + /* Scoreboards, indexed by their addresses. */ + GHashTable *scoreboards; + size_t scoreboard_alloc_size; DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); /* * @lock protects the struct as well as ctx->uninstalling. @@ -101,4 +104,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..15edad6769b 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -521,3 +521,56 @@ 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); +} + +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/core.c b/plugins/core.c index 609d9d5c184..fd8604bcb79 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -209,6 +209,44 @@ 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_resize_one_scoreboard(gpointer key, + gpointer value, + gpointer user_data) +{ + struct qemu_plugin_scoreboard *score = + (struct qemu_plugin_scoreboard *) value; + size_t new_alloc_size = (size_t) user_data; + g_array_set_size(score->data, new_alloc_size); +} + +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 || g_hash_table_size(plugin.scoreboards) == 0) { + /* 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(); + g_hash_table_foreach(plugin.scoreboards, + &plugin_resize_one_scoreboard, + GSIZE_TO_POINTER(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 +257,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 +611,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); + plugin.scoreboards = g_hash_table_new(g_int64_hash, g_int64_equal); + 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 +623,29 @@ 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); + bool inserted = g_hash_table_insert(plugin.scoreboards, score, score); + g_assert(inserted); + qemu_rec_mutex_unlock(&plugin.lock); + + return score; +} + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + qemu_rec_mutex_lock(&plugin.lock); + bool removed = g_hash_table_remove(plugin.scoreboards, score); + g_assert(removed); + 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..6204453d0fd 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -37,10 +37,17 @@ 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; 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 6 09:24:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770375 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196162wrb; Tue, 6 Feb 2024 01:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKflWi8IqRBn25+18x3i9Sq0gp7T0PvfprkvUtHHHdbjFTs1g83jOwkVvFMwN2i2LpfDcJ X-Received: by 2002:ad4:4a61:0:b0:68c:ad6c:86d6 with SMTP id cn1-20020ad44a61000000b0068cad6c86d6mr4543162qvb.3.1707211632731; Tue, 06 Feb 2024 01:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211632; cv=none; d=google.com; s=arc-20160816; b=zrhcH+AlJyN0KKi8WrZlnJOntK9tFBWfYQa/n2ele/2KlkTNt18EQZhQmWySg+6R03 j8iIVPSNaAHDvBqPBcNKSrDvvsG75Xl5/VRriCyR/WaUxLmv3RplwQnzZiOMi4EkL7qE veQNB3sYJS4LG7GV2TWs4bYHWpOghciPTXpi5XzgW2fkJ2+RmyZcC7HzaXWyyZ2Z/1Gc VEKgvYgfF3JMg7gvB2sEI4cDsni7PB1nodrwTRN71AlVdVv3YchpqZ1Sv7B25FHLKuss 4T0l4H+lG+00RqloDWXR5G/R+LbT0IKAAotwVfSiEmiICCLl+UPSj2zuny0Agbw7cmlc gIYw== 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=nC1j8q1kRwCmMHKayYtgqxX6jxFPMnHDfkz53afBzXQ=; b=vhyQJD0lR6FUNXzwAlD9I4iLLoznFtkggMq5wqmevrr0z+kkp0g/Sl5TI2RMU/lcU3 72J8DBQlgDOSU6K3inpJPxm9397w9f+XLdwoxKU7Yfcqzeg6JRvggPSGJur1Pzfd5lqz eppWXuhJpCgq3U9s0JKta1CQf8hP+JeuDYnKMNmmhk6aiHA6Nvymwc4WRGHqs8ZY50+A e2xaX/ir2kfxY3T6d2LdQWMc4ADG1lmVl7D6dPzH8HPGfBXALGNCQoXz8cUUAm/Nq/S8 DCnhhT5GRWMbRsspUtR5c9kiG/I9CS7oQmMJGtDMTtzxfNKXt/j90z2uYQO+LPwSAUlM Z6qw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eB6fOi2U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWGtINevHbBp1+VfVX5xni6JutSE9pAWanF/545mFkEfsyGWhAO/V5sLqfI9oDD5jlO721w73JCApFDnIlqp0Vp Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a13-20020a0ccdcd000000b0067f2c23a115si1970651qvn.163.2024.02.06.01.27.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:27:12 -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=eB6fOi2U; 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 1rXHhQ-0004h1-H0; Tue, 06 Feb 2024 04:25:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHhO-0004gR-I0 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:02 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhJ-0004mH-ML for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:02 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-511538be947so1844314e87.3 for ; Tue, 06 Feb 2024 01:24:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211495; x=1707816295; 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=eB6fOi2URhg44M0HI9Yb9X1g0YP5Xiw67+PJ3wDKBlgcyNOVkdwyeWU96BDWULCzjv v8q63Uq24BTj6sY8yd0hMhOmFJ6F7shTm0TH/qBZbUpgtDZNtk31K6FvspRolWL2ONAT duoL7l0LIW3zV/l5Zasw2kjv7TcrIkgGWiQRYazVjn90WtcKsD5XfpaBNWue0kMfJUjK ybWIx7IKE4G+Jhm+V1LPubwuGG7vk60uBu6opJZqbhgsKxYInCpVgfi1vt/AEbryRsQk GsTIDShGaKaTVC2goj0ik8AvF2qCDSTfwJjuduZeJ4S/F/tgKzAwXjy+lFMkAB2m2YOI xcZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211495; x=1707816295; 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=Th7KywdTXFdRsRbfMjfo1HtiUhuycSUv12nB0o5vBYOMQwqqcGEXeD0eoSvKxM7f/V tuT1ijleOhvztxn3ZH2wDLHY0cPn76CBKwxjqXDmc4cbyPphhhAwIIMRUBqKbRMS35NW k/QGICFW/3gjsX3B0ZzNi3S6nhUFRRMz6ahZLvdvZVqmSUXtAvFayLQkJYBE8Xn9tYRg 2uZdgOKDqeQ6GQxB0aPQTOq3Vgt5zo0xBxjyhej+W1pgSad0GVTx3Om0FvtCG4KxKBAV vPDXe5vGVAAR6DwhfbTExHzPOJ/gV8SsUGx+eYwvKm9+Dwqbq5NNWg63m7HjUfAGDetn j08A== X-Gm-Message-State: AOJu0YztsKjWAGWbqUIMkFpoKjLkAzXWfmdOojTKCgPdyjj5UP4chPiQ HhzGCNIHMU80h48OPgRLhvTokR5cALEiUMskkG0izTjpRGHZ1aVfaHAxgzJ+gZrVTVXw3njf4sV qZ1g= X-Received: by 2002:ac2:5e30:0:b0:511:1a26:daab with SMTP id o16-20020ac25e30000000b005111a26daabmr1248917lfg.2.1707211495128; Tue, 06 Feb 2024 01:24:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVl9T0xIJP6DKHUNs/jNndvkCf+w52YW0d6cumA8Wd9XllQgkSvbwavYMknmpeUqb9jFBk1sfgkKlXZQufdoPn36uGA8s6gP07eUCfmmXozc9D6ba1xunH6aPzLjowwQTS4//APpRX54l/CSzR7LifsV3kJtNEaPUY4EI0UPXD9fqRmGNqM+7ZBXqLI2sPXvfpq3URFnqMUZ82pNkKuHajwdhk5Q/h7m6QYudGd7HdDoFTisa+mv/9RpPl+gZ5gw/LfbqXVVt/ZIq0YKtqRljSoYxFDk8NEk+8UGBMiMyVvA1HRw1T806PSREhGFxoTots8/W3TtKbngDTgSxo1jVgqrZ36TpMNoA== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:54 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 06/17] docs/devel: plugins can trigger a tb flush Date: Tue, 6 Feb 2024 13:24:11 +0400 Message-ID: <20240206092423.3005995-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x12f.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 --- 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 6 09:24:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770365 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195852wrb; Tue, 6 Feb 2024 01:26:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIu+zbB9V/aVqCh2U5KVlwIgKkBz6xMNFSGmonpgbibxzOETtQuHNA4p682Bl61OkjAfqz X-Received: by 2002:ac8:7ef3:0:b0:42a:5164:6033 with SMTP id r19-20020ac87ef3000000b0042a51646033mr1376111qtc.65.1707211567141; Tue, 06 Feb 2024 01:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211567; cv=none; d=google.com; s=arc-20160816; b=NBjZ+wZo1QNrYklYZhosO7YD1xh4lNFqCYTp/mTd+/Pi2U+bfj/4ynhuo9ewad02Sb DpdFdcyWdf/IFm6qHp01IZQ747LSVAL1x5+v+htuXmvD0HHM0biKIpy23SxeYnkC1Frd jbc9dAso/0RqcAZxOgORTQH2gMpHcauHg1onYHPwdW534mB7t2QUXVzeZm+YX9Kal+bI 0runbTICchcGPEuo6uWL7pVqaEFuDRF7BkybSjZgpCOJBdfUuOUg0GropRYAdYntX7Uy Nbr9M8CevnTk+MXfHiMslLIKPO+J5eJEbgb0irsRgM3KcBid1tt5DQxPnba9nsH8GYoM ySMg== 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=b/g0mzC04szOUnabir1iLLohCVaDKcAp4uQzKj4Dxwg=; fh=UumfnL32ttwVq5yWTTunLE/2ROM49EM95wIyTuDETZ4=; b=uTpdn6KNxByIQRqOQggpRZG093LIzI1aNZ83/WxAaNGO9bnQ7Od94cMJAM1gGHXgvq cp2L0y+AqxIJLh7OdUba6IQqK9Kpar3g+7WweuML4CcspQI1VGaSPOxdXyancQqtCaqC vzowAV7JWV8ggP7iVMcMVYBIl6Pfcjuf3T0JOrMHHPOAzSIzf4DOr9DjN5n+hKh5tzKo H7sHzWpAJfxISPbSvQmY9/wylknIfDFHLzwAqlFZtGWg7gKKTnSOESuXM5WLy9mlfQaq gj2vWjlYizpzp5w4WLs4DEBJmAbxJNYKj1xcS+lXGxQz4+k8/dpZ8GjnxuCgrljXNihv 5vSQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WqhZPq20; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVq+vcHWR1j0JXayEfKsOEFvTmNf9BJEodooKcxmC/I0dr/C1yxinO1W4Cwm1q8ITSmukUfaZ8C2tVZGAZUQEv2 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d20-20020a05622a05d400b0042c35eddd22si897874qtb.632.2024.02.06.01.26.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:07 -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=WqhZPq20; 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 1rXHhS-0004hK-61; Tue, 06 Feb 2024 04:25:06 -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 1rXHhP-0004gt-Qj for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:03 -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 1rXHhN-0004ma-RG for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:03 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40fdb18ffc7so17284465e9.1 for ; Tue, 06 Feb 2024 01:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211498; x=1707816298; 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=b/g0mzC04szOUnabir1iLLohCVaDKcAp4uQzKj4Dxwg=; b=WqhZPq20rTP/4q7aSjt+/8odZ6p6q/mJAGXw1KAfYNrOxgzNwSbKutPk3UDbE4mXt0 jMXlMnA2RM/5qPVvZ1Ho5mOoGsAg51/LJEDNOldv5N8N9VtwieGZEFhyTn+POXL11InQ muE7JEwq1ZyPPWr6tAnNi6d62UzVBZ6e3Crue5zjVjPNYebUmE6vVAfRK/QCzAz7XJyl 5lHexawIi70xl2cjiOtu2kkFSUMLbFfYA3YIwvti9mvse9zLYsPJ2jkWtekTapA6jfKc E1KVh+OB6OUs6AQLijVyUBUd4+XdKlZxd7OqFQtKn45RfSPPT/s87xDcok6LmCAgEQNR O4Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211498; x=1707816298; 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=b/g0mzC04szOUnabir1iLLohCVaDKcAp4uQzKj4Dxwg=; b=vuAxKIVIiiIjvtXKHNdHhfAiv9b6+LB+qvMATOaBYMOC4KRR3DX4dOOGgkobUg8kg0 zz/VM0NQsypOzzb2bmEF+ibYpN1ymWUswSuxYLa1qaqCOzRGhQug/W3DKVJAXGkKolTt GWvXGA+auyjxgNfuXGst3ZPF3c7ewkV3T5lYtmdL5oEZTzHAnd6Biw89ve2kwPSrrokO xCfMdpAwRlyyAukwo9qWTpI6VxKC0zkekL2xOHJ1cUt0z4skEliWJqwqSTTHlRPMuplr 6fjUuC0flzltP4u/WGChrk2+JltzYtO5DZzeo0QvT0uuITetg1USyIO3CHWPULFJVPlt loag== X-Gm-Message-State: AOJu0YyJnABf4fnImQQ9Lu6Z1WeckSb+5r22BO7ivukGAjHNOMwjueRI +YN7EKvnIncoRNu9no8XDH5nBlu8lr1AOVbK/34iu/lpRUMgSkoYNVeM04cavjL8o7l5YYGvWEk lxJM= X-Received: by 2002:a05:600c:3b8b:b0:40f:df20:170e with SMTP id n11-20020a05600c3b8b00b0040fdf20170emr1176154wms.28.1707211498653; Tue, 06 Feb 2024 01:24:58 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVkUoJtjxsYrrru7l6Q7fWujJ6IhxOQmpENemZpNSzhbD/MpcgbSBISnecs9TbnzgvStjswP8UBxvXneF3P3m8+vsuwgOAI4ynJcd3mn6VukHWzNAcsKzI8fDdWeaDl24vtzFZKllL6iFe2Jo2gBkWBxnJGnR8JSUpMXSkyMeOOTPlQDCIT/mEnXAkp4JbMRjdpt/sihwyJiqFejoACQDpDFsGMEAnVNHcKwspoIrqj1KI5vGnomL4qI1ovPq+qYDTh13wACY0unIqquP3pMX845aYrH+9D3kRCGpJXb4dPyxYq6VV4D70WiJPYpz1AN6MxKq0/ajGwWC8f+Qq+m4J1Nug++rjRfQ== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:58 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 07/17] plugins: implement inline operation relative to cpu_index Date: Tue, 6 Feb 2024 13:24:12 +0400 Message-ID: <20240206092423.3005995-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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 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. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- plugins/plugin.h | 2 +- accel/tcg/plugin-gen.c | 65 +++++++++++++++++++++++++++++++++++------- plugins/api.c | 3 +- plugins/core.c | 12 +++++--- 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/plugins/plugin.h b/plugins/plugin.h index fd93a372803..77ed10689ca 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -100,7 +100,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..68dee4c68d3 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)); + /* pass an immediate != 0 so that it doesn't get optimized away */ + tcg_gen_muli_i32(cpu_index, cpu_index, 0xdeadbeef); + 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); + 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 fd8604bcb79..863c2e64217 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -320,7 +320,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; @@ -476,9 +477,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: @@ -511,7 +515,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 6 09:24:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770369 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195937wrb; Tue, 6 Feb 2024 01:26:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6o1UJ3I5hTqgborijx7qOp47l0ncY4jgOGMjLN47t4jA0T+HAeR/R8bCg7vKOvRXMAXT8 X-Received: by 2002:ac8:7c48:0:b0:42c:32e6:5b12 with SMTP id o8-20020ac87c48000000b0042c32e65b12mr1847604qtv.43.1707211583785; Tue, 06 Feb 2024 01:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211583; cv=none; d=google.com; s=arc-20160816; b=SV8Iu0Iq0li07Quhxsfw0/W/fRMupd5lI7O511ew9bcSOXmQUwfLJaOO9n2lzYlzKv FU+Uc5jAZ40pe0Qq78qQ9RSFByydv7rcln9N4ciypPAHbQ6QPUttl/tuxqjFxoBxXcHE Msg0LxKkx5wFrt7IZanDv02FMZnBiBmbcsKTuVgbqJp1odMBVwTyNH2UIa/AEzB0Kln9 s4J4d2540ScuVJxEIseh4nXGnZjO/mK6ly+e0d7wdt3Wykxc1aiR4Xzokc3oOSzLccQ8 olLLKZfQFqlDYxAIWm4DjNiRwWETUaxBIlPzBcKqaLFtmr4Txl/YcPp9+tb615P80Jvt 7fRQ== 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=Jy1rbHGzFBtEHIrb0UzJIVl/3vebd/Q3PmRd1pnc7wk=; fh=G+XcbIe6aIzhnvhJ1sy60SH+VPTEIdiO1LrzVA163T8=; b=OpMZ9GJ0SYS7pS1e/Qid5PK0LA0aBSqCJCEgUGhV4ZJbG3C4DPId6cDB1Nf8vcLL0j O0Lq/Lc8vIJfStdtnYm3FJqRAOImIvvxJp/+Oxg5BVPkRu03iEPDMR0Pk3PHGgn4Int9 ZcV+qI0QqlWulCOk3xOibKk0IWxfbNV0mM6u0c+c5BMneCy/XuaJozzYz5GYIRuSjElW vzMA3zN7YL3YRIUjCAJVheBHbaSgAlU36/gnbCJj3FOkH5fKXk/m4qZIQ+ckP68E80tR P5OeA3t3MCw2OauaGV1Tck+Ac9U3vRdydsW4Jar41wHpKAi+K0lPfN6FFyyMQQqmgfvz hgCg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y5ybvpuQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWCJHVCutgAX4W+BfhnYf8pV7LEH4/zUQ9+XvjHjr5qKf/6tCP4b/Id8bn+ycK4FpsxMc7gKPk/WJpEpuwhzufM Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c8-20020ac87dc8000000b0042c2caaf0a0si1905836qte.330.2024.02.06.01.26.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26: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=Y5ybvpuQ; 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 1rXHhy-00056r-AV; Tue, 06 Feb 2024 04:25:41 -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 1rXHhY-0004pT-Cl for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:13 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhQ-0004qa-NO for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:11 -0500 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5112d5ab492so7430835e87.0 for ; Tue, 06 Feb 2024 01:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211502; x=1707816302; 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=Jy1rbHGzFBtEHIrb0UzJIVl/3vebd/Q3PmRd1pnc7wk=; b=Y5ybvpuQ8VfabNi0Wf1awIleMgXCK1eLBJDW5Eh12dHrIVQrAH1oXS8SpqwjiiKcBU ptJD1vjz7RzUK+AABWge2ccTzAQB32LUWNlIQMxeZN5gAkhvJxUgBLxK1wPDVLzBpRqI Etv1ypKXdPsvLcSh3/ethg59wkf/GwIduglhzPWEN9C2EtXBS3+rNpYyA5/FOr5kC73l lFzOmrRR7Mc8Tp1jz3XEUC0G69EJChgzLOYDXLfD07RRjDqt4e65zj+4VhmOjVr4WK4X g7Laz0rEK9ZAmL6H+CUfo9L+knserqsSHBP9GPGQqQsysf4u0HYYDUoPZGAZ37ywbzlD q3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211502; x=1707816302; 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=Jy1rbHGzFBtEHIrb0UzJIVl/3vebd/Q3PmRd1pnc7wk=; b=XFZP0wkPfThGIcRlmq7ve5o0OsBGdSYufS8AeRr8Ho5nnvr6Y63HBnc+8dFT0MNqcN r+b4OW1UeM7I5ZFoEFTVMIhOcOzu4yg8UXaB5Cww6pD0jl2h/Ysr94KNw+2tQrw0zVlK ZyZTun8lk6wm2Z/lmWbfVCElwZA6fZZC+H3HpyEe2AnqUqHdiKieZXFUQzXwEN3HaP0e UaZGGKzvo7hcsZck7RCAxoOiC0wM9FRCwI1W2ULbC+LZVR6t4K9D7gS1IFRawoiL9GDK NhRXoDG20aqRVwOIrnJFh/ZuyimCpl99V/ZQpNcTilUd3W6bdAyQonpIseKQ7sXuBmaR oiyw== X-Gm-Message-State: AOJu0YzD5wjnECw7uGMPBZDCcrjOhOpbNwuDS0K4dh45ltCpTK2UeOwi AI1mlwL0kLv4xzYD1ieLAGnku+Xs2frDtFLxpxTffE5DnhZf0p76YLpkNItdojxCuqvB//wYjA0 Wtz8= X-Received: by 2002:ac2:495a:0:b0:511:4ba4:dc2b with SMTP id o26-20020ac2495a000000b005114ba4dc2bmr1404101lfi.21.1707211502228; Tue, 06 Feb 2024 01:25:02 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWmFm9+NTdSrz9f1Z1xMd8TBX9XkaekBYSKiTACYZ2ocgZfvG2xPTieZazMr5zBauVUzuDQUZUwu/cC5xv5DKPpXsgCwQtQN/TJduftzk8hrL96B/XQqMgChvsXMz7uuaHzcEAWoB0aPNA8i1MBn00K8jcAv/PWHws7sKZ252/nLaD70ESMUc0T9d8dbufBHittckE1yyudJ/440ERXQrYTN0jI7jal2OZbP4p3HeCzmSs5OvuptmKPOQ+gkPkNsHnHWxD3XovloFA2yN7HarZ3yv3xNqnC48aIjzmKh8hdKmzgkn6fItbfJEI+Cj6rScO+EwnzCArKHWYo1Ew5cpJRHtpHcbMyQg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:01 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 08/17] plugins: add inline operation per vcpu Date: Tue, 6 Feb 2024 13:24:13 +0400 Message-ID: <20240206092423.3005995-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x136.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 --- 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 af4aeef4d78..0fd72544615 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 77ed10689ca..1ece1b6707a 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -74,6 +74,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 68dee4c68d3..4930e674c7d 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 863c2e64217..48e351d7631 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -334,6 +334,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, @@ -482,6 +499,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 6 09:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770374 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196142wrb; Tue, 6 Feb 2024 01:27:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIbO1kbWN/JOk109YnA6A0AWoZgNrkV3RvKAfQANdP5I+I/UMcsXqLURXcmaQ3VRGVZh+E X-Received: by 2002:a05:622a:ec9:b0:42a:c5d5:735c with SMTP id df9-20020a05622a0ec900b0042ac5d5735cmr1573924qtb.7.1707211628803; Tue, 06 Feb 2024 01:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211628; cv=none; d=google.com; s=arc-20160816; b=FRQlNu36e5GDCJtPv1SYTvzgcCb5Z/BqFrvLRBmgZusaofK9zkgtMNceBsMGf2wk3l 9pKdzBoAOtIhhabTlTOnZACEFHA27bZujas1So1W1Hh2XaEeMpZvqvXUWJYW+X3hoBQ+ ITZHkAaUw6306TBJFoPHJ0aJ2bw3Wnv1URffZrzsyCl5vSiUgTacjcQCwC8FvP7K0OuN 8Fr34ETMutEO393vcaLyK7kccgtlv4FBnXw7M2Zg0d9MLbboEpcYGFNqL5Ss5W/3HcGz 15KUa533i2aCgc2nDJ07jyDhleQIGhHOznbV8+srhjg36dX4jYbHS+/eqaYzuHNJD/oa mBug== 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=guUVN8VKpczzEXZNtRS6ntiARKPcliqywTyHLmbAOwI=; b=G/XXz9dbSM/AlIU2ovH42QPh0sZ/WuCO42ztuaDvsKESnkdn7NusYdcI7rG8z0ezmF LsHFYVuXDl94bBhE8JPhT8ImI1UjGZrC5XroLuSi4tuxbONPR4dizLSwh4yboa/i/fbs ZzHNDNqnsj3s7BPEMnLw/l5UmEsHZGdr9iUr8/uYQPyjRH12GsFT4d+11dFuTKKu/PlM zNozqBw4iN9gId1NDl7KJ/4yAVwyoRVQinVE1RfKSNvEteYnHeFiIKK1caJxTjq6m26w R10+f3SxJDGet+whQg8/Rd7PKHT0mcxb5Yl1Y1q4pIr2JalAnLEi1OdLlHME+PtpPhAt t8Ug==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pd73tkoK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU0fcFQbabxw84QJPFLLmr4GRK/scG1uKeRVrPQsx08jV80lGpD00vhkNi8wq5f5MCOXDS4x4d+uSzNY2XgUGs0 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020a05622a034400b0042c28ae0303si1971105qtw.46.2024.02.06.01.27.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:27: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=pd73tkoK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXHhe-0004u4-W8; Tue, 06 Feb 2024 04:25: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 1rXHhX-0004oa-7e for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:11 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhV-0004xl-5c for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:10 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40fd72f7125so19582025e9.1 for ; Tue, 06 Feb 2024 01:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211506; x=1707816306; 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=pd73tkoKmArkQnGAWs9cIn+9N89RpFG1iXDD0cUBxsZTOse3CnOpwib+L7fKFPrOzL YqTFVhKGOcTAqLN3qwDKEIkcmrO0bkumXM+ZfHigazfEew2Li5CouwjY16avhc3xhyq5 T4gtkq3DnAKDciF9uNQQTKGxLItrR3HeRapDUn1zE2k8nw0ZnjA9gcToad8iwJvBmaeM xWWLSE+5Zm6MyxNH+J0qVP3Otg+TB2dgGkHYt1FNxZaTaye0QeFrDnJithGfntKjZWoi E8GHv8YFEpqZ9kaKHaFC1evofg57aUkLvKSAYGBCsBVHhnknOEQJ9IhlsEgPucx0nRsx WGug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211506; x=1707816306; 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=cNeYcoNbwYZe/PmzCcYLMd585zPaPVCkdpkM4Ht9bn5pvpmr+hakaevUCwRFiyZfr0 iCTlrRjPYJj78By6xgK9B2pAoUGRZCJbHp/x4rPMgrm5CBStyh4k7NCoCbPnw/nKtr7M ws8nBZ17eAxX2k+6WavZVTHrRvv/MvQmGjB5lphMQ9FskkBz6D4Q9lrIizDwrzzKjh0N qNnNYsjVhODezc/kq92H6kdZFWyi7BM+/b2fTNQe1hNelTDwqPjwQEM0I/lBOKLZIYcr cgwvCkPeJl15j7iJrzODqLG9Cn8MI8qLduBiCb7dvdsmi7QD066/RhtzFiIcQc+Qs5vx WT6w== X-Gm-Message-State: AOJu0YxTR7IRTZKc5Z6KYwR0HoFQ4XWNiX7YiK7Gy04JfL25McyRj0VB R+fcucFel8DBi3OCbbeABXpJzfM664MONwkfTmqvWjC3FjLH+iZ9+ECOQEh9hYVxLN+WYohSL8O h5tU= X-Received: by 2002:a05:600c:1c21:b0:40d:3fee:97f6 with SMTP id j33-20020a05600c1c2100b0040d3fee97f6mr1681410wms.34.1707211505758; Tue, 06 Feb 2024 01:25:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXGPuqgaCqXDWYVwZHA9Yvi/rzYX4GLilyeC85kBJDh3DI4Jbj7K7ZlYtxg4Wz5Ubvrl2zAzi2YSkIiwrO/f5egWYO+lVICXY9ij3Juv5/CMm7YjBmvO12HKnL6bpfXt8COnW1I4JbhcaIORcp7LaBuG/PW4jMRv+ra0QC0P5Zbt40JR37qNZAN3BZm8TI1or3AUadUwonsadBbaC2l90tVc1nW7QSwTffKtYRNuafMcddQMP05bksZYuyqqJ+DdaBeKqwuuL2Xj7fiMhoaGHD12oPPBkAXbnq4Nv9X+u1PzsKw6roQRSYmdfpxI0jiXrt/qcQHdv1hg04/LQPD6Jj2+yKKEvuWPg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:05 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/17] tests/plugin: add test plugin for inline operations Date: Tue, 6 Feb 2024 13:24:14 +0400 Message-ID: <20240206092423.3005995-10-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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 6 09:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770377 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196210wrb; Tue, 6 Feb 2024 01:27:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEJ/+RIVlg/aIHwhbVhDcaoDxgeaHXKclt4l6V4QLEqcTizoIVllX5pqsow176yqFnXIhY X-Received: by 2002:a0c:db90:0:b0:68c:64c0:97c with SMTP id m16-20020a0cdb90000000b0068c64c0097cmr1635259qvk.14.1707211641049; Tue, 06 Feb 2024 01:27:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211641; cv=none; d=google.com; s=arc-20160816; b=BZzp/vEUvQzujPJaFkwq0Din6TstrYeuNtzmcstVGmOP0C1YuQglp1i1CN2Qvh4vqA E/MkKQAX8Oqs2ps1ejP8LYf/45uED+OqF0V5LM8ep3hs7D4AqjsgqllBF/N3xnbSk1Um 5RV8G+xeegCXD8LYlnP6UbA+rtLgfdSZysfs9dXi3ywVEETdwSH+hatUxeW6Mhkk43vZ TaHKoeyWqPVH+anYwtjpn/mJnS3BHSzKyS5pklX4Ft6sRARLXH7gQZmK420mO/mYi22U 6eUy1LC6VF7XOS9J8Ll/qMaLfZgmQ4tQtViRV3bBu20f/lhQ7cvO5ASlIDJWyziAf4aa NM3w== 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=uzlcwakGgyM+JlbjjSwfxhmI7LDcsChtFq0USJXmwnw=; b=vg7Wd/6E1G717xZR+42jFrwJxrHFiR7ubAlv32EPSl49WtSK+UDm0MDccefcQy+xqd h/Q4/RlQyhvxfhgjzHiXcEV7qQiCU/HHA2u7Yd8brcYnGqaiQe2DTBKK6YSfvJCafXi8 rnw8y+FgjzuDvh1qD1Jx4D7nOVVG4bGFFz53Qw0ZCYUES9Su3Db1k+3ryua8oVhZ+nAU GQ1puN0o7UNU+dA1Bpd8wyjmH+/TQug0PBg7CkaTeyiHjYm35CRrWUC6WGdSEQPV89AW jRlU0HXkXGbe3ZVzC7RRiZRT/QtGXI/M5Z/LMXpD0/sw5SdnTr8MXXtgnnGY3RAsxaCh bYjA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QNf3aFXA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVH2olM+rPw3Mue9STyCLcPFx5vAljDgc04dZ7ZqJfPkuTkEymeAOwA56p+leSBhNc3iwvtMY9Bk0IgxW/Hoa4S Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l2-20020ad44442000000b0068c71cc980asi1933005qvt.28.2024.02.06.01.27.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:27:21 -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=QNf3aFXA; 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 1rXHhg-0004xR-08; Tue, 06 Feb 2024 04:25:20 -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 1rXHha-0004rN-0I for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:14 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhY-0004xw-64 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:13 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40fe6c66c3fso2001095e9.2 for ; Tue, 06 Feb 2024 01:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211509; x=1707816309; 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=QNf3aFXACLNwrO8xs8mW3pgvkcVnXsxaJM4k+bnbzUQRWaHjYsiKJEpiu2el1J/L2i ZQmo7wnshoX7qQX1uy5Y/6avfQG1RynID6c8vEPXjcwtj11wZt0mMmRxIWp6uCkXZbRT 2LU2Y0OdIR+kguqiHGLwpwGBv/oCFiUs0/89LVa0DVjqaMzanKAO2o6+DbMiKpthYH+J GWp5WkPBSEZf0k9E0E1BeZKoO0JrDLq9QKvej+AWUftrYL3BvMz7hIQnfWDJ51kozPad HAB/bWY3G2XPyjbHrRj/jvu3ADnMmbEeHYDftwYtcVX5VO8NzPSNk4MdxrWXPbmGtAJq MXWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211509; x=1707816309; 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=LHtZJ+msmx3LycJiRDTRLx2erQ7pmXZ1ahUSbUMCaMhNEDFSCi7Z/tHih5d8Xkf/Fh 84rxfnEd1rrw4Wf6wPMcHAJjTBSsNXHOwBvl3GfHISOfn3brPH/XmQDuVqoGGLRF1Tk5 9UI5TzTPAFGc0gCWBQrnKptBJ7/2/fVnNnGYdRr2arDTVi/WPjXAmVxLXfZy4CBiJ2Nn Kb/yzfYnG8W7xPjPGjxW8slUgIVGKNbgxMfRM+VupA+ncFIbRPQZpoCmgwh+kUU8Hj8X JaswNxGfUA591LwVtAgZ3vQWfoI3WNHIJvGzxS9HJ8lOpJCEiQEakXAbHo0r4xCwbe17 TI5g== X-Gm-Message-State: AOJu0YxUQKyNVJBs4+ai6RdhCQ6wDjutDKq8cmvCPmuZjlqjfmRgSlH5 vOoEXY0uv8hFQXSkK9GYTJx6BQaJxwRTHO432d16+cSJukfCEH+dEM9daJnnIsmCPV320UUeAqD NcSM= X-Received: by 2002:a05:600c:1551:b0:40e:f626:483d with SMTP id f17-20020a05600c155100b0040ef626483dmr1111760wmg.13.1707211509281; Tue, 06 Feb 2024 01:25:09 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXvxRllywUspVpYBmmU355BN8xDwFZHEB3DADkV4LFearbp5gSsJLNr21mt2pbLgp0STeO/2GkxehadlxIsUxSV1zsqbmnnrsaqnD8eFcPemSlbOnmUn/hVQbWdZ3n/0Vn35DKf2iUAdDnqLMIAm+D8o7eRAR4F5LtfWZRVAvwiioZzdBK7xOUm9Uo9qvDK2gb/e2HwtokIt+8QS1j4CIGAHcKxFVK8aKyEEMYzSVTj98tub+/KvwatcoVXOGdBZh/k+O+WgYFQP2rLI6cUVPYfi9jhrO4C2oLDPDmoq6yHVfUSo+TtNJpRUkgOogrGTUwfuyWI0lIytDbS6yXX0E9XRgIuBAfu0w== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:09 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 10/17] tests/plugin/mem: migrate to new per_vcpu API Date: Tue, 6 Feb 2024 13:24:15 +0400 Message-ID: <20240206092423.3005995-11-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32c.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 6 09:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770366 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195870wrb; Tue, 6 Feb 2024 01:26:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGIc5kiCtKuuCDkgg0BtMg3SJj+5F37+48yen0jS3j4M9/VnDbcaEfSf5uwplz3KsTXD0v X-Received: by 2002:a05:622a:44c:b0:42a:3195:e8be with SMTP id o12-20020a05622a044c00b0042a3195e8bemr1971805qtx.51.1707211568824; Tue, 06 Feb 2024 01:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211568; cv=none; d=google.com; s=arc-20160816; b=m9MUia/oPygG2vRonrGloA5zBu0an4ozozSUCXOER5AmH/P07N0073nU9M94oyMnoA fjefX5hfQXE9EFxCOzeuN6z4J+/o3HyT0JK27s4B8qPdqHsmphxKD/NwgqRvw61y1Q0J ckAenKkZlYMmo9AoW0JTsiBUgdsRvodhVNL7fXhFbN+ygkdWLuVzXFRMmjsSDheSk9BL wIDaP+sffhb9snHKrrSqRcF1uhOv0VKcLoarXNCCZtl+K2UwSVc+V0AakezMEDJWDWhY hGufYLNBauYWW0/2bMr+KdFcaTjWqiyC0dC11yF5yxc6Jco+NE9sO21AB4FVVOGTf2nr inEA== 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=aKieShv19+leNAfJUjv501z/6nlQbzmMBdk6Ree8cU8=; b=SV0nk2P4xy3XmLSrx7CVdVUm+lLfI+ETiPnGmGc3rYwQhg00aGQu2ibiF8qjIfPKnS T8gsb8NL6RYp7b9J/UVuSlM1/kCoh9REaa3uLAsZT088BwLVIMLO7KcLRW7pAbkTZlHP 48M5fIc0v7fexPQSR4A+Z+Gn6ZKDRDIn2DVBet2H6U6q9pW4tcsvUyndThveXU3hKq2A siy+faOrgA1nEBh11JLqKUu3a2XAgL77agTHIF6IzKH1LXMfvWaE7OJ5ExW/OTw7Vkl2 nLyiQ89tr8n9j/S/XmIGjxTjS5K8QjhwsWebeSzt7mcyHnSH/rmcbhVchiwwaiGQTpRo fOEw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oRmcvAW5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCW/TKlNUcXLwnqf81t2EJnBaQ2aDc98zaFQeeaSp82cIMJtbrX8oEucoa5zKPkz8k0oegS7zMzITyck5FfapAOY Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay16-20020a05622a229000b0042c31c005dbsi1834780qtb.372.2024.02.06.01.26.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26: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=oRmcvAW5; 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 1rXHhy-00056o-Ad; Tue, 06 Feb 2024 04:25:41 -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 1rXHhc-0004u5-V6 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:17 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhb-0004yU-4q for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:16 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40fc654a718so34402175e9.2 for ; Tue, 06 Feb 2024 01:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211513; x=1707816313; 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=oRmcvAW5mtt31dbVvQKkS1FyobZlWH5GNipyeZspcIVKc8YqS/r23dk0oNV8hchRwR rQ56GRSqaXulHNfOs+IHLnVdScGo4Ui0XJnGK2zJuragDnwBxA+zWiKgMjMAzCkDmpXW zy9InmMsV5vQQz6iC6uGRvnf1kdQDxSe44VhfiV0uS0wkkt2lAgSQFivaLOBUOGMNyYk t7PTFsu6r0e+KU5XWXTSBLrME5V8D3x86SeR1HEFNTCnKLOX14E/Y9VhbYlqRO/OdWzd fPjY8kSgoMHj0xlyqh221KkE0y1IFO6RzmDnUm5eEvf7Z0D1R5MZNR8X9r90gSlgAmz8 ER/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211513; x=1707816313; 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=PKYqMumFoF2I7yniMHqFAysDRmp8/gUjjJCm2BHqguYBtZyhkX8gAUbY36BNa2i9gO Sh33EH574TIjYtfppkJAdUYKXhB9J+I3PlOIYX1g4Js/cXaFqgFN2tAswVbyQsyLbenP Sr37/Ozgg/rH0SagCx8QG5HX6YcoBHmAjOid3YJ+CNIO+M67wmADZckWWZRguKuxLdPX dinoYW1G8EfM2o33ImZen+fZDzh92D8NoxxQYjqGrbot/pwBOJ1zphqIIFcEoGHtd4VO 9QR+KWmfxfHBcX+iUAIIFqnUHL3j1MZotMBMwQW/vBn3hElx75FLdp/sU5FnQSMnzJUR MosA== X-Gm-Message-State: AOJu0YwPYTO070oNiqRUPe+RUa63fEA1TPfcdJBsPrCp4PQXjBaj+ZvJ jM7OOBmUsbeLPz9smif8LrVp2V6NjM9ZgEHLviqlAZP2oaLqjYwtykal2ds1b+0uphdIlHpU+zI 69dk= X-Received: by 2002:a05:600c:470b:b0:40e:b93e:4a0f with SMTP id v11-20020a05600c470b00b0040eb93e4a0fmr1850701wmo.19.1707211512798; Tue, 06 Feb 2024 01:25:12 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUtVWrdbotELh7Qs0BaH/u1pQwm0ogtBS6Y8QLdlvhDw1DNAWIt/YfgUGrt1OdvDNa7IvhLTx8cBkddlSmygUsnCDn7uTRb180nQIfiUZ5rAsSJ3FJ0hFiyo1OjYAyg+XSZ2XlP/8XcU564cxwckQtan/7H2sOn89kHcjc1pq1uA3UkMf167P0WfuZuPRVsBrOfg4BacHP5ataRifUjdF4PXU7A26X9Tk9QVr4UrOhlUUqVAL2iBaVQw3XdWsKZZ5N3fSWQo5fi6MdT4bZmAARlqIU8bwLj2mGqmulqPpp1R+a7RbDos6w39DQcbhNzhJTHaSVObf/HFLbhpR70t5QIOVIbsKkRSA== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:12 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 11/17] tests/plugin/insn: migrate to new per_vcpu API Date: Tue, 6 Feb 2024 13:24:16 +0400 Message-ID: <20240206092423.3005995-12-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32d.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 6 09:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770367 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195880wrb; Tue, 6 Feb 2024 01:26:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW8TpDeQU0L5zj/GrujBWlVs+XaZ48ZfZtcXYEaq18qYood7OwByEnorUwv7n9s4Zsmkjp X-Received: by 2002:ad4:5de3:0:b0:68c:805e:e354 with SMTP id jn3-20020ad45de3000000b0068c805ee354mr2258354qvb.38.1707211570117; Tue, 06 Feb 2024 01:26:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211570; cv=none; d=google.com; s=arc-20160816; b=SWJCihzqhNpKWmtZ4K+sREFgCjeF5PtMkFR4628MbRvXzD9+4eJAvbdLI/IIDpdFPj 0IB0Grde9btk5H2vrrb728EaAFbZom6dN+y9YU0fEfvp+3WdhAvaax32wxSHFmhpRTTN cDioEMwUlN36icOXgelbmoUm7Zx2PbHBK9Agafr2Xymk4HfzT0Y0GqU5eY0vVBM6+xhb 3mV/nUlHXbi2ivAg+BUlkW8cEuN00/gQCvICrn6T8t8JZh0xq1O5aDKlQrFk/3DB+M+P kl+6AQNQLc36aq+2kg1qMxSuf3rMPtK5FJQ+HdR3zB7f2QNff6Xk3yRxqKPmCDdzSa7d TsQA== 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=xVOOEMbviVKQVoHR5oe1Nz0RBx3knGQbPntqeDogGzw=; b=reOb2lc79jWEXGWoBEYQb2xFAXHPtta/c4LVhc+Bk0PJl+ADyN1NHS+x/U6p5DzA4Y ndT2lLkfYyV6f85DUNKie98Q7TrrH0xQFSPOPmAiQWikWODF+X5kETF6AlxVxa97qn3x wh/7CvwrtMdrOQDahVdcSPooYpWC0dRMcOl273w82rJiYSDXZZ0Bnkmgw7EUV6+qUE6u MBd0AfeTfdVJJpY953aZyyFkctgKtziptq65KoQ/MUpjxEmRPIlRHce1Sxfjq+NRvBmi mg8HsdNbgxu6Cp3YbIC8WPIeRRnM4h03obk+S6eatl2sLmoBN3XdmM6NB7KIBkaUyCtg LFEA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s2nBvNaw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVpCIjrj2QeRFgStAaayz06utEeyNiAhYEPSGDycjkOtLVRgqr1FzxdAuTudoUVttic1xThmj2MQ6/jGcLBFqo2 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id er2-20020a056214190200b0068c76c0dbddsi1845818qvb.71.2024.02.06.01.26.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:10 -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=s2nBvNaw; 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 1rXHiP-0005tI-5x; Tue, 06 Feb 2024 04:26:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHhr-0005GG-Vy for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:36 -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 1rXHhe-0004zW-LJ for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:20 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40fc6578423so35407185e9.0 for ; Tue, 06 Feb 2024 01:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211516; x=1707816316; 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=s2nBvNaw14+vObWdOIheMf7F9dXwtU/xW/6xQci2kw64rKVG4aWY5mUKahLtc5dggJ UXOeAqlqZyyyleNyvom21f5MroYRClDescBCT3jr5rntmHuAvBxWfNbbY1oY4tPLBxe/ NPsobT+NamQgHTYR8h5ve3AdlLx6OBENZg9gpFb07xPT//qUU39lTdhgY2OnH4S9oq56 B1LYuQNgkrH0vidLapYUhYyOEUk6fnJop60c4H9FJMqzgypcEEQptGZ0AedwQ/q999JC mdQwwDGHDlGxynu2JF3YxJFcluCSzvuh0vItBaS+HmzFN0FXUOFNeie6lebI/e/z1obS Pj/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211516; x=1707816316; 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=V/sUoUkPfjMyr6zWke22TxleMYphF9k5325glOQcU39dCag7wlbM8Az7mBNJsTBSQp 5y1NMYWA5EVbY+2vUhPyUm+8+jBUIu6h++psOvQ7n/MlRexhOF2NaH/qDKi6SquxpUqB HJWVm134WZcX7jQR0Yuu2u6V+OAq9oL0MEWUpYQj++9EUmqvYynGSaNk+KaNZyjt7Hrh pXl4R2G1YZPhDta4bu/ULFnFdEZnHFRSP5ZPNINNWD90JEEdBxKxRxj4Q6CoA0XnWiYj DghSO0GXD7elBMhVw+i5nRhV1Q39OmYwB5RHU7uL6u/oeI+/kgOrmj+VxPdSGUVxkfn/ kQ5A== X-Gm-Message-State: AOJu0YwbBrOdf7m8ONhTJDdvCXu2ETILDfyi8YSSZWYUD4MnXMBkWVPT Jm7YjpQXW0thv7Acc1nvJ0VQFxyIldQbTGQIUJxbeaXqf5Ggiql5nILbi9omuPL4E1bX3PMzb0y z8Tc= X-Received: by 2002:a05:600c:3b11:b0:40e:fb8f:76b2 with SMTP id m17-20020a05600c3b1100b0040efb8f76b2mr1228668wms.12.1707211516270; Tue, 06 Feb 2024 01:25:16 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW0jfc3MbXKY5AB/3k2PfJ3xXJUnv/eWGALsxO710J4S4tyGv+l55z8CtL0fZAS+bB6ni1Wptbxwp5piXKGRtLBBzu/hTPO5C5ucc3+2BRg8S3uctNqBVWeV1N2v8yMB/LnKFcBLtBYy5EG2OIT7WcF7HSVA7RLu9FiphPLHEz6Mv+82h7CRP7vHKznLMpvzVw1xyzZ0+Sh5zFyxd+ep7jOPhNthZhYiTTUyHwLKtDWHFubtnY8j1YE7Jf+tqHIERuTv7r0O9ED1FU+NZL3XAoOIQvaaRECbXiTL/ievlOtS7iWh7m9vOyJP+bNNtiFQbRCnx435BpRQLkFJJv2dE3kWly/t2F10g== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:16 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 12/17] tests/plugin/bb: migrate to new per_vcpu API Date: Tue, 6 Feb 2024 13:24:17 +0400 Message-ID: <20240206092423.3005995-13-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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 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 6 09:24:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770376 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196160wrb; Tue, 6 Feb 2024 01:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLXj6kQGvmJcdXEc0XLqzWon/dPDSr0KTVOYfnNIZdymuSPtKHQD2IXE0AEUdnOSPwOEw7 X-Received: by 2002:a05:620a:640d:b0:785:9090:d3c3 with SMTP id pz13-20020a05620a640d00b007859090d3c3mr1127796qkn.15.1707211632423; Tue, 06 Feb 2024 01:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211632; cv=none; d=google.com; s=arc-20160816; b=eg42QpqiDaOV7IckJUbRK6HkKocZtsDv6RmpymkM4cd2QCx1xixK0kmUZX+Z9eG3Qa AdmqvOvisqtXMgWHrU38V+KN9QLY6E/bd7J40RPp4o7W8+9XBMZ7+AhtbkDhqmUS2Mzw c4nLHmS217N5aG/XE0dnnZcZU1lFw5nkxI9v5V6x6cS92zKiVeCJMCUTM2FoeJLOBhsV kxQGoiDkt5DpMS3z6n7v1JhKPqpY2yRXkTU+vLLpArQaViJLqcheftxlnhIlQ3IgUP7e PzDHR99PfxlsX+Rt94UXfWhTcmmnahKuZmnzVHVm2PS4MUjQ3m+Gl3XFAqFJ7YJSOA9o /Erw== 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=Saupyw/K+bjsATjY0EX6yCDQjVIHs1fyjUh+UZytTrY=; b=DSCZ0MDo/Chpg5ooj7rrYbRgQnoaRnUOAYC6ggsj9IzBEv2aTWNBXisaKWqlr2Pel5 B/eFbDYuVLLc7XL0KLuIYlb+5UlRrEKNGrtjKpwLUxYXQqPDLv7FGlGkOOjAAeKPifYp MqJeOUES2S2SZMGUweG61DBmIMNrICdfptMY/IrXuOU0NlExFMvLeFArMqQxg62kKwRF OmvWyHkUOx50vk7zoNFcmT4YZ0KskSamlsYrnzULj6byOmUmKeDLpqrMtVwVNoo/EVoV TTJuYJH+LQ9//ybAyWucL80BKOOXct3UtZ++OJ23anCCGpj9Pwx9VjUlAf3RuSmUI5Oz /1EQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YRGmORrT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVFYF69+rkwu3ve+aS18QG5Iv68bLASkDKltprNz0K2fNr0hjD9zMmsaH+8UJXpSlvK6jU6Xlf6jb1L/adpUpgs Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g4-20020a37e204000000b00783ff7daffcsi1872863qki.439.2024.02.06.01.27.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:27:12 -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=YRGmORrT; 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 1rXHiO-0005eo-8V; Tue, 06 Feb 2024 04:26:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHhv-0005Hy-Uh for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:37 -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 1rXHhp-00051M-2M for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:32 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40fe2d3d5cbso3073735e9.2 for ; Tue, 06 Feb 2024 01:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211520; x=1707816320; 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=YRGmORrTHiLOENx0aCM7WPMQr0BoL+VC7H4YW1RfTyufQK51XxtIjNFhlJgG5Can7/ KM2www3oAoPux+qlfwoTKpn0fLlBYaonfq1q3XKd26jtBMSI2C8bCp69AOC13nhIXLFp vXa0dAO2hh57IaVPJHTZN6VuX0dwU0/FUc7gHMxTQfkwBbfEOKGZIxRA7qtsMR7CCMZ8 Pj/66l7jV/N8+k/4/V+GS5mdSBwSEwfs0AaKK9NBdhB6xcx0jEzxRMK1Susv1bmB7Ba+ xZUzwpGUxUP0oNvIC6J4wmC9tVyfP29nrjn3rqv2dSXbyUmZMn9H/WC6zuXF/G6LZ+aj BgUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211520; x=1707816320; 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=ruJ63beozt51y4wRBF9HzAakTsgtArknk3dvqP9u8J0R0MT60bUBqlvzEW8jPteHtk dHBBttumogs41Lc2vSfig1wi/gn2EFzwEWE8N4Wjz0J9UILL1+z9W3An3+1zmOJL4hfz HoCZ52J1qlJAoRGVmmvbuFxamycURkPoja0zTl3HZkAFLskziNxv1BCDFoN7Cv6zNt+L NNxap+OLhdsaicFrQVFSQddOBo9/ygFPkd7TPVZuyN7fXafPg4uvkKkcw3nt9mEFov2l sY0zdUZIDH4uGzUqyznHUbG0+fjdRMqA8xmldvcbU/ByBkqw2TE6V+s35SjvbsFGc7hJ URwA== X-Gm-Message-State: AOJu0YxaNIfo3qgrn9Tlnz672gmpmIObJHdXhEtU3166D5OLvJMvbPoS MN5dqg+JXFG+LLhSEAmV46KoLE4X5YXDSNybO/XntKLg4jAu6Ac4yjnMLyDv/6/TaqhBjjRXIoR wM6c= X-Received: by 2002:a05:600c:5491:b0:40f:c5cc:e756 with SMTP id iv17-20020a05600c549100b0040fc5cce756mr1632415wmb.32.1707211519787; Tue, 06 Feb 2024 01:25:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUYNq+56G9LiYdkKWk5PJs0ecb2uMS0vMn7bCVZoG3bPbuqG77fe6Q2elGy2QGGCKxoz+uFizB3mG9zibVa/3J2otP3ay01XWLkIH19XNWZxpDda8Sacl+DkN1EDVcxvHm7No33rci0V5M3a9O0k+0bhxgIreA0YPwAHid4lXvCQNhs/Hd3YitNipOie49BfkmqR4eAi5vr3wzSSQ/ybBali/4zl/Fej+oZZpSGkF0XMumJN9YfnFPXI6H2uN7kT/gHWcf5ljRQ6bhjbLKTaeInUHo6SVqjwQN7YElThFugFzg1HmEl/47pt19euMxq4x/6mZYxp1zWD5gwi/LDGblQeKegfKLkYg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:19 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 13/17] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Tue, 6 Feb 2024 13:24:18 +0400 Message-ID: <20240206092423.3005995-14-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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 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 6 09:24:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770371 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195993wrb; Tue, 6 Feb 2024 01:26:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8sFh4vygsl9qqF+63WoFdx7vy8t2QHUN4v7dfSCARnQG95veCA2Vgqil13lTmb9OVYNgv X-Received: by 2002:ac8:5142:0:b0:42c:2990:a6c with SMTP id h2-20020ac85142000000b0042c29900a6cmr1992193qtn.29.1707211594417; Tue, 06 Feb 2024 01:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211594; cv=none; d=google.com; s=arc-20160816; b=rlgFfdYvKnIWgB69wBVdt3c3zN/Ce7gIN+kR6AAcd5hgBFiGeTMyvYzcSuXbjvdcsO ABL46yGk/R7Nk6qrr2kGzSaIwRORZyjbTW1ltInm1m2wBA/IjDg9JUXy0HVe7mneDPcE mKoxLu8R+igJssp84uQmcAc8whhKwKWO4FnJmCNs1n07Vj+/BcNcFAnf94H2QHvSozE0 ap2eROMnzFJdPaWeEJJBf3Khu/WRVcDf5G+iXQHcMVq8HkawL/c8v1c35y+TN+tjtmiI bSitdruM1otA1g4l2BnQI7Zysy7T6pMy9j4/BhCOGbVEpKC+JqNH7046CRDxbl4i6QsZ qV5g== 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=oGG9FAwMq1MHzUemLC/CeOBy2HrTswYxL1gOusG4Ckw=; b=b1Txl2vyFBuFFFYHsBofmmnpdXLp3iYALUbVS6nf6wct4lBVwDgOZbeA7CV9I7CZDE dbyLJP8CbynQeVlDRkwf80CpjC6Am8i87ArljSenQ9ibQ8pnTL/Rj0pcxcAtOyVOex2H HdDpvowGJq6o3XR+EMY7Dvp9WmC/EddAHHNi1bqWCMqdhF/CL6MwgSw9nr6gwm5W5TTk iyrfxAA6P+zkjW+07VAA68rPq3ioSEZNMwgc3P0VIvbYE9HFmBjWc4j3Rn/GDdeKBu5q Kxt+HnnpMv6tHkMw1Kp32BPYXLrgovbFMt6QgwTrWACARsz+XRwFPPvnSL/3d7JxpL97 f9IQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lv3hy1Vz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWMt66vc+y9y6D1YAotf/lB1MbmoCpq2GzgUDcvg9NMbp1yl0tCNUnNMaqhno1a663mHPZUDAxkyBEjKN4taJiP Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w10-20020a05622a190a00b0042bf4311f57si1983924qtc.402.2024.02.06.01.26.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:34 -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=lv3hy1Vz; 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 1rXHiS-0006Mk-7u; Tue, 06 Feb 2024 04:26:08 -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 1rXHi2-0005Nd-Lz for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:47 -0500 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHhs-00051Z-Qq for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:35 -0500 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5111c7d40deso8979319e87.1 for ; Tue, 06 Feb 2024 01:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211523; x=1707816323; 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=lv3hy1VzIgjmQv+7yfG2fq4vQ8dVsD1edtOr/QRCSueL3lNxQnDi/ZejjqQZbsI7Y2 izpHQlJh91Sjbif6A/uP7UgM29gWKNcZhpYCCWZgCr/n3kTQbwo9SGFNcI5suOz4I6oH rPI24Faci809lwqRJvpdb/LhKJrydRdip3oddb0LJsEmJKYH+/tgXxRfD44Y3ZvNOr3G 15Zc/abDlEo+ZyyuTTRG0wHWXhcZhEBLo0qaYC9+WVlO/iY8sPgHrZoK0y/Bzt7qD0iK hhc41bm6Rwff66jqmCuyf5me0171mTdsrFcSkE4m4jyY0jmygUW5xa1/e3H6vffT/EnB ZNwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211523; x=1707816323; 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=uqUG0jJRn0qYvUyrSk6GodZLpT+gSPQOq/AtlsGWhVJ43H99nPjV1WR3Nq3c6Ah1Bl /QEqMcVD8FMmR/3tCMm5oN9th1k8b/4szp9ktW96M0dmJwaGNufJLDfV282DFXkMBOoR 4UnsTWDEPopZNI5szUV3e4yQWjm3nPQHA2gPxJyX5xQRqKFH299aN1bffSpQwWX5coso W+0+vtk+sn0uCHNh5OpT2jbqJcKD796sIuzRSAZ6veTR33u7tRIPsn1eIIimCRK8tmeD g6XyTTHED19yhoo6IHaBlJltzA3tC+IzURMBcda6RaYZdGgtOYELkW3W0wqBuA+z17yH Oz3Q== X-Gm-Message-State: AOJu0Yz1/+mJJTtan6uU/Bxh4M3fCJZ18GJdfs7fpGkHurOyndTjzmDG foY//xMqrByR5xDy0wKemBn50ONOmYxORbJ0BLDnL/HwuIl3rc94S57EvotZn0LOIfJW0L8WTy8 qETs= X-Received: by 2002:a05:6512:158e:b0:511:490e:b8fd with SMTP id bp14-20020a056512158e00b00511490eb8fdmr1569886lfb.45.1707211523343; Tue, 06 Feb 2024 01:25:23 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXBsoezeJO4H0d58Vex3/j1KtjMbMpYl8UuxxUrzpYHOMTAXDUcZKHlijnpGScRE/leshDKdjtlQbwYb7ThUjgJu5QKoYnVfizfdNRhVGQN4gL65YLZ5NcF/pvfLV7FJ2af1J49DZWJMYVDHaGmn1I6Zjp0pTtFjtL++i5996f+orH3fDfN3SyeVbFMItn+Cg32LFGTNTjB1og7oEQQilGl6n59gxGXGhz4UpRIiiUv+vnyEkJhl3AmSq7jzqeDZWg8EwtEVX8wrobbO9SX9xkSB0w9wWcIObzcSvZmcmT7ukWMUrkvN6JYoB3aP280wRsqmNKItKRgAHh+7gvDbcKTYHhZ3hbA0Q== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:23 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 14/17] contrib/plugins/howvec: migrate to new per_vcpu API Date: Tue, 6 Feb 2024 13:24:19 +0400 Message-ID: <20240206092423.3005995-15-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x133.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 6 09:24:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770368 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195881wrb; Tue, 6 Feb 2024 01:26:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWvesitQM/WVpGvikZ0Mhs3ML53bSmbFa07m5D3ouhANZd1Zt6UE5KCJBMtXTB/L0Hh/sZ X-Received: by 2002:a5b:8c9:0:b0:dc2:281a:c77c with SMTP id w9-20020a5b08c9000000b00dc2281ac77cmr1024697ybq.22.1707211570254; Tue, 06 Feb 2024 01:26:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211570; cv=none; d=google.com; s=arc-20160816; b=SwMNQN8HUNUot8lQLNMpVwx8K0HFVUV1997HtXD4GE+pv7vzQIq1SQslM3kiJJwS60 2Aw9aYgJKpCP6k6tPGiW5qJHciEGDesWY8e8VCG7De2a1bojhgKrnQi6a/qAUYxfbU0Y vdGQlgGC9ssfGeKky6VmKTfoQqIpcu+58+gdFSOHPouyWK0DWWwtLMbVtYd7SwmMph4Y 5PoWHMMYi3XpiPjH/9mJ6pit8GgZSwyDpvwYYZFucXT08BHGHu7d3pXqyeC+q2NW09sG ir+KlNrDJcIkLzTNYVMRpyn2bjXDzkGuVsE3FiZvfJVPb1y3E9sI+rz6cP/egFxKY43c 3m9g== 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=8IEJoDesP8nm9OgL6hvSjnZOHqeRCmr5Jj59Tquond4=; fh=tUcW5W1IVcRTS55UWPJkuTk0po/L2Zs8nQLfPIp0X4E=; b=NAUQnYYb0LLcl1aOfYy2XhYVKgKje2hXKzOfNljfR2gQMJfv/cYC+RufQ0bAw180lW ZXjkjSKkenkmggX4fyhYXnENqsPW2qkKcTtwHVRJgBCoQlUDXRDPCeAWJCegt84lYaR0 Lf0DVWp87cmcPQp5RmdfEsVVd3SZUqCo1ulTWTYl1OCzSKlfDi9QW7xCOH8rAKXgheAc oJhfPZ+weRuP4KZjGBbNOc7zAVc+acrno4BagwjMmDRIBOBjL/8ZHrd3kkXtb/Um8ioZ 8xnOYzQMcn7cByCrPkbQaAn7DCEx//mpnceOh6dZmpeD3VreL7PgUgnLBtgD/3m5zHD8 YVXg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GM5ZTWIj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVmQy47HwNFBJ1bxv0yhHlsbphcwjl3QG3p0xaICrecYSOeqn0yBBsUE9SA0IgKbJL266aEYNZ0FHbIxB+vaq5P Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v20-20020ae9e314000000b007845e6244f2si1870177qkf.500.2024.02.06.01.26.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:10 -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=GM5ZTWIj; 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 1rXHiQ-00064Y-5D; Tue, 06 Feb 2024 04:26:06 -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 1rXHi2-0005Ne-PH for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:47 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHht-00051p-LG for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:38 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40fc52c2ae4so36834745e9.3 for ; Tue, 06 Feb 2024 01:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211527; x=1707816327; 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=8IEJoDesP8nm9OgL6hvSjnZOHqeRCmr5Jj59Tquond4=; b=GM5ZTWIjOFYg+jG+LqFx9l5tOvq54ICU9InPNrPB5m+Z8EcMkLOQVXFB8MAo/ZDPPB ZL9ReBgrPc90hCR9oNk+oNbokBgvbe5v9hNyP64WnHOXnlq7Ec9MuCzZPqwn7vCShHcw DlicbicqP2rZuR8bOQIDw4JogZDu/pI/aXolFMI7RXkJYeaLk8Mhu93YRqytE6P/w1Jy RThq1MvoB7gWzOl9AUKHgH/kkvLYFa37Fiw+Qqt6+XpEGW3y3oLzTKF556RPmDeJ64Hh A6jOKmRxIad5j3j4MlvxFME5jLV5On4QxSgTkMVuDgJa5PZ0C/EfEOWtqOJKydcbbDrH 3MzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211527; x=1707816327; 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=8IEJoDesP8nm9OgL6hvSjnZOHqeRCmr5Jj59Tquond4=; b=Ifvshbk6b25o4SKDqKAfn01eu+Omh4fqkdIGHrNxMHyls0raWwrXUpRKpY78LBH29D YvJWOQEwO10SSeHVxk4DB2DIhsiQvP+FF6IovGi/1dGGWQLqf9f0BS0r1+AqDo2qHM/E aHmPt2iOZb0ldmYC1fAmBmui83eQFo2U47YHqpOPjaI9u0Xs91TxJsckjiwfI531DwA+ Wa43y6a7DUkyjcn/k5hdh7gsVMaey6D+kLzf3yO+FnEEqZ66giVPNLcZVqxTpnqXw0rZ fvF653fdhQrA0eImdIUZhT0if0A67booxxGwsG0FjTFvm95KF7toqfg4MS9Y0bVUxll3 zRUw== X-Gm-Message-State: AOJu0Yzi9XGud1VJrS+JLYNdCkr3JHlaNWNex6ZdURZLkdU0Gkf1s2aO lY4XZtx+jwQWUYzQlCHfjnIzJ/rjaMSjbhsuXowfqjYyL1AOguFwImFdg67MWyhYAwF/Zfgpg78 onHY= X-Received: by 2002:a05:600c:519b:b0:40f:eb8c:71b9 with SMTP id fa27-20020a05600c519b00b0040feb8c71b9mr308421wmb.12.1707211526865; Tue, 06 Feb 2024 01:25:26 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX0zTsGefe1zVYGps7wgdLgMj0fTlG8C/qtC7cgTn40hm/xwGgr3GAMcD8KkrcQgxPomaF1NvLdE4d+OVi3swgm6bZJwqFp6CTCB1yO0Tc+0602AVvBoamFbI7z/J6eJ/cGgCXySLnDYNJoRFZMS4oWAALZ3WtC15lIl0XWIOUQLGur0FbHZEEpvZ0rhSTmlFXdJ8JYjX3e23sD+wtBlz7IdGIKXP2YtnbxKAzDQCKCh09MxL626I1SLbtjPBgeb1vQ/CpFvKjpfWNhCVp9H3VF6CwMc9fvDnVNijdQcX2mESf9y/TOMpRq6Ot3xSB4K0q17eYgC3o3UP0cKWXb2y4UE+qfcUSxkg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:26 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 15/17] plugins: remove non per_vcpu inline operation from API Date: Tue, 6 Feb 2024 13:24:20 +0400 Message-ID: <20240206092423.3005995-16-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x335.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 --- 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 1ece1b6707a..8e485cfbd58 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 6 09:24:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770372 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196011wrb; Tue, 6 Feb 2024 01:26:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvJQI+imgR4Angs3HXCqX4AlnYkPs8Kq86aywsHUwqAf1aPR+yTc+lmrt999oZDO4Xl0k5 X-Received: by 2002:a05:6214:5298:b0:685:396c:7c51 with SMTP id kj24-20020a056214529800b00685396c7c51mr2196616qvb.21.1707211598313; Tue, 06 Feb 2024 01:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211598; cv=none; d=google.com; s=arc-20160816; b=aQwmGs/+tA7ltLi+mIqaIsmoO9hspRdd9iW8bXFk8nz/EU9PcYqFF4fsGOVhIyLSIJ nr6a+UO74wG5PZtHPf9ls2mcDpy2zRaeuPtEdat8CdvvzqRlAbha+le25lC7Rt01VG/B 631RSqubOVhmwuJuz/94IjKgmvRSxK00WgTRdNCKQ+jNM8PF67Df4ed6Y0yVCdfjOIkw m3nv0kZdcoxyleP0z68mNEJ2vKah12qF7cEgWmyhKc/nAJ5vKeBqZGGu4kc2EdJHcp1J 5510bLXavKVLVePOTcktgvWRf6ftbip4jjqQTLE0LDpr36ybjRMAWy3sfjZ17QO7A0O8 P4mg== 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=yU4raDcKf+FPYuHZq7bZi5tZwN3XViuFGVvnL6vOuMc=; fh=DnEmGejf7ZC74/L+bIGpYStNTfk3CprtjU4C3UXMDQk=; b=urp4jtSfGE6YHhNsnLC/6CLsYMTkulKSeBRuAiDUL02jRfB4VB0uYgIUHiYLffOEWb L9GHu0Pbk+xqWK029mmmu+HDA+H6h3NQgWwwom3fSgl6eEqvr9U2Krf9d+A8HjtNZ0wK z+eJ5ngvwaV4tD/EbsgHv+vvMrouDnvmdGj0f+DcICf7CRVQWuLJWfsQckKwV/4Jd6/J wu2jHIwOS3UNGimRw4WLOY7o80OyfEadek/NRs3kim0VJHhlBWtsZDoGQDS/qZovJvPN HJxUq273PI1CaY0jZeqJmd6jsETKMyb5iGb2hSvmaHg53pkidoLscYeWAXD6tuMZOznR y3gQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rL21EtXt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXSaTYMsjTrYbXtru78wV2oqKHPTj9UDP/2oMEOIoFYpbxu71azWXA+r+G5xpSX4fvtHye0RaWgT7RqrZsGj2O0 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z9-20020a0cfc09000000b0068c469b28f9si1914323qvo.515.2024.02.06.01.26.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:38 -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=rL21EtXt; 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 1rXHiO-0005bx-0m; Tue, 06 Feb 2024 04:26:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHi2-0005NY-CL for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:47 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHht-000521-DD for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:35 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40fdc63f4feso14544105e9.3 for ; Tue, 06 Feb 2024 01:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211530; x=1707816330; 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=yU4raDcKf+FPYuHZq7bZi5tZwN3XViuFGVvnL6vOuMc=; b=rL21EtXtRvTG12D7JP2/bkNX7BdHvVty/jm5A7WRN9i7Ktxz3NnRKwDlP/Z+MRq0+b SklOC/y1d5R51Q4fD6OQSb4x6Vga7bgTF0c5UWiJNCaYsE/pjMDNzc5Y7KaBXcg4Fqvx z4jHHfqfKdExKbUM4ehAsiDHy6RiN3nDRxn8OWhOjFclQ0PMWdhtsFSZ06TL/dTU+liJ dqO1wgBu3Bqa+K/hg1DpNXOSi9llWCrwy7cd+cAb1agcnN63ElXRik6/cxoCFpqTAO4Y Q8QaWBOFGg/dVuZoIWKcp0cKxPb3Zp52tmLX1VPN3sn+jmLcPEgf5rpP93fOboeuPnjH jsnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211530; x=1707816330; 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=yU4raDcKf+FPYuHZq7bZi5tZwN3XViuFGVvnL6vOuMc=; b=X4yArsT0NnA8NzNz/qq92BILC5rcSc7BV5f7SYpToD82ofgAFpmJpfdDrlJ0hgs1BK l3uB4aFRrz+YRXtKID6BQ94/zz2YBvNWP9MPi6Ct2AoiNTk49MUdTgdr3XUZ71/gsT0y 4sQAW2PFyZz/FhBzPnNnBZu2s1MxiZkUKjdH/QVWdAWCXrtnUTzFkGs2IKlbOMNzmdYp Q89+r75YB6K9MNrv9tzpgZe+PPTWR5wLCpcN0/bAKVMgDJYn2bqIkdxkNMOB7576jdW+ YUZ/VnBzzhRYNifw9Rz9Y7PkoW9hTxxeaDCbDdSyYF8rp7oHVYptWtHSj29VpNpE0ryc F9Sw== X-Gm-Message-State: AOJu0YyshJwnHqBgxFeqyxdMd17rAgw6dMRCBSlOWCQ9suxb6+65GqED NWaakwJKQPt0/DQthuDPIRqg6TdcedZu1CKI1B7Q74p8vDLgPChA02WFizw3IYRdhDJFrU2Zv3f 3RtY= X-Received: by 2002:a05:600c:4f8f:b0:40e:c722:2b9a with SMTP id n15-20020a05600c4f8f00b0040ec7222b9amr1638513wmq.32.1707211530349; Tue, 06 Feb 2024 01:25:30 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXf37gLZdIh419UqJnatI3dsluiwTIa8GlNYnfbK3uWuKiFCZZXtHeZQsWUmm0pbzdUDhH3ignaunToqvluglvCE+iKBPOWOZ2GQDnhYizyrUw3joN0tnkYq98SpDp9EqththJbnuQ3P0q1QFiywaOkJPXDhFx5A7NnXumFiplcTSvLNCsX2ARTPJOh3GPkmzfpZ0KHhHyY0WoA0FWMcy+HfxZAA32pF4z4jhvTIWTj4bzR58w775IQmkFDmaz8SgUsUvft1H4SdxR0KbapG5rgh3EbKTJFXv1fz+I5nCXuqb/xyjcGv58kkXJpYyBs1TO0l31mO3aa4ANKIXA7/m0P2ka+BMTR5w== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:30 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 16/17] plugins: cleanup codepath for previous inline operation Date: Tue, 6 Feb 2024 13:24:21 +0400 Message-ID: <20240206092423.3005995-17-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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 --- 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 8e485cfbd58..ba52a5995db 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -69,11 +69,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 4930e674c7d..0d613956734 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 48e351d7631..7f1b8dbfd00 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -318,22 +318,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, @@ -496,15 +480,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 6 09:24:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770373 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp196067wrb; Tue, 6 Feb 2024 01:26:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDh0EKUiMeTHR41PeWFYeDOjVVGmrttzW3THES0Fi8eKTFRK6SALw14rbQIPoIXzhd6npq X-Received: by 2002:ac8:7606:0:b0:42b:ec11:1a6b with SMTP id t6-20020ac87606000000b0042bec111a6bmr1722493qtq.67.1707211611559; Tue, 06 Feb 2024 01:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211611; cv=none; d=google.com; s=arc-20160816; b=UrPgPtYqccS5W+HwWeKAvPFx2aPYqOJIzp7gEaJfsUpEVaWezkXOUO7TNlgsySDyIE dDim9/eNz4V3Igt0rqvo7324DxqwQC9CKV9nMx1zoHUWIMsoIrP1JIbrJ2oJgTR/Hpxo 9+02xyj2yRnwLCzuOMz1GrXFoVcAdI5RPLpqR/KshEAB4AzL+mPx6A2/Zkuz3R29FefI +Dw2skMEOEYC0RQi37oINk8w2/wTzTQqR0dx23T7zN919Y7uXXJYTE4h13UWU4jjShpK PqBN/BwpxmyR75t/8UXzWSULaa2/iYU61HlpK19KPeQ3yRLjgMBPBBKjXJKrqIVjuNvB E8fQ== 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=pAsA6PWTX5Z7yVb+cvK+shtFgXggRhYZ9ZiUku3Ch48=; b=jGmZ9RM63D1+CBjUJ9z27qAFnjsZT34dOYmoT7wVaIxjySpnY4z6JG3XXp1RhVYXXC QJqSbFiY4ldZH/B/GMhoPbpkUsPjc0LG7cEP49y2nH1GH655G9qbJeMe+DndshLR1HLR bRwt1FGfypDoeFMeYLNVSRlrDuKQCvF7/Wj9cOa2qMgNd5QBLmUSggnxB8TdYWfiKlN/ FVRU309sACc8Wx9+wXMEYfBAleFDz4TCpEMEL+rsL/dJ+UzCndHf9NSHYk5qIja79f52 vbr4u89fCMOZYR65d1Dr3KhOnIhQ7Ze28PDoyVwlzh3jsC6m+pFIAO7qGNtxhKSYcidV KzUg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rh1ljblF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVPjroWY17iic7j8MfDtD6J3YdmBbSsQOmguxD79e+GzvOWPnCSj4UnN9aok90K6K+N+wulzlgzTQIQwp3mZvaC Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m15-20020a05622a054f00b0042c28835da4si1921650qtx.717.2024.02.06.01.26.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:26:51 -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=rh1ljblF; 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 1rXHiQ-00064H-3W; Tue, 06 Feb 2024 04:26:06 -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 1rXHi3-0005Pr-RQ for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:49 -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 1rXHhw-00052F-CP for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:25:43 -0500 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5115fcef9e9so348185e87.3 for ; Tue, 06 Feb 2024 01:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211533; x=1707816333; 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=rh1ljblFzFmNRzDd2sGA18k6wKO4fnqgUK9g5LlJZajgBlIORz8OiL1NTsrRUbTRbQ 5DJB8TC1sHu5qwCip4rCUnOsywZhBkQ2635F1pcvi9JfV+vf5J72RLRozYLw+8VtF4M4 T3TB2j78BTctBFnCWC257D8o7uReryTO8BWvd5HGwUbAqKf2w+uEPm36jrq0miACvaS+ 6qgm9LlSt1/pziC3r7HtbMv1Y9Bb7Vi3Tit8oUZ62QMZhx/7upZf4YVpIYALJIsm11uc 32H5uVoVzMa0azzSY34l0u1bgVJvTaNC35cLBLOHRWACVDUGGZaHHf1fkHIyZhpqq7OO kWJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211534; x=1707816334; 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=Lkdx5UQyy50PRTygXqQD4izZ7ao974jEAahz76CwGdzJI6O3BNb96T0KsbS3LEOEie uzBpS26gD6wyO2WuiLfuEDLLNQmDnSS9aTlYu++PVtq7jcj8QPjqCLl/H8nxZypY0Ce2 3/SRJKiadZ7ikUTdrq3P//BPtBKriLxgueGCANW6J39qXARBQHHyvH4MMXIB/lqKwjL2 Sae87tBtLBpAEQQqS53+310NnzHGa6MNPAFN22PjJ3anQ2NAzCT2dXWNQq0BQlvU9ona +7/GJW0Z4lsnjWcGkx6mFF5k2+lnvCwrPq/mBTSHLXt6irDNMyBmPcMQ1hXbItyOgNAX 8oXA== X-Gm-Message-State: AOJu0Yx1VdBTvk9INIriueG/oNZz8kv1tX6MR0/fhohtAMJtrzm0psSM BYjqB/fuwYpCB1ALt/mIh/sVPGn634OkYy7Ek8PvqMf7B8onZu71gRaJWJ0V0rAWkLf746b9HlY lX20= X-Received: by 2002:a05:6512:402a:b0:511:60ca:d4eb with SMTP id br42-20020a056512402a00b0051160cad4ebmr322152lfb.28.1707211533808; Tue, 06 Feb 2024 01:25:33 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU28NjH2CMq7BMcXqdGqUi44UODq9JP5K0hMCtXLzPod2XqtPx6X6l7dlvVPtYI4L8bazVn29mUgzxnthCYJMUJlC9QyQSwKDvOWZ0TpUSMwYgAgfjISZfMpPMMm1Fuao4yzYN1GsHZ0wWg0r8ui3Gw+3jwXHpIrLsAeRGt4Snr+D7E0Z9gK33bg4oAi+mh/KHkPUyaTI55r81hi8c0AKjCszugXnKcdF0YKEIGNLvW4aIUQ2w3EHPUFK78ra0FMALz9A57zPNWDM3R6otnII9P+MDvK0RsqbxYrGQbGZC7OMLluBKHJrHnOFVTQpMitOpiHYk4ZzC/hQZNfyQegPJfXFQb6AOiYw== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:25:33 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 17/17] MAINTAINERS: Add myself as reviewer for TCG Plugins Date: Tue, 6 Feb 2024 13:24:22 +0400 Message-ID: <20240206092423.3005995-18-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> References: <20240206092423.3005995-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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 --- 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/