From nobody Thu Apr 10 02:28:20 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1736442837; cv=none;
	d=zohomail.com; s=zohoarc;
	b=KoPnOzalIyWOO4ul5qeq/Ah/FbJS9sSyEDsGmpUNziq7iZCa8mV9xAfYl+2XiSuBy4czHWO7wRGWEeObl4j9jQVOu70LkL6bUg1a0zj9R09W6MeOGIEZkQ0EtmSMPfe97B5PO1pLlz2UyaW+2XhAqFC5mhJewclhk9Akbcr3ErM=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1736442837;
 h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=;
	b=EqWlpEevFfkDENu1BUdb+gZVeoEaUp0waOzMObZXrG0hCV9UcZB4/IL7+dJY7p/fyKRPRVYIfqRpA2Pl573dUEKrP5jKDEm7BKBGzHkL3nqIZrSSFTzRHWsTBo6y5E86a80CqGJ2VBQepn3yfbYckTXZibTRf9xxac4cAv72Jos=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<alex.bennee@linaro.org> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1736442837348320.4282364521979;
 Thu, 9 Jan 2025 09:13:57 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tVw61-0007Ow-Je; Thu, 09 Jan 2025 12:13:25 -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 <alex.bennee@linaro.org>)
 id 1tVw5z-0007OD-65
 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:13:23 -0500
Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <alex.bennee@linaro.org>)
 id 1tVw5x-0007un-Es
 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:13:22 -0500
Received: by mail-ed1-x535.google.com with SMTP id
 4fb4d7f45d1cf-5d3bbb0f09dso1820958a12.2
 for <qemu-devel@nongnu.org>; Thu, 09 Jan 2025 09:13:21 -0800 (PST)
Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-ab2c9060f9asm89365066b.1.2025.01.09.09.13.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 09 Jan 2025 09:13:17 -0800 (PST)
Received: from draig.lan (localhost [IPv6:::1])
 by draig.lan (Postfix) with ESMTP id 95FED609F2;
 Thu,  9 Jan 2025 17:06:21 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=linaro.org; s=google; t=1736442800; x=1737047600; 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=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=;
 b=jkdp2baGInpfO0Ycpo2mnIyayCx1pRbLmKwpdLxMoxkOnkofNhmjSVDyoVR6+nhfyz
 Dr097ZqWlKxV/sM3pkBE5aQ2IkWBjTmaKyvU9w81I1TtVoFS3jzfs3ZB9U6PnsJXhE6x
 62eSvO2iz3tH0bEACl0We6yRxpmnlfeOPVxAbjOIyOJPbda243Qf+5J314aCSdRwAiaV
 kafxX/ZZGumbhDRMIz5vQJcRxURyGGRhRceOSE+pL4ZyaVvA9Yib1Ye4pdZAPP/nzC74
 HEh/39SpDFAgTE/RFOE6/G9gjGfEJKREJQKw9M6o2kvQU9+jOLJbm5f/LM3gRBDpBfb3
 X9fw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1736442800; x=1737047600;
 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=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=;
 b=AhdvF169T62IwxzpDxeywputU9FsZZbzqwaYN3GS9N6mZN6dF8+04+qyUwbjl9hRMV
 jwCz4HloUHUyOEaPzLlriP+JWauAe9WaU8IUPL7pw4qZGLJia7TnTCBKrSCahDEcXXh9
 L1CvhUP2BEPpOXU0hbum1bYkdLHi71ZaaQHf/2MptV5wlC2l4ANoLh3yd5Pq2wnPGqCW
 i9Eb+vXaec2rNwFxUmfWFJAnRssRB5MZHg4Fn0PUGssFOJZhINPfXw60JGffVAt1os3n
 /vo8Vn+AHUfP2OmQRheftqr4ZclWsE/WoX+/wAp/Q6nlV1rcD2UXw5Qy4goAYqFWnPl+
 YGeg==
X-Gm-Message-State: AOJu0YwrcoxM5chd/mnEWU/ymLW1vwtlF0lF1+BbWHpeXHntyMOgqVLd
 sxPj6lUny4mTbQFusty3GbYyQxe06K5uNnOSTP6IFSnY5qRapiNObVBocz9U/Ck=
X-Gm-Gg: ASbGnctClqpoHhzF/0szASwWmXmLfk8fzRNvd/huZUoGwOKrWB9+6ttzUWwMQeucejY
 EuYkciKNLhIS/KjAUl3q9/VaRR52UkSs6GCjMXHl2D3uAD/IuUkFuPpMcGIHqQPGyyaXqmGWAD+
 3VxqRqlC5eK/S/nK/AVGQjjUD2Y0nmFGrel37vZ6okRtq2zE9F+MBniNKMX78lkGX2f2H2OEtQZ
 PD8D5U6bOF8mZcxVBTCcu0jdVVzWHdhSu2yyPIoLBR9OYz1VJtsdgs=
X-Google-Smtp-Source: 
 AGHT+IF/Uv6/CUQfz8h9b4WwYfMqehRl7qfgDpGULsEDRdAkAvdsp9IMDYYxSmSxt+iJQrphQ09u4A==
X-Received: by 2002:a17:906:c143:b0:aae:8490:9363 with SMTP id
 a640c23a62f3a-ab2ab7408a4mr733026066b.34.1736442799922;
 Thu, 09 Jan 2025 09:13:19 -0800 (PST)
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Dr. David Alan Gilbert" <dave@treblig.org>,
 Pierrick Bouvier <pierrick.bouvier@linaro.org>,
 =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>,
 Thomas Huth <thuth@redhat.com>, Mahmoud Mandour <ma.mandourr@gmail.com>,
 Alexandre Iooss <erdnaxe@crans.org>,
 Richard Henderson <richard.henderson@linaro.org>,
 Paolo Bonzini <pbonzini@redhat.com>, Laurent Vivier <laurent@vivier.eu>,
 =?UTF-8?q?Alex=20Benn=C3=A9e?= <alex.bennee@linaro.org>
Subject: [PATCH 19/22] contrib/plugins/hwprofile: fix 32-bit build
Date: Thu,  9 Jan 2025 17:06:16 +0000
Message-Id: <20250109170619.2271193-20-alex.bennee@linaro.org>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250109170619.2271193-1-alex.bennee@linaro.org>
References: <20250109170619.2271193-1-alex.bennee@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2a00:1450:4864:20::535;
 envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x535.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 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @linaro.org)
X-ZM-MESSAGEID: 1736442837730116600

From: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-10-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
---
 contrib/plugins/hwprofile.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/contrib/plugins/hwprofile.c b/contrib/plugins/hwprofile.c
index 739ac0c66b..2a4cbc47d4 100644
--- a/contrib/plugins/hwprofile.c
+++ b/contrib/plugins/hwprofile.c
@@ -43,6 +43,8 @@ typedef struct {
=20
 static GMutex lock;
 static GHashTable *devices;
+static struct qemu_plugin_scoreboard *source_pc_scoreboard;
+static qemu_plugin_u64 source_pc;
=20
 /* track the access pattern to a piece of HW */
 static bool pattern;
@@ -159,7 +161,7 @@ static DeviceCounts *new_count(const char *name, uint64=
_t base)
     count->name =3D name;
     count->base =3D base;
     if (pattern || source) {
-        count->detail =3D g_hash_table_new(NULL, NULL);
+        count->detail =3D g_hash_table_new(g_int64_hash, g_int64_equal);
     }
     g_hash_table_insert(devices, (gpointer) name, count);
     return count;
@@ -169,7 +171,7 @@ static IOLocationCounts *new_location(GHashTable *table=
, uint64_t off_or_pc)
 {
     IOLocationCounts *loc =3D g_new0(IOLocationCounts, 1);
     loc->off_or_pc =3D off_or_pc;
-    g_hash_table_insert(table, (gpointer) off_or_pc, loc);
+    g_hash_table_insert(table, &loc->off_or_pc, loc);
     return loc;
 }
=20
@@ -224,12 +226,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_p=
lugin_meminfo_t meminfo,
=20
         /* either track offsets or source of access */
         if (source) {
-            off =3D (uint64_t) udata;
+            off =3D qemu_plugin_u64_get(source_pc, cpu_index);
         }
=20
         if (pattern || source) {
             IOLocationCounts *io_count =3D g_hash_table_lookup(counts->det=
ail,
-                                                             (gpointer) of=
f);
+                                                             &off);
             if (!io_count) {
                 io_count =3D new_location(counts->detail, off);
             }
@@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct=
 qemu_plugin_tb *tb)
=20
     for (i =3D 0; i < n; i++) {
         struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i);
-        gpointer udata =3D (gpointer) (source ? qemu_plugin_insn_vaddr(ins=
n) : 0);
+        if (source) {
+            uint64_t pc =3D qemu_plugin_insn_vaddr(insn);
+            qemu_plugin_register_vcpu_mem_inline_per_vcpu(
+                    insn, rw, QEMU_PLUGIN_INLINE_STORE_U64,
+                    source_pc, pc);
+        }
         qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr,
-                                         QEMU_PLUGIN_CB_NO_REGS,
-                                         rw, udata);
+                                         QEMU_PLUGIN_CB_NO_REGS, rw, NULL);
     }
 }
=20
@@ -306,10 +312,9 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qem=
u_info_t *info,
         return -1;
     }
=20
-    /* Just warn about overflow */
-    if (info->system.smp_vcpus > 64 ||
-        info->system.max_vcpus > 64) {
-        fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n");
+    if (source) {
+        source_pc_scoreboard =3D qemu_plugin_scoreboard_new(sizeof(uint64_=
t));
+        source_pc =3D qemu_plugin_scoreboard_u64(source_pc_scoreboard);
     }
=20
     plugin_init();
--=20
2.39.5