From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Xudong Hao <xudong.hao@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [Patch v2 2/5] perf c2c: Fix top-level histogram ownership check
Date: Mon, 9 Nov 2026 08:43:59 +0800 [thread overview]
Message-ID: <20261109004402.1403713-3-dapeng1.mi@linux.intel.com> (raw)
In-Reply-To: <20261109004402.1403713-1-dapeng1.mi@linux.intel.com>
The function set_node_width() incorrectly determined whether a c2c
histogram entry belonged to the top-level cacheline view by checking
if &c2c.hists equals c2c_he->hists.
This comparison is always false for top-level entries because
c2c_he->hists is only assigned for lazily-created sub-histograms in
he__get_c2c_hists(). Top-level entries are instead stored under
he->hists, which points to the embedded struct hists inside c2c.hists.
Add a dedicated helper, c2c_he__is_main_hist(), to check whether a
c2c_hist_entry belongs to the top-level histogram tree and use it to
update the node width accordingly for top-level cachelines view or
per-cacheline view.
Fixes: 7f834c2e84bb ("perf c2c report: Display node for cacheline address")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
tools/perf/builtin-c2c.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index f51fa23f3bf1..a0c9afddbe98 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2233,11 +2233,19 @@ static inline bool is_valid_hist_entry(struct hist_entry *he)
return has_record;
}
+static inline bool c2c_he__is_main_hist(struct c2c_hist_entry *c2c_he)
+{
+ struct hists *hists = c2c_he->he.hists;
+
+ return hists &&
+ container_of(hists, struct c2c_hists, hists) == &c2c.hists;
+}
+
static void set_node_width(struct c2c_hist_entry *c2c_he, int len)
{
struct c2c_dimension *dim;
- dim = &c2c.hists == c2c_he->hists ?
+ dim = c2c_he__is_main_hist(c2c_he) ?
&dim_dcacheline_node : &dim_offset_node;
if (len > dim->width)
--
2.34.1
next prev parent reply other threads:[~2026-11-09 0:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 0:43 [Patch v2 0/5] perf: fix test error and improve c2c memory-region display Dapeng Mi
2026-11-09 0:43 ` [Patch v2 1/5] perf tests: Skip zero sample IP in object-code reading test Dapeng Mi
2026-11-09 0:43 ` Dapeng Mi [this message]
2026-11-09 0:44 ` [Patch v2 3/5] perf c2c: Show memory region in the per-cacheline view Dapeng Mi
2026-11-09 0:44 ` [Patch v2 4/5] perf c2c: Show all memory regions in the region column Dapeng Mi
2026-11-09 0:44 ` [Patch v2 5/5] perf c2c: Rename "Region" column to "Range" for consistency Dapeng Mi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109004402.1403713-3-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
--cc=zide.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®