• Yang Jihong's avatar
    perf tools: Add printing perf_event_attr type symbol in perf_event_attr__fprintf() · 2e4dd65d
    Yang Jihong authored
    When printing perf_event_attr, always display perf_event_attr type and
    its symbol to improve the readability of debugging information.
    
    Before:
    
      # perf --debug verbose=2 record -e cycles,cpu-clock,sched:sched_switch,branch-load-misses,r101,mem:0x0 -C 0 true
      <SNIP>
      ------------------------------------------------------------
      perf_event_attr:
        size                             136
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
      ------------------------------------------------------------
      perf_event_attr:
        type                             1
        size                             136
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 6
      ------------------------------------------------------------
      perf_event_attr:
        type                             2
        size                             136
        config                           0x143
        { sample_period, sample_freq }   1
        sample_type                      IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 7
      ------------------------------------------------------------
      perf_event_attr:
        type                             3
        size                             136
        config                           0x10005
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 9
      ------------------------------------------------------------
      perf_event_attr:
        type                             4
        size                             136
        config                           0x101
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 10
      ------------------------------------------------------------
      perf_event_attr:
        type                             5
        size                             136
        { sample_period, sample_freq }   1
        sample_type                      IP|TID|TIME|CPU|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        sample_id_all                    1
        exclude_guest                    1
        bp_type                          3
        { bp_len, config2 }              0x4
      ------------------------------------------------------------
      <SNIP>
    
    After:
    
      # perf --debug verbose=2 record -e cycles,cpu-clock,sched:sched_switch,branch-load-misses,r101,mem:0x0 -C 0 true
      <SNIP>
      ------------------------------------------------------------
      perf_event_attr:
        type                             0 (PERF_TYPE_HARDWARE)
        size                             136
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
      ------------------------------------------------------------
      perf_event_attr:
        type                             1 (PERF_TYPE_SOFTWARE)
        size                             136
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 6
      ------------------------------------------------------------
      perf_event_attr:
        type                             2 (PERF_TYPE_TRACEPOINT)
        size                             136
        config                           0x143
        { sample_period, sample_freq }   1
        sample_type                      IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 7
      ------------------------------------------------------------
      perf_event_attr:
        type                             3 (PERF_TYPE_HW_CACHE)
        size                             136
        config                           0x10005
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 9
      ------------------------------------------------------------
      perf_event_attr:
        type                             4 (PERF_TYPE_RAW)
        size                             136
        config                           0x101
        { sample_period, sample_freq }   4000
        sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        freq                             1
        sample_id_all                    1
        exclude_guest                    1
      ------------------------------------------------------------
      sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 10
      ------------------------------------------------------------
      perf_event_attr:
        type                             5 (PERF_TYPE_BREAKPOINT)
        size                             136
        { sample_period, sample_freq }   1
        sample_type                      IP|TID|TIME|CPU|IDENTIFIER
        read_format                      ID
        disabled                         1
        inherit                          1
        sample_id_all                    1
        exclude_guest                    1
        bp_type                          3
        { bp_len, config2 }              0x4
      ------------------------------------------------------------
      <SNIP>
    Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
    Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: anshuman.khandual@arm.com
    Cc: mark.rutland@arm.com
    Cc: irogers@google.com
    Cc: jesussanp@google.com
    Cc: peterz@infradead.org
    Cc: acme@kernel.org
    Cc: jolsa@kernel.org
    Cc: alexander.shishkin@linux.intel.com
    Cc: mingo@redhat.com
    Link: https://lore.kernel.org/r/20230623054416.160858-4-yangjihong1@huawei.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    2e4dd65d
perf_event_attr_fprintf.c 6.06 KB