From patchwork Thu Jan 9 17:06:16 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: 855987 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1337678wra; Thu, 9 Jan 2025 09:13:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV6pc3RiztPxkWD+HS2ixooy5qWWaf4wTTrenHxmTcn9pupS7GmMNJhmoHGMH0t4AUNHEqj6w==@linaro.org X-Google-Smtp-Source: AGHT+IGmpeD2vnrr4vMmIF/VJ4l1/XruGzTRegd0FM3PaQlr8VoJAuKZXd0mCterNvtGAfhpbkl9 X-Received: by 2002:a05:620a:2b9c:b0:7b6:d23a:be39 with SMTP id af79cd13be357-7bcd97a7077mr1254552685a.44.1736442837110; Thu, 09 Jan 2025 09:13:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736442837; cv=none; d=google.com; s=arc-20240605; b=S6lR2OKn8NPF/n3N4PlWgZK2JKHJBKZPBB5pjcsn6ra3K6t1onP14sIArFTUwfTXUr jYho1Fxo5of7+To5495GuDNzbehdRUeOx8zeRQSu84YM1Q9nrWK2vJyhiDn3GngGv62t GusxEp7wIR7g00oK+Qz0siX2EsqdeNxMqZEBsvpsiUrUZvxbglPLikUOpBR2tNLzuffO hHMq4UtoJDBQx9cdz0hjVkaeEegNnTo1HJDRQjlH1EKiBrErgtn/+Jr1eeRLg9iPY7aM IFfUpcoNTIL2wcQU8Cz/pVG43UyVBtHffoRWEu0r/+j2Lb5OBLIBleY3RL12rmn1W91s Muxw== 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=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=; fh=FS+JTz/k+Dh1PAd9s6lkEQMFdt/HYT5+zFPDR3GvHJ0=; b=fdz2sGjxTL+h/7t8vHapsa8vBekIJLMrPPs4KbHmnkIFh7c1YNwLXoGNHVlWnPLgjy fZFNbwPeio9f12i77z9b70sSEcVtRmw0U7cmKDWaTBAvDd3W1dOwCz7thodD2v8wDfkh FuIm42y2M+QfajtshfK7VAumAr7yDAZnzNfC6cerRB2w3LRw2z61sLuw68e5N1FrAH5+ BDFO4pwlsThTNnKykBBE5LJlcHCqdF9Tnf0U04OLNJZE3juuTJvfE7vHrOuFxiCmZJ30 Um8+I15pCuJo4+U9HlCmW4sCbyThaGNUOLb9/yFim+8AXE2TbFt8V98wxIyOHhIXoQ+N Vo/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jkdp2baG; 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 af79cd13be357-7bce350a260si189297085a.581.2025.01.09.09.13.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 09:13:57 -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=jkdp2baG; 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 1tVw61-0007Ow-Je; Thu, 09 Jan 2025 12:13:25 -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 1tVw5z-0007OD-65 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:13:23 -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 1tVw5x-0007un-Es for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:13:22 -0500 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5d3bbb0f09dso1820958a12.2 for ; Thu, 09 Jan 2025 09:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736442800; x=1737047600; 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=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=; b=jkdp2baGInpfO0Ycpo2mnIyayCx1pRbLmKwpdLxMoxkOnkofNhmjSVDyoVR6+nhfyz Dr097ZqWlKxV/sM3pkBE5aQ2IkWBjTmaKyvU9w81I1TtVoFS3jzfs3ZB9U6PnsJXhE6x 62eSvO2iz3tH0bEACl0We6yRxpmnlfeOPVxAbjOIyOJPbda243Qf+5J314aCSdRwAiaV kafxX/ZZGumbhDRMIz5vQJcRxURyGGRhRceOSE+pL4ZyaVvA9Yib1Ye4pdZAPP/nzC74 HEh/39SpDFAgTE/RFOE6/G9gjGfEJKREJQKw9M6o2kvQU9+jOLJbm5f/LM3gRBDpBfb3 X9fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736442800; x=1737047600; 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=kTnA9glybPs3zdhSbJS9OZOTx27Sx361JrQqUOFibUA=; b=AhdvF169T62IwxzpDxeywputU9FsZZbzqwaYN3GS9N6mZN6dF8+04+qyUwbjl9hRMV jwCz4HloUHUyOEaPzLlriP+JWauAe9WaU8IUPL7pw4qZGLJia7TnTCBKrSCahDEcXXh9 L1CvhUP2BEPpOXU0hbum1bYkdLHi71ZaaQHf/2MptV5wlC2l4ANoLh3yd5Pq2wnPGqCW i9Eb+vXaec2rNwFxUmfWFJAnRssRB5MZHg4Fn0PUGssFOJZhINPfXw60JGffVAt1os3n /vo8Vn+AHUfP2OmQRheftqr4ZclWsE/WoX+/wAp/Q6nlV1rcD2UXw5Qy4goAYqFWnPl+ YGeg== X-Gm-Message-State: AOJu0YwrcoxM5chd/mnEWU/ymLW1vwtlF0lF1+BbWHpeXHntyMOgqVLd sxPj6lUny4mTbQFusty3GbYyQxe06K5uNnOSTP6IFSnY5qRapiNObVBocz9U/Ck= X-Gm-Gg: ASbGnctClqpoHhzF/0szASwWmXmLfk8fzRNvd/huZUoGwOKrWB9+6ttzUWwMQeucejY EuYkciKNLhIS/KjAUl3q9/VaRR52UkSs6GCjMXHl2D3uAD/IuUkFuPpMcGIHqQPGyyaXqmGWAD+ 3VxqRqlC5eK/S/nK/AVGQjjUD2Y0nmFGrel37vZ6okRtq2zE9F+MBniNKMX78lkGX2f2H2OEtQZ PD8D5U6bOF8mZcxVBTCcu0jdVVzWHdhSu2yyPIoLBR9OYz1VJtsdgs= X-Received: by 2002:a17:906:c143:b0:aae:8490:9363 with SMTP id a640c23a62f3a-ab2ab7408a4mr733026066b.34.1736442799922; Thu, 09 Jan 2025 09:13:19 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9060f9asm89365066b.1.2025.01.09.09.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 09:13:17 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 95FED609F2; 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 19/22] contrib/plugins/hwprofile: fix 32-bit build Date: Thu, 9 Jan 2025 17:06:16 +0000 Message-Id: <20250109170619.2271193-20-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::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 Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20241217224306.2900490-10-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- contrib/plugins/hwprofile.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/contrib/plugins/hwprofile.c b/contrib/plugins/hwprofile.c index 739ac0c66b..2a4cbc47d4 100644 --- a/contrib/plugins/hwprofile.c +++ b/contrib/plugins/hwprofile.c @@ -43,6 +43,8 @@ typedef struct { static GMutex lock; static GHashTable *devices; +static struct qemu_plugin_scoreboard *source_pc_scoreboard; +static qemu_plugin_u64 source_pc; /* track the access pattern to a piece of HW */ static bool pattern; @@ -159,7 +161,7 @@ static DeviceCounts *new_count(const char *name, uint64_t base) count->name = name; count->base = base; if (pattern || source) { - count->detail = g_hash_table_new(NULL, NULL); + count->detail = g_hash_table_new(g_int64_hash, g_int64_equal); } g_hash_table_insert(devices, (gpointer) name, count); return count; @@ -169,7 +171,7 @@ static IOLocationCounts *new_location(GHashTable *table, uint64_t off_or_pc) { IOLocationCounts *loc = g_new0(IOLocationCounts, 1); loc->off_or_pc = off_or_pc; - g_hash_table_insert(table, (gpointer) off_or_pc, loc); + g_hash_table_insert(table, &loc->off_or_pc, loc); return loc; } @@ -224,12 +226,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, /* either track offsets or source of access */ if (source) { - off = (uint64_t) udata; + off = qemu_plugin_u64_get(source_pc, cpu_index); } if (pattern || source) { IOLocationCounts *io_count = g_hash_table_lookup(counts->detail, - (gpointer) off); + &off); if (!io_count) { io_count = new_location(counts->detail, off); } @@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) for (i = 0; i < n; i++) { struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); - gpointer udata = (gpointer) (source ? qemu_plugin_insn_vaddr(insn) : 0); + if (source) { + uint64_t pc = qemu_plugin_insn_vaddr(insn); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, QEMU_PLUGIN_INLINE_STORE_U64, + source_pc, pc); + } qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr, - QEMU_PLUGIN_CB_NO_REGS, - rw, udata); + QEMU_PLUGIN_CB_NO_REGS, rw, NULL); } } @@ -306,10 +312,9 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, return -1; } - /* Just warn about overflow */ - if (info->system.smp_vcpus > 64 || - info->system.max_vcpus > 64) { - fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n"); + if (source) { + source_pc_scoreboard = qemu_plugin_scoreboard_new(sizeof(uint64_t)); + source_pc = qemu_plugin_scoreboard_u64(source_pc_scoreboard); } plugin_init();