1. 29 Jul, 2019 40 commits
    • Jiri Olsa's avatar
      libperf: Add perf_cpu_map struct · 959b83c7
      Jiri Olsa authored
      Add perf_cpu_map struct to libperf.
      
      It's added as a declaration into:
      
        include/perf/cpumap.h
      
      which will be included by users.
      
      The perf_cpu_map struct definition is added into:
      
        include/internal/cpumap.h
      
      which is not to be included by users, but shared within perf and
      libperf.
      
      We tried the total separation of the perf_cpu_map struct in libperf, but
      it lead to complications and much bigger changes in perf code, so we
      decided to share the declaration.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-29-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      959b83c7
    • Jiri Olsa's avatar
      libperf: Add debug output support · a1556f84
      Jiri Olsa authored
      Add the perf_set_print() function to allow setting an output function
      for warn/info/debug messages.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-28-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1556f84
    • Jiri Olsa's avatar
      libperf: Add perf/core.h header · 5b7f445d
      Jiri Olsa authored
      Add perf/core.h header to be used in header files coming in the
      following patches.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-27-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5b7f445d
    • Jiri Olsa's avatar
      libperf: Add libperf to the python.so build · a429dcb8
      Jiri Olsa authored
      Link libperf.a with python.so.
      
      Committer testing:
      
      Continues to work:
      
        # perf test python
        18: 'import perf' in python                               : Ok
        #
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-26-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a429dcb8
    • Jiri Olsa's avatar
      libperf: Add build version support · 47f9bccc
      Jiri Olsa authored
      Add a shared library version, generating the following files:
      
        $ ll tools/perf/lib/libperf.so*
        libperf.so -> libperf.so.0.0.1
        libperf.so.0 -> libperf.so.0.0.1
        libperf.so.0.0.1
      
      Committer testing:
      
      One has to build just libbperf to get this, building perf so far doesn't
      trigger this, i.e. I tried:
      
        $ make O=/tmp/build/perf -C tools/perf
      
      And the files above were not created, so one has to do:
      
        $ make O=/tmp/build/perf -C tools/perf/lib/
        make: Entering directory '/home/acme/git/perf/tools/perf/lib'
          LINK     /tmp/build/perf/libperf.so.0.0.1
        make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
        $ ls -la /tmp/build/perf/*.so.*
        lrwxrwxrwx. 1 acme acme    16 Jul 22 15:37 /tmp/build/perf/libperf.so.0 -> libperf.so.0.0.1
        -rwxrwxr-x. 1 acme acme 16368 Jul 22 15:37 /tmp/build/perf/libperf.so.0.0.1
        $
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-25-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47f9bccc
    • Jiri Olsa's avatar
      libperf: Make libperf.a part of the perf build · 31435049
      Jiri Olsa authored
      Add an empty libperf.a under tools/perf/lib and link it with perf.
      
      It can also be built separately with:
      
        $ cd tools/perf/lib && make
          CC       core.o
          LD       libperf-in.o
          AR       libperf.a
          LINK     libperf.so
      
      Committer testing:
      
        $ make O=/tmp/build/perf -C tools/perf/lib/
        make: Entering directory '/home/acme/git/perf/tools/perf/lib'
          LINK     /tmp/build/perf/libperf.so
        make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
        $ ls -la /tmp/build/perf/libperf.so
        -rwxrwxr-x. 1 acme acme 16232 Jul 22 15:30 /tmp/build/perf/libperf.so
        $ file /tmp/build/perf/libperf.so
        /tmp/build/perf/libperf.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a51d227d871b381ddb686dcf94145c4dd908221, not stripped
        $ git status tools/perf
        On branch perf/core
        nothing to commit, working tree clean
        $
        $ ls -lart tools/perf/lib/
        total 16
        drwxrwxr-x. 16 acme acme 4096 Jul 22 15:29 ..
        -rw-rw-r--.  1 acme acme 1633 Jul 22 15:29 Makefile
        -rw-rw-r--.  1 acme acme    0 Jul 22 15:29 core.c
        -rw-rw-r--.  1 acme acme   20 Jul 22 15:29 Build
        drwxrwxr-x.  2 acme acme 4096 Jul 22 15:29 .
        $
      
      Committer notes:
      
      Need to add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
      -I$(srctree)/tools/include/uapi to tools/perf/lib/Makefile's INCLUDE
      variable to pick up the latest versions of kernel headers, even in older
      systems, this is in line with what is in tools/lib/bpf/Makefile.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-24-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      31435049
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__disable() to evlist__disable() · e74676de
      Jiri Olsa authored
      Rename perf_evlist__disable() to evlist__disable(), so we don't have a
      name clash when we add perf_evlist__disable() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-23-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e74676de
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__enable() to evlist__enable() · 1c87f165
      Jiri Olsa authored
      Rename perf_evlist__enable() to evlist__enable(), so we don't have a
      name clash when we add perf_evlist__enable() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-22-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1c87f165
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__close() to evlist__close() · 750b4ede
      Jiri Olsa authored
      Rename perf_evlist__close() to evlist__close(), so we don't have a name
      clash when we add perf_evlist__close() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-21-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      750b4ede
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__open() to evlist__open() · 474ddc4c
      Jiri Olsa authored
      Rename perf_evlist__open() to evlist__open(), so we don't have a name
      clash when we add perf_evlist__open() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-20-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      474ddc4c
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__cpus() to evsel__cpus() · b49aca3e
      Jiri Olsa authored
      Rename perf_evsel__cpus() to evsel__cpus(), so we don't have a name
      clash when we add perf_evsel__cpus() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-19-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b49aca3e
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__apply_filter() to evsel__apply_filter() · 24e376b2
      Jiri Olsa authored
      Rename perf_evsel__apply_filter() to evsel__apply_filter(), so we don't
      have a name clash when we add perf_evsel__apply_filter() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-18-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      24e376b2
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__disable() to evsel__disable() · 9a10bb22
      Jiri Olsa authored
      Renaming perf_evsel__disable() to evsel__disable(), so we don't have a
      name clash when we add perf_evsel__disable() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-17-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9a10bb22
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__enable() to evsel__enable() · ec7f24ef
      Jiri Olsa authored
      Rename perf_evsel__enable() to evsel__enable(), so we don't have a name
      clash when we add perf_evsel__enable() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-16-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ec7f24ef
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__open() to evsel__open() · 5972d1e0
      Jiri Olsa authored
      Rename perf_evsel__open() to evsel__open(), so we don't have a name
      clash when we add perf_evsel__open() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-15-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5972d1e0
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__remove() to evlist__remove() · 16251027
      Jiri Olsa authored
      Rename perf_evlist__remove() to evlist__remove(), so we don't have a
      name clash when we add perf_evlist__remove() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-14-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      16251027
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__add() to evlist__add() · a1cf3a75
      Jiri Olsa authored
      Rename perf_evlist__add() to evlist__add(), so we don't have a name
      clash when we add perf_evlist__add() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-13-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1cf3a75
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__new() to evsel__new() · 365c3ae7
      Jiri Olsa authored
      Rename perf_evsel__new() to evsel__new(), so we don't have a name clash
      when we add perf_evsel__new() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-12-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      365c3ae7
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__delete() to evsel__delete() · 5eb2dd2a
      Jiri Olsa authored
      Remame perf_evsel__delete() to evsel__delete(), so we don't have a name
      clash when we add perf_evsel__delete() in libperf.
      
      Also renaming perf_evsel__delete_priv() to evsel__delete_priv().
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-11-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5eb2dd2a
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__delete() to evlist__delete() · c12995a5
      Jiri Olsa authored
      Rename perf_evlist__delete() to evlist__delete(), so we don't have a
      name clash when we add perf_evlist__delete() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-10-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c12995a5
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__new() to evlist__new() · 0f98b11c
      Jiri Olsa authored
      Rename perf_evlist__new() to evlist__new(), so we don't have a name
      clash when we add perf_evlist__new() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-9-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f98b11c
    • Jiri Olsa's avatar
      perf evlist: Rename perf_evlist__init() to evlist__init() · 52c86bca
      Jiri Olsa authored
      Rename perf_evlist__init() to evlist__init(), so we don't have a name
      clash when we add perf_evlist__init() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-8-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      52c86bca
    • Jiri Olsa's avatar
      perf evsel: Rename perf_evsel__init() to evsel__init() · b4b62ee6
      Jiri Olsa authored
      Rename perf_evsel__init() to evsel__init(), so we don't have a name
      clash when we add perf_evsel__init() in libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-7-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b4b62ee6
    • Jiri Olsa's avatar
      perf evlist: Rename struct perf_evlist to struct evlist · 63503dba
      Jiri Olsa authored
      Rename struct perf_evlist to struct evlist, so we don't have a name
      clash when we add struct perf_evlist in libperf.
      
      Committer notes:
      
      Added fixes to build on arm64, from Jiri and from me
      (tools/perf/util/cs-etm.c)
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      63503dba
    • Jiri Olsa's avatar
      perf evsel: Rename struct perf_evsel to struct evsel · 32dcd021
      Jiri Olsa authored
      Rename struct perf_evsel to struct evsel, so we don't have a name clash
      when we add struct perf_evsel in libperf.
      
      Committer notes:
      
      Added fixes for arm64, provided by Jiri.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-5-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      32dcd021
    • Jiri Olsa's avatar
      perf tools: Rename struct thread_map to struct perf_thread_map · 9749b90e
      Jiri Olsa authored
      Rename struct thread_map to struct perf_thread_map, so it could be part
      of libperf.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9749b90e
    • Jiri Olsa's avatar
      perf cpu_map: Rename struct cpu_map to struct perf_cpu_map · f854839b
      Jiri Olsa authored
      Rename struct cpu_map to struct perf_cpu_map, so it could be part of
      libperf.
      
      Committer notes:
      
      Added fixes for arm64, provided by Jiri.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f854839b
    • Jiri Olsa's avatar
      perf stat: Move loaded out of struct perf_counts_values · df1d6856
      Jiri Olsa authored
      Because we will make struct perf_counts_values public in following
      patches and 'loaded' is implementation related.
      
      No functional change is expected.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df1d6856
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Add "sendfile64" alias to the "sendfile" syscall · e4b00e93
      Arnaldo Carvalho de Melo authored
      We were looking in tracefs for:
      
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile/format when
      
      what is there is just
      
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile/format
      
      Its the same id, 40 in x86_64, so just add an alias and let the existing
      logic take care of that.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-km2hmg7hru6u4pawi5fi903q@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e4b00e93
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Reuse BPF augmenters from syscalls with similar args signature · ad4153f9
      Arnaldo Carvalho de Melo authored
      We have an augmenter for the "open" syscall, which has just one pointer,
      in the first argument, a "const char *", so any other syscall that has
      just one pointer and that is the first can reuse the "open" BPF
      augmenter program.
      
      Even more, syscalls that get two pointers with the first being a string
      can reuse "open"'s BPF augmenter till we have an augmenter that better
      matches that syscall with two pointers.
      
      With this the few augmenters we have, for open (first arg is a string),
      openat (2nd arg is a string), renameat (2nd and 4th are strings) can be
      reused by a lot of syscalls, ditto for "bind" reusing "connect" because
      both have the 2nd argument as a sockaddr and the 3rd as its len.
      
      Lets see how this makes the "bind" syscall reuse the "connect" BPF prog
      augmenter found in tools/perf/examples/bpf/augmented_raw_syscalls.c:
      
        # perf trace -e bind,connect systemctl restart sshd
        connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        #
      
      Oh, it just connects to some daemon, so we better do it system wide and then
      stop/start sshd:
      
        # perf trace -e bind,connect
        systemctl/10124 connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        sshd/10102 connect(7, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        systemctl/10126 connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        systemd/10128  ... [continued]: connect())            = 0
        (sshd)/10128 connect(3, { .family: PF_LOCAL, path: /run/systemd/journal/stdout }, 30) ...
        sshd/10128 bind(3, { .family: PF_NETLINK }, 12)    = 0
        sshd/10128 connect(4, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(3, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        sshd/10128 connect(3, { .family: PF_UNSPEC }, 16)  = 0
        sshd/10128 connect(3, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/10128 connect(3, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(3, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 bind(4, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/10128 connect(6, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        sshd/10128 bind(6, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        sshd/10128 connect(7, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-zfley2ghs4nim1uq4nu6ed3l@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad4153f9
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Preallocate the syscall table · 30a910d7
      Arnaldo Carvalho de Melo authored
      We'll continue reading its details from tracefs as we need it, but
      preallocate the whole thing otherwise we may realloc and end up with
      pointers to the previous buffer.
      
      I.e. in an upcoming algorithm we'll look for syscalls that have function
      signatures that are similar to a given syscall to see if we can reuse
      its BPF augmenter, so we may be at syscall 42, having a 'struct syscall'
      pointing to that slot in trace->syscalls.table[] and try to read the
      slot for an yet unread syscall, which would realloc that table to read
      the info for syscall 43, say, which would trigger a realoc of
      trace->syscalls.table[], and then the pointer we had for syscall 42
      would be pointing to the previous block of memory. b00m.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-m3cjzzifibs13imafhkk77a0@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      30a910d7
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Mark syscall ids that are not allocated to avoid unnecessary error messages · b8b1033f
      Arnaldo Carvalho de Melo authored
      There are holes in syscall tables with IDs not associated with any
      syscall, mark those when trying to read information for syscalls, which
      could happen when iterating thru all syscalls from 0 to the highest
      numbered syscall id.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-cku9mpcrcsqaiq0jepu86r68@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b8b1033f
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Forward error codes when trying to read syscall info · 5d2bd889
      Arnaldo Carvalho de Melo authored
      We iterate thru the syscall table produced from the kernel syscall
      tables reading info, propagate the error and add to the debug message.
      
      This helps in fixing further bugs, such as failing to read the
      "sendfile" syscall info when it really should try the aliasm
      "sendfile64".
      
        Problems reading syscall 40: 2 (No such file or directory)(sendfile) information
      
        # grep sendfile /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c
      	[40] = "sendfile",
        #
      
      I.e. in the tracefs format file for the syscall tracepoints we have it
      as sendfile64:
      
        # find /sys -type f -name format | grep sendfile
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile64/format
        /sys/kernel/debug/tracing/events/syscalls/sys_exit_sendfile64/format
        #
      
      But as "sendfile" in the file used to build the syscall table used in
      perf:
      
        $ grep sendfile arch/x86/entry/syscalls/syscall_64.tbl
        40	common	sendfile		__x64_sys_sendfile64
        $
      
      So we need to add, in followup patches, aliases in 'perf trace' syscall
      data structures to cope with thie.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-w3eluap63x9je0bb8o3t79tz@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5d2bd889
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Add BPF augmenter for the 'rename' syscall · cfa9ac73
      Arnaldo Carvalho de Melo authored
      I.e. two strings:
      
        # perf trace -e rename
        systemd/1 rename("/run/systemd/units/.#invocation:dnf-makecache.service970761b7f2840dcc", "/run/systemd/units/invocation:dnf-makecache.service") = 0
        systemd-journa/715 rename("/run/systemd/journal/streams/.#9:17539785BJDblc", "/run/systemd/journal/streams/9:17539785") = 0
        mv/1936 rename("/tmp/build/perf/fd/.array.o.tmp", "/tmp/build/perf/fd/.array.o.cmd") = 0
        sh/1949 rename("/tmp/build/perf/.cpu.o.tmp", "/tmp/build/perf/.cpu.o.cmd") = 0
        mv/1954 rename("/tmp/build/perf/fs/.tracing_path.o.tmp", "/tmp/build/perf/fs/.tracing_path.o.cmd") = 0
        mv/1963 rename("/tmp/build/perf/common-cmds.h+", "/tmp/build/perf/common-cmds.h") = 0
        :1975/1975 rename("/tmp/build/perf/.exec-cmd.o.tmp", "/tmp/build/perf/.exec-cmd.o.cmd") = 0
        mv/1979 rename("/tmp/build/perf/fs/.fs.o.tmp", "/tmp/build/perf/fs/.fs.o.cmd") = 0
        mv/2005 rename("/tmp/build/perf/.debug.o.tmp", "/tmp/build/perf/.debug.o.cmd") = 0
        mv/2012 rename("/tmp/build/perf/.str_error_r.o.tmp", "/tmp/build/perf/.str_error_r.o.cmd") = 0
        mv/2019 rename("/tmp/build/perf/.help.o.tmp", "/tmp/build/perf/.help.o.cmd") = 0
        mv/2031 rename("/tmp/build/perf/.trace-seq.o.tmp", "/tmp/build/perf/.trace-seq.o.cmd") = 0
        make/2038  ... [continued]: rename())             = 0
        :2038/2038 rename("/tmp/build/perf/.event-plugin.o.tmp", "/tmp/build/perf/.event-plugin.o.cmd") ...
        ar/2035 rename("/tmp/build/perf/stzwBX3a", "/tmp/build/perf/libapi.a") = 0
        mv/2051 rename("/tmp/build/perf/.parse-utils.o.tmp", "/tmp/build/perf/.parse-utils.o.cmd") = 0
        mv/2069 rename("/tmp/build/perf/.subcmd-config.o.tmp", "/tmp/build/perf/.subcmd-config.o.cmd") = 0
        make/2080 rename("/tmp/build/perf/.parse-filter.o.tmp", "/tmp/build/perf/.parse-filter.o.cmd") = 0
        mv/2099 rename("/tmp/build/perf/.pager.o.tmp", "/tmp/build/perf/.pager.o.cmd") = 0
        :2124/2124 rename("/tmp/build/perf/.sigchain.o.tmp", "/tmp/build/perf/.sigchain.o.cmd") = 0
        make/2140 rename("/tmp/build/perf/.event-parse.o.tmp", "/tmp/build/perf/.event-parse.o.cmd") = 0
        mv/2164 rename("/tmp/build/perf/.kbuffer-parse.o.tmp", "/tmp/build/perf/.kbuffer-parse.o.cmd") = 0
        sh/2174 rename("/tmp/build/perf/.run-command.o.tmp", "/tmp/build/perf/.run-command.o.cmd") = 0
        mv/2190 rename("/tmp/build/perf/.tep_strerror.o.tmp", "/tmp/build/perf/.tep_strerror.o.cmd") = 0
        :2261/2261 rename("/tmp/build/perf/.event-parse-api.o.tmp", "/tmp/build/perf/.event-parse-api.o.cmd") = 0
        :2480/2480 rename("/tmp/build/perf/stLv3kG2", "/tmp/build/perf/libtraceevent.a") = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-6hh2rl27uri6gsxhmk6q3hx5@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cfa9ac73
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Beautify bind's sockaddr arg · 247dd65b
      Arnaldo Carvalho de Melo authored
      By reusing the "connect" BPF collector.
      
      Testing it system wide and stopping/starting sshd:
      
        # perf trace -e bind
        LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        DNS Res~er #18/15132 bind(243, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(247, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(238, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(243, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/10327 bind(258, { .family: PF_NETLINK }, 12)  = 0
        :6507/6507 bind(24, { .family: PF_NETLINK }, 12)   = 0
        DNS Res~er #19/4833 bind(238, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(242, { .family: PF_NETLINK }, 12)  = 0
        sshd/6514 bind(3, { .family: PF_NETLINK }, 12)    = 0
        sshd/6514 bind(5, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/6514 bind(7, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        DNS Res~er #18/10327 bind(229, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(231, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(229, { .family: PF_NETLINK }, 12)  = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-m2hmxqrckxxw2ciki0tu889u@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      247dd65b
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Beautify 'sendto's sockaddr arg · 3c475bc0
      Arnaldo Carvalho de Melo authored
      By just writing the collector in the augmented_raw_syscalls.c BPF
      program:
      
        # perf trace -e sendto
        <SNIP>
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        Socket Thread/3573 sendto(247, 0x7fb32d49c000, 120, NONE, { .family: PF_UNSPEC }, NULL) = 120
        DNS Res~er #18/11374 sendto(242, 0x7fb342cfe420, 20, NONE, { .family: PF_NETLINK }, 0xc) = 20
        DNS Res~er #18/11374 sendto(242, 0x7fb342cfcca0, 42, MSG_NOSIGNAL, { .family: PF_UNSPEC }, NULL) = 42
        DNS Res~er #18/11374 sendto(242, 0x7fb342cfcccc, 42, MSG_NOSIGNAL, { .family: PF_UNSPEC }, NULL) = 42
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        Socket Thread/3573 sendto(242, 0x7fb308bb1c08, 296, NONE, { .family: PF_UNSPEC }, NULL) = 296
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ping/23492 sendto(3, 0x56253bbef700, 64, NONE, { .family: PF_INET, port: 0, addr: 10.10.161.32 }, 0x10) = 64
        ^C
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-p0l0rlvq19v5zf8qc2x2itow@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c475bc0
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Do not try to use the fd->pathname beautifier for bind/connect fd arg · ef969ca6
      Arnaldo Carvalho de Melo authored
      Doesn't make sense and also we now beautify the sockaddr, which provides
      enough info:
      
        # trace -e close,socket,connec* ssh www.bla.com
        <SNIP>
        close(5)                                = 0
        socket(PF_INET, SOCK_DGRAM|CLOEXEC|NONBLOCK, IPPROTO_IP) = 5
        connect(5, { .family: PF_INET, port: 53, addr: 192.168.44.1 }, 16) = 0
        close(5)                                = 0
        socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-h9drpb7ail808d2mh4n7tla4@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ef969ca6
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Disable fd->pathname when close() not enabled · 79d725cd
      Arnaldo Carvalho de Melo authored
      As we invalidate the fd->pathname table in the SCA_CLOSE_FD beautifier,
      if we don't have it we may end up keeping an fd->pathname association
      that then gets misprinted.
      
      The previous behaviour continues when the close() syscall is enabled,
      which may still be a a problem if we lose records (i.e. we may lose a
      'close' record and then get that fd reused by socket()) but then the
      tool will notify that records are being lost and the user will be warned
      that some of the heuristics will fall apart.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b7t6h8sq9lebemvfy2zh3qq1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      79d725cd
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Make connect's addrlen be printed as an int, not hex · 1d862752
      Arnaldo Carvalho de Melo authored
        # perf trace -e connec* ssh www.bla.com
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(4<socket:[16610959]>, { .family: PF_LOCAL, path: /var/lib/sss/pipes/nss }, 110) = 0
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 53, addr: 192.168.44.1 }, 16) = 0
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 22, addr: 146.112.61.108 }, 16) = 0
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET6, port: 22, addr: ::ffff:146.112.61.108 }, 28) = 0
        ^Cconnect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 22, addr: 146.112.61.108 }, 16) = -1 (unknown) (INTERNAL ERROR: strerror_r(512, [buf], 128)=22)
        #
      
      Argh, the SCA_FD needs to invalidate its cache when close is done...
      
      It works if the 'close' syscall is not filtered out ;-\
      
        # perf trace -e close,connec* ssh www.bla.com
        close(3)                                = 0
        close(3</usr/lib64/libpcre2-8.so.0.8.0>) = 0
        close(3)                                = 0
        close(3</usr/lib64/libkrb5.so.3.3>)     = 0
        close(3</usr/lib64/libkrb5.so.3.3>)     = 0
        close(3)                                = 0
        close(3</usr/lib64/libk5crypto.so.3.1>) = 0
        close(3</usr/lib64/libk5crypto.so.3.1>) = 0
        close(3</usr/lib64/libcom_err.so.2.1>)  = 0
        close(3</usr/lib64/libcom_err.so.2.1>)  = 0
        close(3)                                = 0
        close(3</usr/lib64/libkrb5support.so.0.1>) = 0
        close(3</usr/lib64/libkrb5support.so.0.1>) = 0
        close(3</usr/lib64/libkeyutils.so.1.8>) = 0
        close(3</usr/lib64/libkeyutils.so.1.8>) = 0
        close(3)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        close(4)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        connect(3</etc/nsswitch.conf>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        close(3</etc/nsswitch.conf>)            = 0
        connect(3</usr/lib64/libnss_sss.so.2>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        close(3</usr/lib64/libnss_sss.so.2>)    = 0
        close(3</usr/lib64/libnss_sss.so.2>)    = 0
        close(3)                                = 0
        close(3)                                = 0
        connect(4<socket:[16616519]>, { .family: PF_LOCAL, path: /var/lib/sss/pipes/nss }, 110) = 0
        ^C
        #
      
      Will disable this beautifier when 'close' is filtered out...
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-ekuiciyx4znchvy95c8p1yyi@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1d862752
    • Arnaldo Carvalho de Melo's avatar
      perf augmented_raw_syscalls: Augment sockaddr arg in 'connect' · 212b9ab6
      Arnaldo Carvalho de Melo authored
      We already had a beautifier for an augmented sockaddr payload, but that
      was when we were hooking on each syscalls:sys_enter_foo tracepoints,
      since now we're almost doing that by doing a tail call from
      raw_syscalls:sys_enter, its almost the same, we can reuse it straight
      away.
      
        # perf trace -e connec* ssh www.bla.com
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(4<socket:[16604782]>, { .family: PF_LOCAL, path: /var/lib/sss/pipes/nss }, 0x6e) = 0
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(5</etc/hosts>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(5</etc/hosts>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 0x6e) = -1 ENOENT (No such file or directory)
        connect(5</etc/hosts>, { .family: PF_INET, port: 53, addr: 192.168.44.1 }, 0x10) = 0
        connect(5</etc/hosts>, { .family: PF_INET, port: 22, addr: 146.112.61.108 }, 0x10) = 0
        connect(5</etc/hosts>, { .family: PF_INET6, port: 22, addr: ::ffff:146.112.61.108 }, 0x1c) = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-5xkrbcpjsgnr3zt1aqdd7nvc@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      212b9ab6