linux/tools/perf
Namhyung Kim bdeaf6ffec perf annotate: Honor output options with --data-type
For data type profiling output, it should be in sync with normal output
so make it display percentage for each field.  Also use coloring scheme
for users to identify fields with big overhead easily.

Users can use --show-total-period or --show-nr-samples to change the
output style like in the normal perf annotate output.

Before:

  $ perf annotate --data-type
  Annotate type: 'struct task_struct' in [kernel.kallsyms] (34 samples):
  ============================================================================
      samples     offset       size  field
           34          0       9792  struct task_struct    {
            2          0         24      struct thread_info       thread_info {
            0          0          8          long unsigned int    flags;
            1          8          8          long unsigned int    syscall_work;
            0         16          4          u32  status;
            1         20          4          u32  cpu;
                                         };

After:

  $ perf annotate --data-type
  Annotate type: 'struct task_struct' in [kernel.kallsyms] (34 samples):
  ============================================================================
   Percent     offset       size  field
    100.00          0       9792  struct task_struct       {
      3.55          0         24      struct thread_info  thread_info {
      0.00          0          8          long unsigned int       flags;
      1.63          8          8          long unsigned int       syscall_work;
      0.00         16          4          u32     status;
      1.91         20          4          u32     cpu;
                                      };

Committer testing:

First collect a suitable perf.data file for use with 'perf annotate --data-type':

  root@number:~# perf mem record -a sleep 1s
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 11.047 MB perf.data (3466 samples) ]
  root@number:~#

Then, before:

  root@number:~# perf annotate --data-type
  Annotate type: 'union ' in /usr/lib64/libc.so.6 (6 samples):
  ============================================================================
      samples     offset       size  field
            6          0         40  union         {
            6          0         40      struct __pthread_mutex_s __data {
            2          0          4          int  __lock;
            0          4          4          unsigned int __count;
            0          8          4          int  __owner;
            1         12          4          unsigned int __nusers;
            2         16          4          int  __kind;
            1         20          2          short int    __spins;
            0         22          2          short int    __elision;
            0         24         16          __pthread_list_t     __list {
            0         24          8              struct __pthread_internal_list*  __prev;
            0         32          8              struct __pthread_internal_list*  __next;
                                             };
                                         };
            0          0          0      char*    __size;
            2          0          8      long int __align;
                                     };
  <SNIP>

And after:

  Annotate type: 'union ' in /usr/lib64/libc.so.6 (6 samples):
  ============================================================================
   Percent     offset       size  field
    100.00          0         40  union    {
    100.00          0         40      struct __pthread_mutex_s    __data {
     31.27          0          4          int     __lock;
      0.00          4          4          unsigned int    __count;
      0.00          8          4          int     __owner;
      7.67         12          4          unsigned int    __nusers;
     53.10         16          4          int     __kind;
      7.96         20          2          short int       __spins;
      0.00         22          2          short int       __elision;
      0.00         24         16          __pthread_list_t        __list {
      0.00         24          8              struct __pthread_internal_list*     __prev;
      0.00         32          8              struct __pthread_internal_list*     __next;
                                          };
                                      };
      0.00          0          0      char*       __size;
     31.27          0          8      long int    __align;
                                  };
  <SNIP>

The lines with percentages >= 7.67 have its percentages red colored.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
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: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240322224313.423181-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-04-03 11:48:56 -03:00
..
arch perf cpumap: Use perf_cpu_map__for_each_cpu when possible 2024-03-21 10:41:28 -03:00
bench libperf cpumap: Replace usage of perf_cpu_map__new(NULL) with perf_cpu_map__new_online_cpus() 2023-12-12 14:55:13 -03:00
dlfilters perf dlfilter: Add a test for object_code() 2023-09-30 00:09:06 -07:00
Documentation perf docs arm_spe: Clarify more SPE requirements related to KPTI 2024-03-21 10:41:27 -03:00
include/perf perf dlfilter: Add al_cleanup() 2023-08-15 16:41:49 -03:00
jvmti
pmu-events perf vendor events intel: Remove info metrics erroneously in TopdownL1 2024-03-21 13:54:40 -03:00
python
scripts perf scripts python arm-cs-trace-disasm.py: Do not ignore disam first sample 2023-12-20 14:31:59 -03:00
tests perf tests: Run tests in parallel by default 2024-03-21 13:54:40 -03:00
trace perf beauty: Move uapi/linux/vhost.h copy out of the directory used to build perf 2024-03-21 20:44:35 -03:00
ui perf annotate: Calculate instruction overhead using hashmap 2024-03-06 20:25:20 -08:00
util perf dso: Reorder members to save space in 'struct dso' 2024-03-21 20:44:35 -03:00
.gitignore perf build: Shellcheck support for OUTPUT directory 2023-12-05 15:46:43 -03:00
Build
builtin-annotate.c perf annotate: Honor output options with --data-type 2024-04-03 11:48:56 -03:00
builtin-bench.c perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
builtin-buildid-cache.c perf buildid-cache: Fix use of uninitialized value 2023-10-12 10:01:56 -07:00
builtin-buildid-list.c
builtin-c2c.c perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty 2024-03-21 10:41:28 -03:00
builtin-config.c
builtin-daemon.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c libperf cpumap: Replace usage of perf_cpu_map__new(NULL) with perf_cpu_map__new_online_cpus() 2023-12-12 14:55:13 -03:00
builtin-help.c
builtin-inject.c perf record: Lazy load kernel symbols 2023-11-09 13:49:32 -03:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-kwork.c perf kwork: Fix a build error on 32-bit 2023-11-21 10:02:38 -08:00
builtin-list.c perf list: Allow wordwrap to wrap on commas 2024-03-21 10:41:29 -03:00
builtin-lock.c perf lock: Fix a memory leak on an error path 2023-11-27 10:21:27 -03:00
builtin-mem.c perf mem: Clean up perf_pmus__num_mem_pmus() 2024-01-24 14:05:22 -08:00
builtin-probe.c
builtin-record.c perf record: Delete session after stopping sideband thread 2024-03-21 13:54:39 -03:00
builtin-report.c perf report: Sort child tasks by tid 2024-03-03 22:50:55 -08:00
builtin-sched.c perf sched: Move curr_pid and cpu_last_switched initialization to perf_sched__{lat|map|replay}() 2024-02-09 14:08:41 -08:00
builtin-script.c perf script: Show also errors for --insn-trace option 2024-03-21 10:41:27 -03:00
builtin-stat.c perf stat: Remove duplicate cpus_map_matched function 2024-03-21 10:41:28 -03:00
builtin-timechart.c
builtin-top.c Merge branch 'perf-tools' into perf-tools-next 2024-02-12 12:19:21 -08:00
builtin-trace.c perf trace: Fix 'newfstatat'/'fstatat' argument pretty printing 2024-03-21 13:54:40 -03:00
builtin-version.c perf version: Display availability of OpenCSD support 2024-03-03 22:48:40 -08:00
builtin.h perf tools: Suggest inbuilt commands for unknown command 2024-03-21 13:54:40 -03:00
check-headers.sh perf beauty: Move uapi/linux/vhost.h copy out of the directory used to build perf 2024-03-21 20:44:35 -03:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config treewide: remove meaningless assignments in Makefiles 2024-02-23 14:19:07 -08:00
Makefile.perf perf beauty: Move uapi/linux/vhost.h copy out of the directory used to build perf 2024-03-21 20:44:35 -03:00
MANIFEST tools perf: Add arm64 sysreg files to MANIFEST 2023-11-22 11:17:53 -08:00
perf-archive.sh perf archive: Add new option '--unpack' to expand tarballs 2023-12-20 13:20:45 -03:00
perf-completion.sh perf shell completion: Support completion of metrics/metricgroups 2023-09-11 10:26:36 -03:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf tools: Suggest inbuilt commands for unknown command 2024-03-21 13:54:40 -03:00
perf.h