From patchwork Thu Jan 16 16:02:46 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: 857917 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:cc8:b0:385:e875:8a9e with SMTP id dq8csp281716wrb; Thu, 16 Jan 2025 08:14:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUJwFT9jY6BQ99f2ynB4ravjB7FUJQiZJPvHFECSvJ4XKNKfjI2g7J83JupIFLnqG6PlpYDmA==@linaro.org X-Google-Smtp-Source: AGHT+IHtkP5neilH9WIuicx4W3OCHkmseRogT7CcVijT/rvuZt0VMqKwNvKNRHf5f2brTm8ttjJ/ X-Received: by 2002:a05:690c:6711:b0:6ef:60db:5e8d with SMTP id 00721157ae682-6f531223024mr262329837b3.4.1737044050546; Thu, 16 Jan 2025 08:14:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737044050; cv=none; d=google.com; s=arc-20240605; b=O3OW8CjLYVesJfqNblNJwumMXFk/vhwxstutvoUuPhIakbuoS+tP2U64JLR2WRxdnd aSVqc3QjWxbGVXs44jLBz8sImpTweKZgJXHW0pp7W+Erxl6pBX4HN8d7iHpbyMRvACX3 Gen1Q0cm1ofzgvEdDAE8tv+a2eQeXbK6qxgY+Rqe8eG9GxT7KPAd/ejI+0nCLfJobSTU F929PcF4t3wII1bjfpYVV9iaX4dQ9Exq5OuU5/fpGDzrJZJB8/I+pLg1XBdTeX+XGTtW jHjpMNRQx1Ho7ivUZTFntLEcG/cL6zXmCkkpbU9PPQ+LblciULxzOPqLf/Nv7SA/5zQi cd1g== 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=LWJxUxOPIoAG7kV40OipmNLMiNyFM+gQ1dWz4vBqJQ4=; b=BuN7SuB6tiSlU6Por1iIZd2N+dw9OCWfIeN9UhkI27d/ngflmKVuXviieoE73j5gD5 Z2jQhi4SZ6pUoHfnK45VPDRmcZDz5lpNT38e8wIxCgMT+Ua13IlfPhz7m5WrLk0tWKPX TMFys/mhPGNxc7O/o0B5djd++vz0RqHlotNsNGgVIzU06t2UsipHywzQ7leTTHGk/7kt +VV/6voP9msoI16x3qHeoleAeVlBf76Konash8pIiQ+E1Fk1MYu1TvmdliLPx+xk/lfI 8IhD83IX/D8ZpRZuKg35910VhVJLePlN/bER0viPv9Mrz9mdzjiYd3ByRqOQCB8RL7TQ MRKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Pc3/ma2A"; 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 00721157ae682-6f6e66d93cfsi3974567b3.288.2025.01.16.08.14.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jan 2025 08:14: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="Pc3/ma2A"; 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 1tYSVF-0006XQ-HS; Thu, 16 Jan 2025 11:13:53 -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 1tYSTk-0003aw-Pm for qemu-devel@nongnu.org; Thu, 16 Jan 2025 11:12:23 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tYSTf-0004TD-8Y for qemu-devel@nongnu.org; Thu, 16 Jan 2025 11:12:20 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4368a293339so11745275e9.3 for ; Thu, 16 Jan 2025 08:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737043933; x=1737648733; 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=Pc3/ma2Apvo4MIo7xCUs2rjDR+MBhM4s7bWKDDQDI7YAVtAJGr41x9EhBpqyL0O8J1 yIt1192HFLoVvBpG/hlbPvgJTUQ05p8BDqSaLGTi9cXbSeU8kiflHfbVdHKCkY9Xly8k 12Xc8qBwqGsLjNnrcuNA6kLqQ/2ox9/iCLV71uV9YvZfQnR/rEmMj0htvjnbMeKKYo67 8vXHnVO3Upfhv4iDzsRhya7ZKba6MSEWcyALq0cx7GBsXlmxsDs6CgO4u9csdlOt5y1R I6UDqycKBUKB1e/0lqyIlJyswDdksy22PoO83UlNMJQ2v/xw9Zx810qb/oAjOiBrJa1V thKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737043933; x=1737648733; 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=oIGz2bFf6l7nDFesumM10SNQBzKJ+x0nPM/aDkKEKfmH/wxV8jgJXYchSfzimv8JQ9 T7UmWHLWyZaaKtK74swXGVKTI288DyZVL3EJfnAxJOI7/7knBGbozUkEZcJvMexbDzq+ 9WHyVa8Hod4SVN3fRUR7ZvSSsUlye/kikYhre5sZG/RfAdI9Da4uL8VMQW+gX83NN17W PUef6vPpmdjG3U+kzds9jQ7oXEi3MGQI95Cow187ufV0nmvBAGjyG9bWvMNwpWN3oHPj O4enUFAoB2NguEx0ZtTlqddAo3l9FlSLeUxlDvjSk+NqewxDDutxohdvW5tUR5WQ39f6 oVsQ== X-Gm-Message-State: AOJu0Yyhf4abfaukrhta/x+W6sPBSvSCx70u5G+qJR2J+zNtXjkLIdNQ LeMq2JqQVPf5VJbi9ls5NLVfgD0bswqmX1p3SJhf8/beBlV0aAAcjgMQZspumEg= X-Gm-Gg: ASbGncsvXGgXGN6wneKuALDeh3rMnvWdG/YK6qoaPv3mGAo7uzTk7HBEtEVqRQDpOO3 enKBDazwKWiNbSY7sC7Q2ETklUgLAyBsUft7hESMeT6zc79HKJeeYYCo9U4Hw6eU6aPt4uA0Zqr V6itpPUPojm09AQzWR0uvSbq0+AkLJYmlVxEPVVdzsjpo5VJNZfB2xReV8kCsT8YkhiMqihPBid cOpliqAqR8ZOyiSLU/1oGnNLS66DWKXtZbFH2KxNwDeCWPBf8GbzsM= X-Received: by 2002:a5d:584f:0:b0:385:f638:c68a with SMTP id ffacd0b85a97d-38a8730b738mr29985496f8f.30.1737043933410; Thu, 16 Jan 2025 08:12:13 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43890408a66sm3915205e9.5.2025.01.16.08.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 08:12:11 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1F85B608B4; Thu, 16 Jan 2025 16:03:08 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Markus Armbruster , Yuri Benditovich , Jason Wang , Cleber Rosa , "Dr. David Alan Gilbert" , Peter Xu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Stefano Garzarella , qemu-arm@nongnu.org, Michael Roth , Laurent Vivier , Mahmoud Mandour , Andrew Melnychenko , Konstantin Kostiuk , Kyle Evans , Richard Henderson , =?utf-8?q?Marc-Andr=C3=A9?= =?utf-8?q?_Lureau?= , John Snow , David Hildenbrand , Fabiano Rosas , Alexandre Iooss , Eric Blake , =?utf-8?q?Alex_Benn=C3=A9e?= , Vladimir Sementsov-Ogievskiy , Pierrick Bouvier , Kevin Wolf , Peter Maydell , Laurent Vivier , "Michael S. Tsirkin" , Thomas Huth , Warner Losh , =?utf-8?q?Dan?= =?utf-8?q?iel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 17/37] contrib/plugins/hotblocks: fix 32-bit build Date: Thu, 16 Jan 2025 16:02:46 +0000 Message-Id: <20250116160306.1709518-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250116160306.1709518-1-alex.bennee@linaro.org> References: <20250116160306.1709518-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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);