1. 15 Jul, 2019 1 commit
  2. 12 Jul, 2019 1 commit
  3. 11 Jul, 2019 2 commits
  4. 10 Jul, 2019 21 commits
  5. 09 Jul, 2019 15 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Auto bump rlimit(MEMLOCK) for eBPF maps sake · c3e78a34
      Arnaldo Carvalho de Melo authored
      Circa v5.2 this started to fail:
      
        # perf trace -e /wb/augmented_raw_syscalls.o
        event syntax error: '/wb/augmented_raw_syscalls.o'
                             \___ Operation not permitted
      
        (add -v to see detail)
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      
      In verbose mode we some -EPERM when creating a BPF map:
      
        # perf trace -v -e /wb/augmented_raw_syscalls.o
        <SNIP>
        libbpf: failed to create map (name: '__augmented_syscalls__'): Operation not permitted
        libbpf: failed to load object '/wb/augmented_raw_syscalls.o'
        bpf: load objects failed: err=-1: (Operation not permitted)
        event syntax error: '/wb/augmented_raw_syscalls.o'
                             \___ Operation not permitted
      
        (add -v to see detail)
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      
      If we bumped 'ulimit -l 128' to get it from the 64k default to double that, it
      worked, so use the recently added rlimit__bump_memlock() helper:
      
        # perf trace -e /wb/augmented_raw_syscalls.o -e open*,*sleep sleep 1
             0.000 ( 0.007 ms): sleep/28042 openat(dfd: CWD, filename: "/etc/ld.so.cache", flags: RDONLY|CLOEXEC) = 3
             0.022 ( 0.004 ms): sleep/28042 openat(dfd: CWD, filename: "/lib64/libc.so.6", flags: RDONLY|CLOEXEC) = 3
             0.201 ( 0.007 ms): sleep/28042 openat(dfd: CWD, filename: "", flags: RDONLY|CLOEXEC)                 = 3
             0.241 (1000.421 ms): sleep/28042 nanosleep(rqtp: 0x7ffd6c3e6ed0)                                       = 0
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-j6f2ioa6hj9dinzpjvlhcjoc@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3e78a34
    • Arnaldo Carvalho de Melo's avatar
      perf test: Auto bump rlimit(MEMLOCK) for BPF test sake · d3280ce0
      Arnaldo Carvalho de Melo authored
      I noticed that the 'perf test bpf' was failing:
      
        # perf test bpf
        41: BPF filter                                            :
        41.1: Basic BPF filtering                                 : Skip
        41.2: BPF pinning                                         : Skip
        41.3: BPF prologue generation                             : Skip
        41.4: BPF relocation checker                              : Skip
        # ulimit -l
        64
        #
      
      Using verbose mode we get just a line bout -EPERF being returned from
      libbpf's bpf_load_program_xattr(), that ends up being used in 'perf
      test bpf' initial program loading capability query:
      
        Missing basic BPF support, skip this test: Operation not permitted
      
      Not that informative, but on a separate problem when creating BPF maps
      bumping rlimit(MEMLOCK) helped, so I tried it here as well, works:
      
        # ulimit -l 128
        # perf test bpf
        41: BPF filter                                            :
        41.1: Basic BPF filtering                                 : Ok
        41.2: BPF pinning                                         : Ok
        41.3: BPF prologue generation                             : Ok
        41.4: BPF relocation checker                              : Ok
        #
      
      So use the recently added rlimit__bump_memlock() helper:
      
        # ulimit -l 64
        # perf test bpf
        41: BPF filter                                            :
        41.1: Basic BPF filtering                                 : Ok
        41.2: BPF pinning                                         : Ok
        41.3: BPF prologue generation                             : Ok
        41.4: BPF relocation checker                              : Ok
        # ulimit -l
        64
        #
      
      I.e. the bumping of memlock is restricted to the 'perf test' instance,
      not changing the global value.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b9fubkhr4jm192lu7y8hgjvo@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3280ce0
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Introduce rlimit__bump_memlock() helper · 4975223b
      Arnaldo Carvalho de Melo authored
      Just like the BPF guys did when faced with failures with map creation,
      etc, i.e. their solution is:
      
        tools/testing/selftests/bpf/bpf_rlimit.h
      
      For perf use this function in 'perf test' and in 'perf trace'.
      
      Make it bump to 4 times the current value, if it fails twice the current
      value and if it still fails, warn that things like BPF map creation may
      fail, to help in diagnosing the problem.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-muvqef2i7n6pzqbmu7tn2d2y@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4975223b
    • Leo Yan's avatar
      perf intel-pt: Fix potential NULL pointer dereference found by the smatch tool · 323fd749
      Leo Yan authored
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/intel-pt.c:3200
        intel_pt_process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 3196)
      
        tools/perf/util/intel-pt.c:3206
        intel_pt_process_auxtrace_info() warn: variable dereferenced before
        check 'session->itrace_synth_opts' (see line 3200)
      
        tools/perf/util/intel-pt.c
        3196         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        3197                 pt->synth_opts = *session->itrace_synth_opts;
        3198         } else {
        3199                 itrace_synth_opts__set_default(&pt->synth_opts,
        3200                                 session->itrace_synth_opts->default_no_sample);
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        3201                 if (!session->itrace_synth_opts->default_no_sample &&
        3202                     !session->itrace_synth_opts->inject) {
        3203                         pt->synth_opts.branches = false;
        3204                         pt->synth_opts.callchain = true;
        3205                 }
        3206                 if (session->itrace_synth_opts)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        3207                         pt->synth_opts.thread_stack =
        3208                                 session->itrace_synth_opts->thread_stack;
        3209         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      intel_pt_process_auxtrace_info(), thus this patch removes the NULL test
      for 'session->itrace_synth_opts'.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-4-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      323fd749
    • Leo Yan's avatar
      perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool · 1d481458
      Leo Yan authored
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/intel-bts.c:898
        intel_bts_process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 894)
      
        tools/perf/util/intel-bts.c:899
        intel_bts_process_auxtrace_info() warn: variable dereferenced before
        check 'session->itrace_synth_opts' (see line 898)
      
        tools/perf/util/intel-bts.c
        894         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        895                 bts->synth_opts = *session->itrace_synth_opts;
        896         } else {
        897                 itrace_synth_opts__set_default(&bts->synth_opts,
        898                                 session->itrace_synth_opts->default_no_sample);
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        899                 if (session->itrace_synth_opts)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
        900                         bts->synth_opts.thread_stack =
        901                                 session->itrace_synth_opts->thread_stack;
        902         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      intel_bts_process_auxtrace_info(), thus this patch removes the NULL test
      for 'session->itrace_synth_opts'.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1d481458
    • Song Liu's avatar
      perf script: Assume native_arch for pipe mode · 9d49169c
      Song Liu authored
      In pipe mode, session->header.env.arch is not populated until the events
      are processed. Therefore, the following command crashes:
      
         perf record -o - | perf script
      
      (gdb) bt
      
      It fails when we try to compare env.arch against uts.machine:
      
              if (!strcmp(uts.machine, session->header.env.arch) ||
                  (!strcmp(uts.machine, "x86_64") &&
                   !strcmp(session->header.env.arch, "i386")))
                      native_arch = true;
      
      In pipe mode, it is tricky to find env.arch at this stage. To keep it
      simple, let's just assume native_arch is always true for pipe mode.
      Reported-by: default avatarDavid Carrillo Cisneros <davidca@fb.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: kernel-team@fb.com
      Cc: stable@vger.kernel.org #v5.1+
      Fixes: 3ab481a1 ("perf script: Support insn output for normal samples")
      Link: http://lkml.kernel.org/r/20190621014438.810342-1-songliubraving@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d49169c
    • Adrian Hunter's avatar
      perf scripts python: export-to-sqlite.py: Fix DROP VIEW power_events_view · 1334bb94
      Adrian Hunter authored
      Drop power_events_view before its dependent tables.
      
      SQLite does not seem to mind but the fix was needed for PostgreSQL
      (export-to-postgresql.py script), so do the same fix for the SQLite. It is
      more logical and keeps the 2 scripts following the same approach.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Fixes: 5130c6e5 ("perf scripts python: export-to-sqlite.py: Export Intel PT power and ptwrite events")
      Link: http://lkml.kernel.org/r/20190708055232.5032-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1334bb94
    • Adrian Hunter's avatar
      perf scripts python: export-to-postgresql.py: Fix DROP VIEW power_events_view · d8d051df
      Adrian Hunter authored
      PostgreSQL can error if power_events_view is not dropped before its
      dependent tables e.g.
      
        Exception: Query failed: ERROR:  cannot drop table mwait because other
        objects depend on it
        DETAIL:  view power_events_view depends on table mwait
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Fixes: aba44287 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
      Link: http://lkml.kernel.org/r/20190708055232.5032-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8d051df
    • Leo Yan's avatar
      perf hists browser: Fix potential NULL pointer dereference found by the smatch tool · ceb75476
      Leo Yan authored
      Based on the following report from Smatch, fix the potential
      NULL pointer dereference check.
      
        tools/perf/ui/browsers/hists.c:641
        hist_browser__run() error: we previously assumed 'hbt' could be
        null (see line 625)
      
        tools/perf/ui/browsers/hists.c:3088
        perf_evsel__hists_browse() error: we previously assumed
        'browser->he_selection' could be null (see line 2902)
      
        tools/perf/ui/browsers/hists.c:3272
        perf_evsel_menu__run() error: we previously assumed 'hbt' could be
        null (see line 3260)
      
      This patch firstly validating the pointers before access them, so can
      fix potential NULL pointer dereference.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-2-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ceb75476
    • Leo Yan's avatar
      perf cs-etm: Fix potential NULL pointer dereference found by the smatch · 0702f23c
      Leo Yan authored
      tool
      
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/cs-etm.c:2545
        cs_etm__process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 2541)
      
        tools/perf/util/cs-etm.c
        2541         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        2542                 etm->synth_opts = *session->itrace_synth_opts;
        2543         } else {
        2544                 itrace_synth_opts__set_default(&etm->synth_opts,
        2545                                 session->itrace_synth_opts->default_no_sample);
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        2546                 etm->synth_opts.callchain = false;
        2547         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      cs_etm__process_auxtrace_info(), thus this patch removes the NULL
      test for 'session->itrace_synth_opts'.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-5-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0702f23c
    • Luke Mujica's avatar
      perf parse-events: Remove unused variable: error · 72de3fd9
      Luke Mujica authored
      Remove the 'error' variable because it is declared but not used in
      parse-events.y or in the generated parse-events.c.
      Signed-off-by: default avatarLuke Mujica <lukemujica@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190703222509.109616-2-lukemujica@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72de3fd9
    • Luke Mujica's avatar
      perf parse-events: Remove unused variable 'i' · 34c9af57
      Luke Mujica authored
      Remove the 'int i' because it is declared but not used in parse-events.y
      or in the generated parse-events.c.
      Signed-off-by: default avatarLuke Mujica <lukemujica@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190703222509.109616-1-lukemujica@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      34c9af57
    • Arnaldo Carvalho de Melo's avatar
      perf metricgroup: Add missing list_del_init() when flushing egroups list · acc7bfb3
      Arnaldo Carvalho de Melo authored
      So that at the end each of the entries have its list node struct cleared
      and the egroup list head ends emptied.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-dxzj1ah350fy9ec0xbhb15b6@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      acc7bfb3
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Use list_del_init() more thorougly · e56fbc9d
      Arnaldo Carvalho de Melo authored
      To allow for destructors to check if they're operating on a object still
      in a list, and to avoid going from use after free list entries into
      still valid, or even also other already removed from list entries.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-deh17ub44atyox3j90e6rksu@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e56fbc9d
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Use zfree() where applicable · d8f9da24
      Arnaldo Carvalho de Melo authored
      In places where the equivalent was already being done, i.e.:
      
         free(a);
         a = NULL;
      
      And in placs where struct members are being freed so that if we have
      some erroneous reference to its struct, then accesses to freed members
      will result in segfaults, which we can detect faster than use after free
      to areas that may still have something seemingly valid.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-jatyoofo5boc1bsvoig6bb6i@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8f9da24