[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 17/37] contrib/plugins/hotblocks: fix 32-bit build
From: |
Alex Bennée |
Subject: |
[PATCH v3 17/37] contrib/plugins/hotblocks: fix 32-bit build |
Date: |
Thu, 16 Jan 2025 16:02:46 +0000 |
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241217224306.2900490-8-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/hotblocks.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
index 02bc5078bd..f12bfb7a26 100644
--- a/contrib/plugins/hotblocks.c
+++ b/contrib/plugins/hotblocks.c
@@ -29,7 +29,7 @@ static guint64 limit = 20;
*
* The internals of the TCG are not exposed to plugins so we can only
* get the starting PC for each block. We cheat this slightly by
- * xor'ing the number of instructions to the hash to help
+ * checking the number of instructions as well to help
* differentiate.
*/
typedef struct {
@@ -50,6 +50,20 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b)
return count_a > count_b ? -1 : 1;
}
+static guint exec_count_hash(gconstpointer v)
+{
+ const ExecCount *e = v;
+ return e->start_addr ^ e->insns;
+}
+
+static gboolean exec_count_equal(gconstpointer v1, gconstpointer v2)
+{
+ const ExecCount *ea = v1;
+ const ExecCount *eb = v2;
+ return (ea->start_addr == eb->start_addr) &&
+ (ea->insns == eb->insns);
+}
+
static void exec_count_free(gpointer key, gpointer value, gpointer user_data)
{
ExecCount *cnt = value;
@@ -91,7 +105,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
static void plugin_init(void)
{
- hotblocks = g_hash_table_new(NULL, g_direct_equal);
+ hotblocks = g_hash_table_new(exec_count_hash, exec_count_equal);
}
static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
@@ -111,10 +125,15 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct
qemu_plugin_tb *tb)
ExecCount *cnt;
uint64_t pc = qemu_plugin_tb_vaddr(tb);
size_t insns = qemu_plugin_tb_n_insns(tb);
- uint64_t hash = pc ^ insns;
g_mutex_lock(&lock);
- cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash);
+ {
+ ExecCount e;
+ e.start_addr = pc;
+ e.insns = insns;
+ cnt = (ExecCount *) g_hash_table_lookup(hotblocks, &e);
+ }
+
if (cnt) {
cnt->trans_count++;
} else {
@@ -123,7 +142,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct
qemu_plugin_tb *tb)
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_hash_table_insert(hotblocks, cnt, cnt);
}
g_mutex_unlock(&lock);
--
2.39.5
- [PATCH v3 29/37] include/exec: fix some copy and paste errors in kdoc, (continued)
- [PATCH v3 29/37] include/exec: fix some copy and paste errors in kdoc, Alex Bennée, 2025/01/16
- Re: [PATCH v3 00/37] maintainer updates for jan '25 (semihosting, gdb, plugins, docs) pre-PR-FINAL, Alex Bennée, 2025/01/16
- [PATCH v3 22/37] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile, Alex Bennée, 2025/01/16
- [PATCH v3 32/37] docs/devel: add git-publish for patch submitting, Alex Bennée, 2025/01/16
- [PATCH v3 26/37] plugins: fix kdoc annotation, Alex Bennée, 2025/01/16
- [PATCH v3 19/37] contrib/plugins/hwprofile: fix 32-bit build, Alex Bennée, 2025/01/16
- [PATCH v3 36/37] docs: add a glossary, Alex Bennée, 2025/01/16
- [PATCH v3 27/37] editorconfig: update for perl scripts, Alex Bennée, 2025/01/16
- [PATCH v3 35/37] docs/devel: add a codebase section, Alex Bennée, 2025/01/16
- [PATCH v3 33/37] docs/devel: add b4 for patch retrieval, Alex Bennée, 2025/01/16
- [PATCH v3 17/37] contrib/plugins/hotblocks: fix 32-bit build,
Alex Bennée <=
- [PATCH v3 28/37] tests/qtest: fix some copy and paste errors in kdoc, Alex Bennée, 2025/01/16
- [PATCH v3 18/37] contrib/plugins/cflow: fix 32-bit build, Alex Bennée, 2025/01/16
- [PATCH v3 31/37] docs/sphinx: include kernel-doc script as a dependency, Alex Bennée, 2025/01/16
- [PATCH v3 23/37] win32: remove usage of attribute gcc_struct, Alex Bennée, 2025/01/16
- [PATCH v3 24/37] docs/devel/style: add a section about bitfield, and disallow them for packed structures, Alex Bennée, 2025/01/16
- [PATCH v3 34/37] docs/devel: add information on how to setup build environments, Alex Bennée, 2025/01/16
- [PATCH v3 15/37] contrib/plugins/stoptrigger: fix 32-bit build, Alex Bennée, 2025/01/16
- [PATCH v3 20/37] contrib/plugins/hotpages: fix 32-bit build, Alex Bennée, 2025/01/16
- [PATCH v3 25/37] plugins: enable linking with clang/lld, Alex Bennée, 2025/01/16