• Arnaldo Carvalho de Melo's avatar
    perf stat: Fallback to user only counters when perf_event_paranoid > 1 · 42ef8a78
    Arnaldo Carvalho de Melo authored
    After 0161028b ("perf/core: Change the default paranoia level to 2")
    'perf stat' fails for users without CAP_SYS_ADMIN, so just use
    'perf_evsel__fallback()' to have the same behaviour as 'perf record',
    i.e. set perf_event_attr.exclude_kernel to 1.
    
    Now:
    
      [acme@jouet linux]$ perf stat usleep 1
    
       Performance counter stats for 'usleep 1':
    
              0.352536      task-clock:u (msec)  #   0.423 CPUs utilized
                     0      context-switches:u   #   0.000 K/sec
                     0      cpu-migrations:u     #   0.000 K/sec
                    49      page-faults:u        #   0.139 M/sec
               309,407      cycles:u             #   0.878 GHz
               243,791      instructions:u       #   0.79  insn per cycle
                49,622      branches:u           # 140.757 M/sec
                 3,884      branch-misses:u      #   7.83% of all branches
    
           0.000834174 seconds time elapsed
    
      [acme@jouet linux]$
    Reported-by: default avatarIngo Molnar <mingo@kernel.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-b20jmx4dxt5hpaa9t2rroi0o@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    42ef8a78
builtin-stat.c 59.2 KB