]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf annotate: Use annotation__pcnt_width() consistently
authorNamhyung Kim <namhyung@kernel.org>
Sat, 3 Aug 2024 21:13:30 +0000 (14:13 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Aug 2024 19:11:42 +0000 (16:11 -0300)
The annotation__pcnt_width() calculates the screen width for the
overhead (percent) area considering event groups properly.  Use this
function consistently so that we can make sure it has similar output
in different modes.  But there's a difference in stdio and tui output:
stdio uses 8 and tui uses 7 for a percent.

Let's use 8 and adjust the print width in __annotation_line__write()
properly.

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: 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/20240803211332.1107222-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c
tools/perf/util/annotate.h

index 09e6fdf344db810055d40ca6fadc8073028b4a29..917897fe44a283980afe38c28109d8c35d09622c 100644 (file)
@@ -699,13 +699,13 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
                       int percent_type)
 {
        struct disasm_line *dl = container_of(al, struct disasm_line, al);
+       struct annotation *notes = symbol__annotation(sym);
        static const char *prev_line;
 
        if (al->offset != -1) {
                double max_percent = 0.0;
                int i, nr_percent = 1;
                const char *color;
-               struct annotation *notes = symbol__annotation(sym);
 
                for (i = 0; i < al->data_nr; i++) {
                        double percent;
@@ -775,14 +775,11 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
        } else if (max_lines && printed >= max_lines)
                return 1;
        else {
-               int width = symbol_conf.show_total_period ? 12 : 8;
+               int width = annotation__pcnt_width(notes);
 
                if (queue)
                        return -1;
 
-               if (evsel__is_group_event(evsel))
-                       width *= evsel->core.nr_members;
-
                if (!*al->line)
                        printf(" %*s:\n", width, " ");
                else
@@ -1111,7 +1108,7 @@ int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel)
        int more = 0;
        bool context = opts->context;
        u64 len;
-       int width = symbol_conf.show_total_period ? 12 : 8;
+       int width = annotation__pcnt_width(notes);
        int graph_dotted_len;
        char buf[512];
 
@@ -1127,7 +1124,6 @@ int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel)
        len = symbol__size(sym);
 
        if (evsel__is_group_event(evsel)) {
-               width *= evsel->core.nr_members;
                evsel__group_desc(evsel, buf, sizeof(buf));
                evsel_name = buf;
        }
@@ -1703,10 +1699,10 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
                        if (symbol_conf.show_total_period) {
                                obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
                        } else if (symbol_conf.show_nr_samples) {
-                               obj__printf(obj, "%6" PRIu64 " ",
+                               obj__printf(obj, "%7" PRIu64 " ",
                                                   al->data[i].he.nr_samples);
                        } else {
-                               obj__printf(obj, "%6.2f ", percent);
+                               obj__printf(obj, "%7.2f ", percent);
                        }
                }
        } else {
index 9ba772f4627011c745eb4509ba53df09cc0d7f6f..64e70d716ff115dace647ec0e564abb27e593815 100644 (file)
@@ -339,7 +339,7 @@ static inline int annotation__cycles_width(struct annotation *notes)
 
 static inline int annotation__pcnt_width(struct annotation *notes)
 {
-       return (symbol_conf.show_total_period ? 12 : 7) * notes->src->nr_events;
+       return (symbol_conf.show_total_period ? 12 : 8) * notes->src->nr_events;
 }
 
 static inline bool annotation_line__filter(struct annotation_line *al)