• Jiri Olsa's avatar
    perf evsel: Fix max perf_event_attr.precise_ip detection · 4e8a5c15
    Jiri Olsa authored
    After a discussion with Andi, move the perf_event_attr.precise_ip
    detection for maximum precise config (via :P modifier or for default
    cycles event) to perf_evsel__open().
    
    The current detection in perf_event_attr__set_max_precise_ip() is
    tricky, because precise_ip config is specific for given event and it
    currently checks only hw cycles.
    
    We now check for valid precise_ip value right after failing
    sys_perf_event_open() for specific event, before any of the
    perf_event_attr fallback code gets executed.
    
    This way we get the proper config in perf_event_attr together with
    allowed precise_ip settings.
    
    We can see that code activity with -vv, like:
    
      $ perf record -vv ls
      ...
      ------------------------------------------------------------
      perf_event_attr:
        size                             112
        { sample_period, sample_freq }   4000
        ...
        precise_ip                       3
        sample_id_all                    1
        exclude_guest                    1
        mmap2                            1
        comm_exec                        1
        ksymbol                          1
      ------------------------------------------------------------
      sys_perf_event_open: pid 9926  cpu 0  group_fd -1  flags 0x8
      sys_perf_event_open failed, error -95
      decreasing precise_ip by one (2)
      ------------------------------------------------------------
      perf_event_attr:
        size                             112
        { sample_period, sample_freq }   4000
        ...
        precise_ip                       2
        sample_id_all                    1
        exclude_guest                    1
        mmap2                            1
        comm_exec                        1
        ksymbol                          1
      ------------------------------------------------------------
      sys_perf_event_open: pid 9926  cpu 0  group_fd -1  flags 0x8 = 4
      ...
    Suggested-by: default avatarAndi Kleen <ak@linux.intel.com>
    Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
    Link: http://lkml.kernel.org/n/tip-dkvxxbeg7lu74155d4jhlmc9@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    4e8a5c15
evlist.h 11.1 KB