From patchwork Tue Jan 14 11:38:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 857223 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1871958wrc; Tue, 14 Jan 2025 03:39:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWH8AlP1oN3buE3/HedgqGBSldEHND3rBkgszVBaqnU/Dy8FNoP35f6DQqay/f/PS+Ta3CvtA==@linaro.org X-Google-Smtp-Source: AGHT+IHN7w13shPWjklhjvP1j5ldKXyAyL8VYSzJ3ZfEkZWKWj9IabhjIFBiiFTPyIGt84M9QEJN X-Received: by 2002:ac8:5a11:0:b0:460:9b2b:e8b5 with SMTP id d75a77b69052e-46c70fd38cdmr411664911cf.4.1736854772880; Tue, 14 Jan 2025 03:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736854772; cv=none; d=google.com; s=arc-20240605; b=UQ/ZVk5X7lFladexjYVBYXtsfzUSSLPEPRyPr0d0dGeazx3jy/+KSXDEIbJez1yLSU Pf5aPD6D4RFfxFCX34WEods2EOzjflZIIt48fAo7ySC1FJtcAX3raxhPmZyahgqjXno7 5m53co/Bw5oiIS907/JsfL1PgPT68NrCIRph3zIaOQ66WQio66JOFuLNHQQVnlYVyTZ4 i4KszCp/qxDX/gLbSJ5+ZeMw7EyeHvn93lAaHHZQOjY6IBjqDiLH7ZbC8AHjQ6hFRT6m RRlmjPrfwXkd89I/UeF9qOIdn1CGsPG1Dnk2aymZ4ikxGknNI+BXPC5+N7jTThrXaNOO V1ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=2F/PrPslSIW6Y9g5K7Gs/QX6OA8vuL+PxeLCYDC6PuY=; fh=kybcMgHu6G3G1kz+Iwx2Y7lVQ4lMSqWHrwHMI/PcVVA=; b=DxvI6mc+bmj6K0sMqKrR9Bmdir33SrBvs/5q3BosOZIO22bl/0rp+52hAdTUqDfLoQ 545qzCgs6NUrGfaYc25sbIV3nhw4bWNylRXqeabuR18pqkbvFmDwX/pyCBnI/O/WIocW TQAUyFTHbUsv2AHbzoAX/GUfodqQxKMMphZwr9NakzBgsRvXKi5n/RykW7ABGTYtm8av SvHW5HvDoiqe/R2VrA571fyrHX+ZZ+1yKCu5m4rOlBZBW4U51JM3+5YhRAYgF/4FqRWP tqu7JGuHqKBTQWGeBuxdkOV4eMbeudUCxzCKDMKGFDjBTBiXdTqi1BJ/KZTilnSkPF/X 337g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AnAWZm3/"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46c873e5432si112727931cf.326.2025.01.14.03.39.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jan 2025 03:39:32 -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="AnAWZm3/"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXfFs-0005Bw-32; Tue, 14 Jan 2025 06:38:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXfFk-00057r-Qh for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:39 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXfFi-0005RB-1M for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:36 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-aaf6b1a5f2bso155155366b.1 for ; Tue, 14 Jan 2025 03:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736854712; x=1737459512; 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=2F/PrPslSIW6Y9g5K7Gs/QX6OA8vuL+PxeLCYDC6PuY=; b=AnAWZm3/ZQ0KCgzdufvHJBAb7uSvEPMiKF0VQAYTHgwj/4O1RZCdN60fMItA7HPnkY Z7jIxIwvIKFFwx/uefWOwnGdxtPcnKQKbEDhsjlLvcvcc3N06iiUVKJVLPguEKlv3CHz XJFpFn4YmSVwR43mG/yYQ3wGMqslO1BZiwpwEBNuCcfPTnADv7LMMQryW2oGLsRCmzWs 4bBgwkUgN2Otl9/oR2v3RnSvpCOovQwpov3GOvAGekNJ9AnXBu/D9y/fvWl/kSOhgGJf vpYrp0ygjLULB5cNU7s16VOLhxHLpEBC0AwwsQnzscXO+exrQUrNE1KV8qT8Jtvyy1C5 XWNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736854712; x=1737459512; 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=2F/PrPslSIW6Y9g5K7Gs/QX6OA8vuL+PxeLCYDC6PuY=; b=CT8rjsiwudBdVOuNHI9cRJV0S2NJi/dZQLtjbtbXe69UzRemBoPQrj9P/atFiKt/TF R4A4YL4i9SPK+cwddS7AnC9IyKsqDgKPA9+4XXgJP1wbj00LlS6DoUShbDCXuvaueFsl flFppHHwFmJv3kZ3ooTPAa+95JnIz1O/AlVpBGP13zgk6T/IV0LCD9FtFGFBmqcTqXH6 Y3XIXcysX8gsGO7SdNd1k5tbdKFUFx3qza/WCn1jMLiR7CGG1JrOGcG2XaYjqd2MGXBT SRFP9CioBFRCgsHPwbgbQq48g/sIXkbLYbIMWcriQMosbFJAFSYg3qbBu2zXrceo/TBJ RrUw== X-Gm-Message-State: AOJu0YwBrR4Az1k1FvNBPFnu9Q+qH5XLqTpY4+6+t4i3AZ3iPjl0MacB 1nyrdA00eYeiDAAjl3zpXCqkqDrQZWMlYzF6fKxcH42ip4ydEmWfIZVqT+cMsRc= X-Gm-Gg: ASbGncvnAdxsIux+xaO86RGIRiNGTMNb+GA7YCYxv9fYxt5AaUGXGWLRST+UQ+/xuRc 7j4s0+UxOl8/hv2Zod4PgbS6vOReeFPTpr0V690gdql7gI3s0B01rmBngi75YkahpRO9Bz20atE 7viffvccgV8SzvYMFLRY1iCs/UkVXxjv+EyE2lv/vZTZniyEAv9pUTIDzJmG7xwxilP4OZHHWYe yiY8OxCd+BZGEg4SX85svAemIYsdZc1nPXUU6Gqdl66RxwZKNL21BM= X-Received: by 2002:a17:907:7b86:b0:aa6:8dcb:365b with SMTP id a640c23a62f3a-ab2c3c5c979mr1787868166b.5.1736854711979; Tue, 14 Jan 2025 03:38:31 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c95647absm615118466b.118.2025.01.14.03.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 03:38:28 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5B34A5F89C; Tue, 14 Jan 2025 11:38:23 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v2 17/37] contrib/plugins/hotblocks: fix 32-bit build Date: Tue, 14 Jan 2025 11:38:01 +0000 Message-Id: <20250114113821.768750-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250114113821.768750-1-alex.bennee@linaro.org> References: <20250114113821.768750-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62f.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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson Message-Id: <20241217224306.2900490-8-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- 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);