Re: [PATCH 15/48] perf report: Add 'type' sort key

From: Namhyung Kim
Date: Tue Oct 24 2023 - 15:12:04 EST


On Mon, Oct 23, 2023 at 9:53 AM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Em Wed, Oct 11, 2023 at 08:50:38PM -0700, Namhyung Kim escreveu:
> > The 'type' sort key is to aggregate hist entries by data type they
> > access. Add mem_type field to hist_entry struct to save the type.
> > If hist_entry__get_data_type() returns NULL, it'd use the
> > 'unknown_type' instance.
>
> Needed the patch below, doing the same that is a bit before for
> libtraceevent

I think it can always return unknown_type if libtraceevent is not
enabled. Maybe I need to move the definition here then.

Thanks,
Namhyung

>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index c79564c1d5df5db3..3fae226d115ef8e6 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2132,6 +2132,7 @@ struct sort_entry sort_addr = {
> .se_width_idx = HISTC_ADDR,
> };
>
> +#ifdef HAVE_DWARF_SUPPORT
> /* --sort type */
>
> static int64_t
> @@ -2190,7 +2191,7 @@ struct sort_entry sort_type = {
> .se_snprintf = hist_entry__type_snprintf,
> .se_width_idx = HISTC_TYPE,
> };
> -
> +#endif // HAVE_DWARF_SUPPORT
>
> struct sort_dimension {
> const char *name;
> @@ -2246,7 +2247,9 @@ static struct sort_dimension common_sort_dimensions[] = {
> DIM(SORT_LOCAL_RETIRE_LAT, "local_retire_lat", sort_local_p_stage_cyc),
> DIM(SORT_GLOBAL_RETIRE_LAT, "retire_lat", sort_global_p_stage_cyc),
> DIM(SORT_SIMD, "simd", sort_simd),
> +#ifdef HAVE_DWARF_SUPPORT
> DIM(SORT_ANNOTATE_DATA_TYPE, "type", sort_type),
> +#endif
> };
>
> #undef DIM