From: sashiko-bot@kernel.org
To: "Jiebin Sun" <jiebin.sun@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 04/14] perf c2c: add column format infrastructure for function view
Date: Fri, 10 Jul 2026 09:00:02 +0000 [thread overview]
Message-ID: <20260710090003.5543C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710084247.3576706-5-jiebin.sun@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] Incorrect cycle estimation omits peer snoop cycles and misattributes them to generic loads.
- [Medium] Performance degradation via O(N) tree walk instead of utilizing the O(1) cached `child_stores` field.
- [Medium] Potential NULL pointer dereference in `symbol_width()` due to uninitialized `dim_symbol_view.se`.
--
--- Patch [4]: [PATCH v2 04/14] perf c2c: add column format infrastructure for function view ---
commit 27bafa4ad47ef7cdc864764ce3f927a10cdbbd23
Author: Jiebin Sun <jiebin.sun@intel.com>
perf c2c: add column format infrastructure for function view
This patch adds the column format plumbing functions used by all
function view dimensions. It introduces helper functions to calculate
column widths and render multi-line column headers.
> diff --git a/tools/perf/ui/browsers/c2c-function.c b/tools/perf/ui/browsers/c2c-function.c
> index dbc912a4a242b..d718cab6537d9 100644
> --- a/tools/perf/ui/browsers/c2c-function.c
> +++ b/tools/perf/ui/browsers/c2c-function.c
> @@ -66,6 +66,123 @@ static __maybe_unused inline u64 hist_entry__iaddr(struct hist_entry *he)
[ ... ]
> +static __maybe_unused int symbol_width(struct hists *hists, struct sort_entry *se)
> +{
> + int width = hists__col_len(hists, se->se_width_idx);
[Severity: Medium]
Can this dereference a null pointer?
When c2c_width() is called for dim_symbol_view:
c2c_width() {
...
if (dim == &dim_symbol_view)
return symbol_width(hists, dim->se);
}
The statically declared dim_symbol_view is uninitialized, so its se member
is null. Passing it here will cause an immediate pointer dereference
when accessing se->se_width_idx.
> +
> + if (!c2c.symbol_full && width > SYMBOL_WIDTH)
> + width = SYMBOL_WIDTH;
> +
> + return width;
> +}
[ ... ]
> +/*
> + * Return the estimated total cycles for a c2c_hist_entry
> + * (rmt_hitm + lcl_hitm + rmt_peer + lcl_peer + other loads).
> + */
> +static __maybe_unused u64 c2c_hist_entry__cycles(struct c2c_hist_entry *c2c_he)
> +{
> + double cycles_rmt, cycles_lcl, cycles_load;
> + u64 other_load, total_hitm;
> +
> + cycles_rmt = avg_stats(&c2c_he->cstats.rmt_hitm) * c2c_he->stats.rmt_hitm;
> + cycles_lcl = avg_stats(&c2c_he->cstats.lcl_hitm) * c2c_he->stats.lcl_hitm;
> + total_hitm = c2c_he->stats.tot_hitm;
> + other_load = (c2c_he->stats.load >= total_hitm) ? c2c_he->stats.load - total_hitm : 0;
> + cycles_load = avg_stats(&c2c_he->cstats.load) * other_load;
> +
> + return (u64)(cycles_rmt + cycles_lcl + cycles_load);
[Severity: Medium]
Is this cycle calculation omitting the peer snoop cycles?
The comment above this function states it includes rmt_peer and lcl_peer,
but the logic drops their averages. By only subtracting total_hitm from
stats.load, it leaves the peer snoop counts (tot_peer) in the other_load
remainder.
This appears to weight the peer counts with the generic cstats.load average
instead of multiplying rmt_peer and lcl_peer counts by their respective
latencies.
> +}
[ ... ]
> +/* Sum child entries' store counts under a level-1 hist_entry. */
> +static __maybe_unused u64 hist_entry__child_stores(struct hist_entry *he)
> +{
> + struct rb_node *nd;
> + u64 sum = 0;
> +
> + for (nd = rb_first_cached(&he->hroot_out); nd; nd = rb_next(nd)) {
> + struct hist_entry *child = rb_entry(nd, struct hist_entry, rb_node);
> + struct c2c_hist_entry *c2c_child =
> + container_of(child, struct c2c_hist_entry, he);
> +
> + sum += (u64)c2c_child->stats.store;
> + }
> + return sum;
[Severity: Medium]
Could this use the cached child_stores field instead of walking the tree?
This loop introduces a tree walk to sum the store counts on every
render cycle. The c2c_hist_entry structure has a child_stores field that
could provide this count in constant time, avoiding the need to iterate
over all children in hroot_out.
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710084247.3576706-1-jiebin.sun@intel.com?part=4
next prev parent reply other threads:[~2026-07-10 9:00 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 7:03 [PATCH 00/14] perf c2c: add a function view Jiebin Sun
2026-06-26 7:03 ` [PATCH 01/14] perf c2c: extract shared data structures into c2c.h Jiebin Sun
2026-06-26 7:13 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 02/14] perf c2c: add function view browser skeleton Jiebin Sun
2026-06-26 7:11 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 03/14] perf c2c: add function view type definitions and helpers Jiebin Sun
2026-06-26 7:14 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 04/14] perf c2c: add column format infrastructure for function view Jiebin Sun
2026-06-26 7:03 ` [PATCH 05/14] perf c2c: add column entry functions " Jiebin Sun
2026-06-26 7:03 ` [PATCH 06/14] perf c2c: add comparison functions for function view sorting Jiebin Sun
2026-06-26 7:22 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 07/14] perf c2c: add dimension definitions and format creation Jiebin Sun
2026-06-26 7:23 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 08/14] perf c2c: add HPP list parsing for function view histograms Jiebin Sun
2026-06-26 7:16 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 09/14] perf c2c: add stats merging and memory management helpers Jiebin Sun
2026-06-26 7:17 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 10/14] perf c2c: add hierarchy entry creation and lookup functions Jiebin Sun
2026-06-26 7:19 ` sashiko-bot
2026-06-26 7:03 ` [PATCH 11/14] perf c2c: add function view hierarchy builder Jiebin Sun
2026-06-26 7:03 ` [PATCH 12/14] perf c2c: add function view browser UI Jiebin Sun
2026-06-26 7:03 ` [PATCH 13/14] perf c2c: add TAB key to switch to function view Jiebin Sun
2026-06-26 7:03 ` [PATCH 14/14] perf c2c: document function view in perf-c2c man page Jiebin Sun
2026-07-07 0:41 ` [PATCH 00/14] perf c2c: add a function view Namhyung Kim
2026-07-10 8:49 ` Jiebin Sun
2026-07-10 21:54 ` Namhyung Kim
2026-07-10 8:42 ` [PATCH v2 " Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 01/14] perf c2c: extract shared data structures into c2c.h Jiebin Sun
2026-07-10 8:54 ` sashiko-bot
2026-07-10 8:42 ` [PATCH v2 02/14] perf c2c: add function view browser skeleton Jiebin Sun
2026-07-10 8:50 ` sashiko-bot
2026-07-10 8:42 ` [PATCH v2 03/14] perf c2c: add function view type definitions and helpers Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 04/14] perf c2c: add column format infrastructure for function view Jiebin Sun
2026-07-10 9:00 ` sashiko-bot [this message]
2026-07-10 8:42 ` [PATCH v2 05/14] perf c2c: add column entry functions " Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 06/14] perf c2c: add comparison functions for function view sorting Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 07/14] perf c2c: add dimension definitions and format creation Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 08/14] perf c2c: add HPP list parsing for function view histograms Jiebin Sun
2026-07-10 9:01 ` sashiko-bot
2026-07-10 8:42 ` [PATCH v2 09/14] perf c2c: add stats merging and memory management helpers Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 10/14] perf c2c: add hierarchy entry creation and lookup functions Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 11/14] perf c2c: add function view hierarchy builder Jiebin Sun
2026-07-10 9:01 ` sashiko-bot
2026-07-10 8:42 ` [PATCH v2 12/14] perf c2c: add function view browser UI Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 13/14] perf c2c: add TAB key to switch to function view Jiebin Sun
2026-07-10 8:42 ` [PATCH v2 14/14] perf c2c: document function view in perf-c2c man page Jiebin Sun
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=20260710090003.5543C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jiebin.sun@intel.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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