Re: [PATCH v8 6/9] perf c2c: add function view hierarchy entry creation
Namhyung Kim <[email protected]>
| Newsgroups | org.kernel.vger.linux-perf-users,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 10, 2026 at 01:26:44PM +0800, Jiebin Sun wrote: > Add the entry-creation layer: owned-reference child allocation and > insertion, and the level-1/2/3 lookup-or-create functions keyed by > function symbol (level 1 read-side, level 2 writer) and by the source > cacheline's existing index (level 3). > > Give synthetic children normal entry operations and acquire their thread > and map-symbol references. This lets the hierarchy teardown use > hist_entry__delete() for the common fields while the function-view free > callback handles the private child tree and containing allocation. > > Reuse cacheline_idx to preserve the source entry identity without adding > function-view-only state. The browser can later use the same index to find > the original cacheline entry. > > These are driven by the hierarchy builder in the next patch and are > __maybe_unused until then. > > Signed-off-by: Jiebin Sun <[email protected]> > Cc: Adrian Hunter <[email protected]> > Cc: Alexander Shishkin <[email protected]> > Cc: Arnaldo Carvalho de Melo <[email protected]> > Cc: Dapeng Mi <[email protected]> > Cc: Ian Rogers <[email protected]> > Cc: Ingo Molnar <[email protected]> > Cc: James Clark <[email protected]> > Cc: Jiri Olsa <[email protected]> > Cc: Mark Rutland <[email protected]> > Cc: Namhyung Kim <[email protected]> > Cc: Peter Zijlstra <[email protected]> > Cc: Thomas Falcon <[email protected]> > Reviewed-by: Tianyou Li <[email protected]> > Reviewed-by: Wangyang Guo <[email protected]> > --- > tools/perf/ui/browsers/c2c-function.c | 293 +++++++++++++++++++++++++- > 1 file changed, 282 insertions(+), 11 deletions(-) > > diff --git a/tools/perf/ui/browsers/c2c-function.c b/tools/perf/ui/browsers/c2c-function.c > index 4bf8406fde55..4099d4c7e7b4 100644 > --- a/tools/perf/ui/browsers/c2c-function.c > +++ b/tools/perf/ui/browsers/c2c-function.c > @@ -28,6 +28,7 @@ > #include "../../util/addr_location.h" > #include "../../util/cacheline.h" > #include "../../util/debug.h" > +#include "../../util/dso.h" > #include "../../util/hist.h" > #include "../../util/map.h" > #include "../../util/mem-events.h" > @@ -57,12 +58,34 @@ static inline __maybe_unused u64 c2c_hitm_count(const struct c2c_stats *stats) > return stats->tot_hitm; > } > > -static inline __maybe_unused bool symbol_name_equal(struct symbol *a, struct symbol *b) > +static int64_t c2c_function_cmp(const struct map_symbol *left, > + const struct map_symbol *right) > { > - /* Two unknown symbols compare equal, matching cmp_null() in util/sort.c. */ > - if (!a || !b) > - return a == b; > - return arch__compare_symbol_names(a->name, b->name) == 0; > + const struct dso *left_dso = left->map ? map__dso(left->map) : NULL; > + const struct dso *right_dso = right->map ? map__dso(right->map) : NULL; > + int ret; > + > + if (!left_dso || !right_dso) { > + if (left_dso != right_dso) > + return left_dso ? 1 : -1; What if both DSOs are NULL? Thanks, Namhyung > + } else { > + /* > + * Use the same DSO name as _sort__dso_cmp() (short name unless > + * verbose), so this matches the DSO comparison the level-1 > + * entries are deduplicated by; otherwise same-basename DSOs > + * could be split or merged inconsistently across levels. > + */ > + const char *left_name = verbose > 0 ? > + dso__long_name(left_dso) : dso__short_name(left_dso); > + const char *right_name = verbose > 0 ? > + dso__long_name(right_dso) : dso__short_name(right_dso); > + > + ret = strcmp(left_name, right_name); > + if (ret) > + return ret; > + } > + > + return _sort__sym_cmp(left->sym, right->sym); > }