All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Jiebin Sun <jiebin.sun@intel.com>, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 01/14] perf c2c: extract shared data structures into c2c.h
Date: Thu, 16 Jul 2026 10:51:01 -0700	[thread overview]
Message-ID: <alkaBTSMVXPWMJW6@google.com> (raw)
In-Reply-To: <20260626071353.3931C1F000E9@smtp.kernel.org>

Hello,

On Fri, Jun 26, 2026 at 07:13:52AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> - [Medium] Missing feature fallback inline stubs for SLANG-dependent functions in header.
> - [Medium] Asymmetric memory management API leading to potential resource leaks.
> - [Medium] Global namespace pollution with generic function names.
> --
> 
> commit e451cf21befaafcbe2925718151023dd5ccba2cc
> Author: Jiebin Sun <jiebin.sun@intel.com>
> 
> perf c2c: extract shared data structures into c2c.h
> 
> This patch moves c2c_hists, compute_stats, c2c_hist_entry, and perf_c2c
> structure definitions from builtin-c2c.c into a new shared header c2c.h.
> This allows the upcoming function view browser to reuse these types.
> 
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index c9584dbedf77a..33271554e354b 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> [ ... ]
> > @@ -141,9 +76,9 @@ static const struct option c2c_options[] = {
> >  	OPT_END()
> >  };
> >  
> > -static struct perf_c2c c2c;
> > +struct perf_c2c c2c;
> >  
> > -static void *c2c_he_zalloc(size_t size)
> > +void *c2c_he_zalloc(size_t size)
> >  {
> >  	struct c2c_hist_entry *c2c_he;
> 
> [Severity: Medium]
> By exporting c2c_he_zalloc(), is there a risk of memory leaks since a
> corresponding free function is not exported?
> 
> Looking at the rest of c2c_he_zalloc() in builtin-c2c.c, it allocates several
> sub-structures:
> 
>     c2c_he->cpuset = bitmap_zalloc(c2c.cpus_cnt);
>     ...
>     c2c_he->nodeset = bitmap_zalloc(c2c.nodes_cnt);
>     ...
>     c2c_he->node_stats = calloc(c2c.nodes_cnt, sizeof(*c2c_he->node_stats));
> 
> Any external module (like the new function view) that uses this allocator
> won't have an encapsulated way to clean these up, forcing manual duplication
> of the teardown logic to avoid leaks.
> 
> [ ... ]
> > @@ -1928,7 +1816,7 @@ static struct c2c_dimension *dimensions[] = {
> >  	NULL,
> >  };
> >  
> > -static void fmt_free(struct perf_hpp_fmt *fmt)
> > +void fmt_free(struct perf_hpp_fmt *fmt)
> >  {
> >  	struct c2c_fmt *c2c_fmt;
> >  
> > @@ -1936,7 +1824,7 @@ static void fmt_free(struct perf_hpp_fmt *fmt)
> >  	free(c2c_fmt);
> >  }
> >  
> > -static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
> > +bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
> 
> [Severity: Medium]
> Could the removal of the static keyword here lead to symbol collisions?
> 
> Since fmt_free() and fmt_equal() lack a subsystem prefix (like c2c_ or
> perf_c2c_), exporting these generic names to the global namespace increases
> the risk of collisions during static linking or Link-Time Optimization with
> other perf tool objects.

I think this is a meaningful.  Even without collisions, it'd be better
to have a prefix for global functions.

Thanks,
Namhyung

> 
> > diff --git a/tools/perf/c2c.h b/tools/perf/c2c.h
> > new file mode 100644
> > index 0000000000000..3e974dd1d7ee6
> > --- /dev/null
> > +++ b/tools/perf/c2c.h
> [ ... ]
> > +#ifdef HAVE_SLANG_SUPPORT
> > +int perf_c2c__browse_cacheline(struct hist_entry *he);
> > +#endif
> 
> [Severity: Medium]
> Should this header provide a fallback stub for perf_c2c__browse_cacheline()
> when HAVE_SLANG_SUPPORT is not defined?
> 
> The perf subsystem build guidelines require header files to provide
> compatible dummy inline stubs (e.g., returning -ENOTSUPP) when feature
> defines are absent. Omitting the #else block here might lead to missing
> functionality or build breakages on systems lacking SLANG.
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260626070355.1556721-1-jiebin.sun@intel.com?part=1

  reply	other threads:[~2026-07-16 17:51 UTC|newest]

Thread overview: 71+ 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-07-16 17:51     ` Namhyung Kim [this message]
2026-07-17  1:43       ` Jiebin Sun
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-13  9:22       ` Jiebin Sun
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
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
2026-07-17  2:05   ` [PATCH v3 00/14] perf c2c: add a function view Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 01/14] perf c2c: extract shared data structures into c2c.h Jiebin Sun
2026-07-17  2:14       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 02/14] perf c2c: add function view browser skeleton Jiebin Sun
2026-07-17  2:15       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 03/14] perf c2c: add function view type definitions and helpers Jiebin Sun
2026-07-17  2:15       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 04/14] perf c2c: add column format infrastructure for function view Jiebin Sun
2026-07-17  2:21       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 05/14] perf c2c: add column entry functions " Jiebin Sun
2026-07-17  2:19       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 06/14] perf c2c: add comparison functions for function view sorting Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 07/14] perf c2c: add dimension definitions and format creation Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 08/14] perf c2c: add HPP list parsing for function view histograms Jiebin Sun
2026-07-17  2:22       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 09/14] perf c2c: add stats merging and memory management helpers Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 10/14] perf c2c: add hierarchy entry creation and lookup functions Jiebin Sun
2026-07-17  2:20       ` sashiko-bot
2026-07-17  2:05     ` [PATCH v3 11/14] perf c2c: add function view hierarchy builder Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 12/14] perf c2c: add function view browser UI Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 13/14] perf c2c: add TAB key to switch to function view Jiebin Sun
2026-07-17  2:05     ` [PATCH v3 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=alkaBTSMVXPWMJW6@google.com \
    --to=namhyung@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.