From patchwork Fri Jan 17 13:42:36 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: 858178 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:cc8:b0:385:e875:8a9e with SMTP id dq8csp704868wrb; Fri, 17 Jan 2025 05:44:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUWwPX9UQOsXGRq/psw+lg71Z8DdBuUyJsEiRY5JxPFq+kJHyyOp7BZSn/feJWqP4Q42QHXOw==@linaro.org X-Google-Smtp-Source: AGHT+IEwCvm4hRtlTaidEYCGmT7pG80T63+PhzwOMerH3BBi3wCtYGbHGkRq8G9yer+XN1D2uf4I X-Received: by 2002:a05:6214:4b0f:b0:6e1:a36b:3445 with SMTP id 6a1803df08f44-6e1b21857c6mr52450466d6.19.1737121477759; Fri, 17 Jan 2025 05:44:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737121477; cv=none; d=google.com; s=arc-20240605; b=RJezN8OI/LhFVSUTbJi2pBPsdSUYvBorOjx0tTkP2VYPSoKV7++TZdHoa2iz3AM1Fv o4c/ZiMXiKtWtuYooV3MnPZvkaeGox770a9sMoB6XhTQplt06RLscH7rOswXRi4V4/fu h5saZ5RCgWmRyHO3T3FZFnQ7/JiZVKhACCwRNl4+csZQvPRzeBiXQ9sgAW7IT+pgkbsD FP+Kh5THPRsROd4tTgJPxGUKTeOAQwgBaumIHF14BW44XD4dY9NlzCXTl9SOIkzdYa/R v496gZhZHXu1CIpu225D+40fJlJaC6RPFjabahbZBHHgi6vFVbFOVJ041Ce7/M/bLNL+ e3FQ== 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=zp1WT9YSEVD+JiobR2XNVwHS259ESWVfvYJkMEpr24k=; fh=yu0InTeBwSZcLajIY49SmB6DXvx9wTO9ThO8p5pbR7k=; b=AAhB8+ElZEil1ylVEZPqj0FXLVH3C8a0SeXm646WJXpra9Sob4aZSxaCmDrdGCO9s+ UZaiF5K1cY7mbMZgOJSZHqXLk7GTnjetbYVmtUIscn9byyFLh95cTxLc48zpGBPcjDnM NRyzbhol55C4VDJjHkgEK42L1Ljb7ZEh2OxKk4elRSV7Kb4QTAGvfFl6U4p2DQIFXhct I029RVBr+9JUj8Vy5zOB5bLHdbRzt8/1kwpte1o6fMQJ+1teORzQUvH+ygCh+/NiVUA+ 0+a1a4f1CSvy1YiXPXk9R5CE6634/iHjiaGIa3H34yUrXURZyH3mGjiMVGT84yZfgUdO 2Z2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tiMTOEca; 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 6a1803df08f44-6e1afbfad0fsi25415286d6.92.2025.01.17.05.44.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Jan 2025 05:44:37 -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=tiMTOEca; 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 1tYmdM-0001Gy-Ap; Fri, 17 Jan 2025 08:43:36 -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 1tYmcw-0000zm-Tg for qemu-devel@nongnu.org; Fri, 17 Jan 2025 08:43:11 -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 ) id 1tYmcu-0002Dy-81 for qemu-devel@nongnu.org; Fri, 17 Jan 2025 08:43:10 -0500 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5d3dce16a3dso1065104a12.1 for ; Fri, 17 Jan 2025 05:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737121385; x=1737726185; 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=zp1WT9YSEVD+JiobR2XNVwHS259ESWVfvYJkMEpr24k=; b=tiMTOEcaNlqmjOTANFWEHUpKWBRw5+j2mIwQmF0WYgH4G4Sat5hI2qQ+E1j8gko/cw FL2c5c5Kt4qudVkPejUSN7VKQmhA7Gm45JejIwIm+qJIdmxxQfM43Z2W/o3lhTwqbmEE TXF8T22zTKoorXiQ9KB8CFSi7n/rzGlMyTAP3zIuqjqmVC5A0ZyMBKu9WQIi/WsBA5bM Dx9IEgN1pFtM95q8zkHcYIvosgVaeZlyJGdB1jarLRLPeidGqdkCPgE2YXKOHVz1yfT0 O4PtubUE6oXNJUzv2wSpz3zR9hLzjyWQxSa7sUbsEArB4itiDyZTcI7ulinkf3jdtgZ/ BdEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737121385; x=1737726185; 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=zp1WT9YSEVD+JiobR2XNVwHS259ESWVfvYJkMEpr24k=; b=Ocxpy5kc7jHVz7lcbsoh4gRqs3eZhoSRXn3SfI/TCnYEBJyEKE6QvQ6UBwDvp4+Rp8 896S4+W7gHf5MltKDKS3T5Bth7+GO+8Fgzq9Cym506tziIH+5b5o1TwWTNl+dGsW+qQM v+uiYhI/sIGN8ngKBllej+rqmB97UFf+7+SLiy2IicUEcG8biuXg8XbYd1lD2RxpVJnV h5tU4eI7c/In5g1azm3dGEAkcMVxaZcxIYVMYl9TW3W3LSf8FL6wGz5iAKjGNn23wZFh uRZbUxFFEgI4GWABYFquIYcdEgPHA5ElpqsQ1u7fwhrhGa3m76TOBb6vhl7RknaciqVu tLsA== X-Gm-Message-State: AOJu0Yz0vwlof1/yCgcm6iTFlSmudlbqpbgbcg6Y/MoAkFtE0zZlL6H0 YcewtwrfoCLGBNLoZ58j9ZnfNKWaJeL0kbr4csf5cU09MZ7vNIXFghranakCgW0= X-Gm-Gg: ASbGncuSTAqjiPkir8Sr/Lx8z8mGnlb3eAL+YgrSC7ndXc+V/eQYYQkg9/2ZgocsoFX eABxiI7V/ZZS7N/BHh1RrXYdc+XQz+n1cOTZ5ptKNUsDh/5Tsgnxn7UUr0hzFgn+Cxn4c539Ai/ BrNXut1S5c3uN+mjtY+Aw0RyXXArvXiO//emutxvLuK3bxeR88NAqcC0Wa/ggqd6VjXCjSs5XU2 49Ve8uJWOYzDn4XWUmHybBcPo5UVT30MTcmOg18xv45U91ZvdL4kWRcNuWoA5lKzw+R X-Received: by 2002:a05:6402:5188:b0:5d0:d06b:cdc4 with SMTP id 4fb4d7f45d1cf-5db7dd0c8f6mr2075132a12.15.1737121385256; Fri, 17 Jan 2025 05:43:05 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5db73642c1asm1487113a12.5.2025.01.17.05.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:43:04 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 80FD3608B7; Fri, 17 Jan 2025 13:42:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 17/37] contrib/plugins/hotblocks: fix 32-bit build Date: Fri, 17 Jan 2025 13:42:36 +0000 Message-Id: <20250117134256.2079356-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250117134256.2079356-1-alex.bennee@linaro.org> References: <20250117134256.2079356-1-alex.bennee@linaro.org> MIME-Version: 1.0 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: 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 Message-Id: <20250116160306.1709518-18-alex.bennee@linaro.org> 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);