From patchwork Thu Jan 9 17:06:14 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: 855970 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1334918wra; Thu, 9 Jan 2025 09:08:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUUukeu2+NrXWz2iQpiyn4Obdo9T2JQkcUuXA5BfdbQWElRDMoGHpQshOzHW6BjN9phLwZOIQ==@linaro.org X-Google-Smtp-Source: AGHT+IFJDJWN0RC5et2GOBjT4bkaeot2QVSjDNHcbb6z5B54CiL3zOF/p/iEs/XMecpwAqTlYsEb X-Received: by 2002:a05:6102:370f:b0:4b3:c658:2a36 with SMTP id ada2fe7eead31-4b3d0f8f840mr6202106137.8.1736442501209; Thu, 09 Jan 2025 09:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736442501; cv=none; d=google.com; s=arc-20240605; b=I0w9IfPz1YXaIAFm7G4sORvB+PLEqVQ1KnO0mfLTP9fhlGDoGIu48dMeHSc3PrdFnb kyGz/K7Ox+Q5nbfitCHPNUDhorMsu21LvyaXJbsJ3PfZpo8TXO7o0BKIGXrQLciKOdv+ CG6JKPc9cGevhDHomvRYXTlnOqCafPWJOI5zhNa9E5bjrgGp0VT9BEUHFPdGpwrSzJse m5ccjsz18A7Cyy2ktBjIPJ/QyRBr1gl2qbLm24/EBu62khNlx0fTgQ9MTeZVQgQB4gGV 0J8hnhFkuI+BD4GoUx4zx2jcYPsZYZqjmq7kgQYf8r1hdEj/pR3Ka5R/sjiP0x4WINqE C+Dw== 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=FS+JTz/k+Dh1PAd9s6lkEQMFdt/HYT5+zFPDR3GvHJ0=; b=h9roIFK1YGo1w9/DcIu+wtDPJa+p3iNK2zmXa0FqitlCYbKFfArCb6Ay+BnWGA7c1u Cm5Nso2zeCYF6yRmXfie+4EKd3B702yzSIUrlSK9wbowUP1OrOiLG6HXGyFB14N77B1N MSoohuxL5Xz+SJYUEb4XOR89sJmVUzNw/qhj5lzn59E2gVNhDb1Ie6c8HSVv71g5az/T L7HTEJwjxmRAni5kBWlAaKQot7EP7rCwprciIq+ROcunCqzdP5xSwXRiJva6nQDrrMwb no+WiEIyur//IRjxKR9lprK+pyBbtHp8OuFIJyk7MI1+ujC2pS8SQzvFVzkP1bBfRx9L YezQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iriQPbtt; 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 ada2fe7eead31-4b6093810dcsi742480137.584.2025.01.09.09.08.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 09:08: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=iriQPbtt; 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 1tVvzj-0004oG-NI; Thu, 09 Jan 2025 12:06:55 -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 1tVvze-0004l3-Vs for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:50 -0500 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVvzd-00072B-95 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:50 -0500 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-aab6fa3e20eso222923466b.2 for ; Thu, 09 Jan 2025 09:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736442408; x=1737047208; 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=iriQPbttMtiUPNR7aL0ojXwpi9tYW/wZyZgXaG/hyZ6wLIkkT5fA318dcga0MeSDnV 7s795eJiYjXFtGbPryTAvWK1Q4XLL67CYgzr3mu9AaY/6/blLWLNU+rfu3KMKdGcnBqJ 9Qme2C+9IvuBlShBX2EBfCAPgolDKQCHLVf7WiQ4VoIYwHoyngd7Nhe3NeiZbxRcQFY1 wNZmF/3YHefefArnLL9IJ3vd1mZNtnGebVL+cXUzyKkPvH9uo0tnTiILCx29AxS3kzfl 9BNaaFTzjvDv0zDBnY9WHPt5B1lFeR4ANv2mky3tFXg/6kuJ7FWpVyNMdmWeWRhz3/nI Ty2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736442408; x=1737047208; 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=WLJhgrqs9izeae8C8Oude4/7s2VHqWoaHKHBlvUxWTpq3v44Vdj865J6fqX3fPArNZ 2kMSALSzV1Rq5CK1eQiHqmP9BNEgUaXngbl1JD12P/JU4BHsVQ624vFaDv+jNcBqpNAP Dowm4RjN1mrRZ2Thja+bKgCn3CYu6ZmK1J1v8nkmleY2vHnis3kpfeEJRNFVgsb6vvP2 VCVNnmkRV2rnh0J+Q4CpDZ4ZNkldagcOJJy5mqUeeQJXP4Y1J1OypU8ClSWLqD2tJ8+X eqsZ2ysWMLTFyMIpzqU3Q4DzRocW5hsLLcdCPbB8n94R4jE9JretwlHODfmkLnyNnfbc GkPw== X-Gm-Message-State: AOJu0YzgqedBRTwiGnZbnrtC0bSTYagV7LKAQ+addq3qU/wcqmKaGLsb acDd07WaL6RdJ7xFpC5b+EVAocPDCfY1rbIfXvr4+SUyaKR0yRhU+GkVQW/1xMw= X-Gm-Gg: ASbGncs+Po41Ax9DEAzscGxIJvAecoMhmSsBFjH9wl9lAZjs1t4WMSYu+7QBTmLzHT4 hqeF24bK07BCWWWZRucZ3dNZW4Ig0LgmeyDF7+vm04al6t650k1G4/kFS3t9RxsG2Ll2vt2rICl 5q4U7JEta/2bIYGXbzD7Ap+2QN8AOtUxLN7C+E+HIjO16p49QiIuw2SC9awAkT2HwkbV34G9SJ9 5vgOCKhlW0owmL3LyzePMd8a2r6e+1HyUcaCvATdZ15TZIGunOG7ww= X-Received: by 2002:a17:907:9687:b0:aa6:912f:7ec1 with SMTP id a640c23a62f3a-ab2abc779dcmr717675866b.39.1736442407621; Thu, 09 Jan 2025 09:06:47 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c96461dasm87969866b.168.2025.01.09.09.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 09:06:40 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 692BD606A6; Thu, 9 Jan 2025 17:06:21 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Thomas Huth , Mahmoud Mandour , Alexandre Iooss , Richard Henderson , Paolo Bonzini , Laurent Vivier , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 17/22] contrib/plugins/hotblocks: fix 32-bit build Date: Thu, 9 Jan 2025 17:06:14 +0000 Message-Id: <20250109170619.2271193-18-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 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x634.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);