]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf annotate-data: Show offset and size in hex
authorNamhyung Kim <namhyung@kernel.org>
Mon, 19 Aug 2024 23:36:02 +0000 (16:36 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 21 Aug 2024 14:48:39 +0000 (11:48 -0300)
It'd be better to have them in hex to check cacheline alignment.

 Percent     offset       size  field
  100.00          0      0x1c0  struct cfs_rq    {
    0.00          0       0x10      struct load_weight  load {
    0.00          0        0x8          long unsigned int       weight;
    0.00        0x8        0x4          u32     inv_weight;
                                    };
    0.00       0x10        0x4      unsigned int        nr_running;
   14.56       0x14        0x4      unsigned int        h_nr_running;
    0.00       0x18        0x4      unsigned int        idle_nr_running;
    0.00       0x1c        0x4      unsigned int        idle_h_nr_running;
  ...

Committer notes:

Justification from Namhyung when asked about why it would be "better":

Cache line sizes are power of 2 so it'd be natural to use hex and
check whether an offset is in the same boundary.  Also 'perf annotate'
shows instruction offsets in hex.

>
> Maybe this should be selectable?

I can add an option and/or a config if you want.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240819233603.54941-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/annotate-data.c
tools/perf/util/annotate-data.c
tools/perf/util/sort.c

index f563a3bb072ca5e99e53bdea875f557b8f5cf909..cd562a8822b7f2d76aa8b1aae1bfb7dc90b10a4d 100644 (file)
@@ -427,12 +427,12 @@ static void browser__write(struct ui_browser *uib, void *entry, int row)
 
        /* print type info */
        if (be->indent == 0 && !member->var_name) {
-               ui_browser__printf(uib, " %10d %10d  %s%s",
+               ui_browser__printf(uib, " %#10x %#10x  %s%s",
                                   member->offset, member->size,
                                   member->type_name,
                                   list_empty(&member->children) || be->folded? ";" : " {");
        } else {
-               ui_browser__printf(uib, " %10d %10d  %*s%s\t%s%s",
+               ui_browser__printf(uib, " %#10x %#10x  %*s%s\t%s%s",
                                   member->offset, member->size,
                                   be->indent * 4, "", member->type_name,
                                   member->var_name ?: "",
index f5eefcb71c4f13058e21955d86cdd5cc010c9ff0..1e8328dde72070a23733773f521d2c0d30a77018 100644 (file)
@@ -1704,7 +1704,7 @@ static void print_annotated_data_type(struct annotated_data_type *mem_type,
                nr_events++;
        }
 
-       printf(" %10d %10d  %*s%s\t%s",
+       printf(" %#10x %#10x  %*s%s\t%s",
               member->offset, member->size, indent, "", member->type_name,
               member->var_name ?: "");
 
index c4046d5d1749bf830e764679cf90d47176bad6af..d315308f9170899b3b4021bc8a41f7b876b09440 100644 (file)
@@ -2312,7 +2312,7 @@ static int hist_entry__typeoff_snprintf(struct hist_entry *he, char *bf,
                                 he->mem_type_off, true);
        buf[4095] = '\0';
 
-       return repsep_snprintf(bf, size, "%s %+d (%s)", he_type->self.type_name,
+       return repsep_snprintf(bf, size, "%s +%#x (%s)", he_type->self.type_name,
                               he->mem_type_off, buf);
 }