From patchwork Tue Dec 17 01:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 851402 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp110343wrq; Mon, 16 Dec 2024 17:09:15 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXMl+yb1GeVFuDHYQk+u75WYQzz4JD/YtdwfmXH2ZOJeZlXeIho8s1jG50wWBkLKgHpurL/Uw==@linaro.org X-Google-Smtp-Source: AGHT+IFXL4pge/+LEiyRGd8XkZl7c1yAfR67HkxGwhp1jk1lbAD6kcZCGE5sK5LaZaazh9325sFt X-Received: by 2002:a05:620a:2992:b0:7b6:d6e5:ac62 with SMTP id af79cd13be357-7b6fbecc660mr2292038685a.6.1734397755617; Mon, 16 Dec 2024 17:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734397755; cv=none; d=google.com; s=arc-20240605; b=N5D0FHBbIiShrCj6lZtd52C6ltyE40u2ujvjvl4XcKszYae6gzNGdm8AweWgH6QEwh XdoYJ2k1MGfZKCpkG7jA+TQNoFj9ldwULTkMurOHjfPcqsp9RIWWVsZGUBanImE1GrhS a9XDq1/sB/DKB94/fdbh3gmYYHPI44uMCUO/jMYIojj4QAOtOG8I1ooBNtcDilcD8E9N oYHxmyBgE1PaIYfaqH1T035Wucumf9aZ/QS0D+qSWnhyR6/eG7p21YL9fy4mXjH5FzT0 5VpFA8fvTqSqXqUQ3e7Ndwj6MQV22Zq7OC/k3pcLlg3f12MYXF0ScKpjgwViCg3CPcwa 5Jfg== 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=crzqjDJBZdpI+EWDwy4Pgv4ZHNVlbcwq1nqGrijGMLQ=; fh=CFa3ou2Ry4mS7fTsZUswJFlbz+fCeIacXufDVqA7iAo=; b=UH4Bp24TOff2Vh75nNFUI8bCDFJW34WMRX7Q4bYNF+xruT8VeDd3t5s85aPe0rgufC VjiAD+pfqsV71of4HKH6Stwzd+rlheydimtW+d9C44H0Qb/e0W17eVqUNmunblAxoOta Zl6Dzirz1ZLJY/F16Z+6IP/gFXSVfPdkiBwkPkATC/kJDXREMsko1E6BibGMW9xVKnxm JP/l5izTbiDL37y0Wcz7Xba8ESzbFJB630zhWcxdFrMHkg7ULy2wd36RBjku3F3IrcVZ rkg8pezArm55rHs5rTUolUYFMHjjSJEJYZf9gkn2UjfeZeGtXhmhPBpQe3wfofCh8HYM gmXw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=afI4yBFZ; 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-7b7047ca79dsi873475485a.124.2024.12.16.17.09.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Dec 2024 17:09:15 -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=afI4yBFZ; 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 1tNM3p-0008JU-Cs; Mon, 16 Dec 2024 20:07: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 1tNM3f-0008Ht-W3 for qemu-devel@nongnu.org; Mon, 16 Dec 2024 20:07:32 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNM3d-0004yy-Ht for qemu-devel@nongnu.org; Mon, 16 Dec 2024 20:07:31 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-725f4623df7so4079370b3a.2 for ; Mon, 16 Dec 2024 17:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734397648; x=1735002448; 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=crzqjDJBZdpI+EWDwy4Pgv4ZHNVlbcwq1nqGrijGMLQ=; b=afI4yBFZ37rqkhm56I+kuJ12HOAEO1J9MdQBQTT6Fpn9C+t5LVA9sPsIJ9Jd/bgd0D loJKgdexiNEALovJUSZuosIXaDVPjkqDUWCOICaGkfFlgM4VnV4msTJx7gii9+vOp1VK c7n6LtySy023mRsdDvNX4fEYC8EoHG0BeMzoJ2P9YnH86uF6BLgHjWqOkJly+VJ2RMbj ijHUA2mmkEko16+Oc7j1BJbfMZu0smBvjUYm3XFzeUsEEpzg0gha9mEz7of4K5+WyLUM rh1TkpeiZruSr+TamHuNwi8RN1pDFYRh6iqNvCrDYHdT0U7NNpLl9fQnfV2hKh3kJMMK 6DFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734397648; x=1735002448; 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=crzqjDJBZdpI+EWDwy4Pgv4ZHNVlbcwq1nqGrijGMLQ=; b=cpqgFKYSLh/tTrKWLIzcr6kOZX0TnycekLLtKwP9sQYOl0jUQlXbnq4LRyPMmxZg9h AdFgclaALupVZ7US9+mVkFKOOMIcDX5rs38yX2eUGktuxQSVDJkwhlsGs8qkLinJWMsV AsBXQ1Z1NdwSzj3gLtsPqfF/GGPA0iXxoYlsW9dc/95xAaW72Mz5YQR9ztCL3tlvf0oq csPXTKbubaqZyiYWTlzF6/i0sAu4z+4AJ0hFl8ZDJgRxx9XhVmtmMqtiSPe9nKE5yOxU QCgiTlDvaLezhH+D1ksxQUbk2YTQbo/ALtXcto41NIATGoQ5AdP9dAH95c25CZjx6gWS O3Yg== X-Gm-Message-State: AOJu0YxwFOs487Cr5INhp3PjvoA+PVRhJuK1+5bOLQVczf4QUJwrc3cF 08uRdG4M6RRHvJpOcXb90mNz+5BAhs+Z+wAvRhbAN2G0KAFbkEDH6KyRksbPGceDqxzjnvh8dpL ESMw= X-Gm-Gg: ASbGncvwunYAk+XXWASMoFzjyhz7MZQB8ZmE0sYL27R/DKSw3A9nAiaQIzLaLvv4Eqf dxVWSRGKPrapKsTxArRUxtYlB2tPxUC+cptWBzcksmWyY+my6TuRFWzmu2j/Uj1ZGiPNCW6YhaX gm30sB9ry0D1n2E3rFEn4i0HsJltCqOhsmulbDV3PxbOT3qwQPikJqbQMgHKmrwYtLYMCyLW6oa URevqO5nkVlX/Sr2T75irF9zAgnVGccGvXBGFEfw/tpnDyEGdh5eQZBMAazIh8DLKsoWj0RrVQY kD81v/5z6OhgoPo= X-Received: by 2002:a17:902:e545:b0:216:7ee9:2212 with SMTP id d9443c01a7336-218929ca98cmr207825885ad.23.1734397647842; Mon, 16 Dec 2024 17:07:27 -0800 (PST) Received: from pc.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-218a1e6d0e4sm48746595ad.261.2024.12.16.17.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 17:07:27 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, Pierrick Bouvier , Alexandre Iooss , Paolo Bonzini , Mahmoud Mandour , Thomas Huth , philmd@linaro.org Subject: [PATCH 11/13] contrib/plugins/hwprofile: fix 32-bit build Date: Mon, 16 Dec 2024 17:07:05 -0800 Message-Id: <20241217010707.2557258-12-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217010707.2557258-1-pierrick.bouvier@linaro.org> References: <20241217010707.2557258-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x429.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 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- 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 739ac0c66b5..2a4cbc47d40 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();