Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiebin Sun" <jiebin.sun@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 07/14] perf c2c: add dimension definitions and format creation
Date: Fri, 26 Jun 2026 07:23:13 +0000	[thread overview]
Message-ID: <20260626072313.98DC31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626070355.1556721-8-jiebin.sun@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The c2c_se_cmp wrapper improperly forces fmt->sort to use dim->se->se_cmp instead of dim->se->se_sort.
--

commit 160d3ea9bf317fa78359c422d21e9cf0a3470f5a
Author: Jiebin Sun <jiebin.sun@intel.com>

perf c2c: add dimension definitions and format creation

This patch adds function view dimension definitions that bind column names
to their rendering and comparison functions. It also introduces lookup and
format creation helpers for the function view.

> diff --git a/tools/perf/ui/browsers/c2c-function.c b/tools/perf/ui/browsers/c2c-function.c
> index 172e1aa86ecab..794a023239ce1 100644
> --- a/tools/perf/ui/browsers/c2c-function.c
> +++ b/tools/perf/ui/browsers/c2c-function.c

[ ... ]

> @@ -390,6 +390,125 @@ total_stores_cmp(struct perf_hpp_fmt *fmt __maybe_unused,

[ ... ]

> +/* Wrappers so sort_entry-backed dimensions sort/collapse via their se. */
> +static int64_t c2c_se_cmp(struct perf_hpp_fmt *fmt,
> +			  struct hist_entry *a, struct hist_entry *b)
> +{
> +	struct c2c_fmt *c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
> +	struct c2c_dimension *dim = c2c_fmt->dim;
> +
> +	return dim->se->se_cmp(a, b);
> +}
> +
> +static int64_t c2c_se_collapse(struct perf_hpp_fmt *fmt,
> +			       struct hist_entry *a, struct hist_entry *b)
> +{
> +	struct c2c_fmt *c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
> +	struct c2c_dimension *dim = c2c_fmt->dim;
> +	int64_t (*collapse_fn)(struct hist_entry *a, struct hist_entry *b);
> +
> +	collapse_fn = dim->se->se_collapse ?: dim->se->se_cmp;
> +	return collapse_fn(a, b);
> +}
> +
> +static __maybe_unused struct c2c_fmt *get_function_format(const char *name)
> +{
> +	struct c2c_dimension *dim = get_function_dimension(name);
> +	struct c2c_fmt *c2c_fmt;
> +	struct perf_hpp_fmt *fmt;
> +
> +	if (!dim)
> +		return NULL;
> +
> +	c2c_fmt = zalloc(sizeof(*c2c_fmt));
> +	if (!c2c_fmt)
> +		return NULL;
> +
> +	fmt = &c2c_fmt->fmt;
> +
> +	c2c_fmt->dim = dim;
> +	INIT_LIST_HEAD(&fmt->list);
> +	INIT_LIST_HEAD(&fmt->sort_list);
> +
> +	fmt->cmp	= dim->se ? c2c_se_cmp : dim->cmp;
> +	fmt->sort	= dim->se ? c2c_se_cmp : dim->cmp;

[Severity: Medium]
Does this assignment incorrectly bypass the sort_entry's se_sort callback?

Because c2c_se_cmp strictly calls dim->se->se_cmp:

static int64_t c2c_se_cmp(struct perf_hpp_fmt *fmt,
                          struct hist_entry *a, struct hist_entry *b)
{
        ...
        return dim->se->se_cmp(a, b);
}

Using c2c_se_cmp for fmt->sort means we will use se_cmp instead of se_sort.
For example, sorting by the symbol column might sort by memory address offset
rather than alphabetically by symbol name.

Should there be a separate c2c_se_sort wrapper that delegates to
dim->se->se_sort, or similar logic?

> +	fmt->color	= dim->color;
> +	fmt->entry	= dim->entry;
> +	fmt->header	= c2c_header;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626070355.1556721-1-jiebin.sun@intel.com?part=7

  reply	other threads:[~2026-06-26  7:23 UTC|newest]

Thread overview: 23+ 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 [this message]
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

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=20260626072313.98DC31F000E9@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