Re: [PATCH v7 1/2] perf tools c2c: Add annotation support to perf c2c report

From: Li, Tianyou

Date: Mon Oct 13 2025 - 09:43:27 EST


Hi Ravi,

Appreciated for your testing and the code. It works like magic. Learnt.

I compared the sample count, percentage and period by 't' in annotate browser, all numbers in perf c2c report aligned with perf report.

I am curious if we should update the evsel_hists->stats when perf_c2c__has_annotation return true. I will send out patch v8 soon.

Regards,

Tianyou

On 10/13/2025 4:52 PM, Ravi Bangoria wrote:
On 11-Oct-25 1:46 PM, Tianyou Li wrote:
Perf c2c report currently specified the code address and source:line
information in the cacheline browser, while it is lack of annotation
support like perf report to directly show the disassembly code for
the particular symbol shared that same cacheline. This patches add
a key 'a' binding to the cacheline browser which reuse the annotation
browser to show the disassembly view for easier analysis of cacheline
contentions.
I still see annotate browser title with samples/event count as 0.
Something like below (lightly tested) should fix it. Can you please
check?


--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -299,6 +299,18 @@ static bool perf_c2c__has_annotation(struct perf_hpp_list *list)
return !list || list->sym;
}
+static void perf_c2c__evsel_hists_inc_stats(struct evsel *evsel,
+ struct hist_entry *he,
+ struct perf_sample *sample)
+{
+ struct hists *evsel_hists = evsel__hists(evsel);
+
+ hists__inc_nr_samples(evsel_hists, he->filtered);
+ evsel_hists->stats.total_period += sample->period;
+ if (!he->filtered)
+ evsel_hists->stats.total_non_filtered_period += sample->period;
+}
+
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_sample *sample,
@@ -363,6 +375,9 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
hists__inc_nr_samples(&c2c_hists->hists, he->filtered);
if (perf_c2c__has_annotation(NULL))
addr_map_symbol__inc_samples(mem_info__iaddr(mi), sample, evsel);
+
+ perf_c2c__evsel_hists_inc_stats(evsel, he, sample);
+
ret = hist_entry__append_callchain(he, sample);
if (!ret) {

Thanks,
Ravi