Skip to content
  1. Aug 30, 2019
    • Kyle Meyer's avatar
      perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online · 8c727469
      Kyle Meyer authored
      
      
      nr_cpus, the number of CPUs online during a record session bound by
      MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in
      __machine__synthesize_threads and machine__set_current_tid.
      
      Signed-off-by: default avatarKyle Meyer <kyle.meyer@hpe.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russ Anderson <russ.anderson@hpe.com>
      Link: http://lore.kernel.org/lkml/20190827214352.94272-6-meyerk@stormcage.eag.rdlabs.hpecorp.net
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c727469
    • Kyle Meyer's avatar
      perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online · 7df4e36a
      Kyle Meyer authored
      
      
      nr_cpus, the number of CPUs online during a record session bound by
      MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in
      perf_session__cpu_bitmap.
      
      Signed-off-by: default avatarKyle Meyer <kyle.meyer@hpe.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russ Anderson <russ.anderson@hpe.com>
      Link: http://lore.kernel.org/lkml/20190827214352.94272-5-meyerk@stormcage.eag.rdlabs.hpecorp.net
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7df4e36a
    • Kyle Meyer's avatar
      perf stat: Replace MAX_NR_CPUS with cpu__max_cpu() · 92b5a154
      Kyle Meyer authored
      
      
      The function cpu__max_cpu() returns the possible number of CPUs as
      defined in the sysfs and can be used as an alternative for MAX_NR_CPUS
      in zero_per_pkg() and check_per_pkg().
      
      Signed-off-by: default avatarKyle Meyer <kyle.meyer@hpe.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russ Anderson <russ.anderson@hpe.com>
      Link: http://lore.kernel.org/lkml/20190827214352.94272-4-meyerk@stormcage.eag.rdlabs.hpecorp.net
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      92b5a154
    • Kyle Meyer's avatar
      perf svghelper: Replace MAX_NR_CPUS with perf_env::nr_cpus_online · f78f9667
      Kyle Meyer authored
      
      
      'nr_cpus', the number of CPUs online during a record session bound by
      MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in
      svg_build_topology_map().
      
      The value of nr_cpus can be passed into str_to_bitmap(),
      scan_core_topology(), and svg_build_topology_map() to replace
      MAX_NR_CPUS as well.
      
      Signed-off-by: default avatarKyle Meyer <kyle.meyer@hpe.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russ Anderson <russ.anderson@hpe.com>
      Link: http://lore.kernel.org/lkml/20190827214352.94272-3-meyerk@stormcage.eag.rdlabs.hpecorp.net
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f78f9667
    • Kyle Meyer's avatar
      perf timechart: Refactor svg_build_topology_map() · 0ac1dd5b
      Kyle Meyer authored
      
      
      Exchange the parameters of svg_build_topology_map() with 'struct
      perf_env *env' and adjust the function accordingly.
      
      This patch should not change any behavior, it is merely refactoring for
      the following patch.
      
      Committer notes:
      
      No need to include env.h from svghelper.h, all it needs is a forward
      declaration for 'struct perf_env', so move the include directive to
      svghelper.c, where it is really needed.
      
      Signed-off-by: default avatarKyle Meyer <kyle.meyer@hpe.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russ Anderson <russ.anderson@hpe.com>
      Link: http://lore.kernel.org/lkml/20190827214352.94272-2-meyerk@stormcage.eag.rdlabs.hpecorp.net
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0ac1dd5b
    • Jiri Olsa's avatar
      perf c2c: Display proper cpu count in nodes column · 67260e8c
      Jiri Olsa authored
      There's wrong bitmap considered when checking for cpu count of specific
      node.
      
      We do the needed computation for 'set' variable, but at the end we use
      the 'c2c_he->cpuset' weight, which shows misleading numbers.
      
      Fixes: 1e181b92
      
       ("perf c2c report: Add 'node' sort key")
      Reported-by: default avatarJoe Mario <jmario@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20190820140219.28338-1-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      67260e8c
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-5.4-20190829' of... · 39c2ca43
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-5.4-20190829' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      perf top:
      
        Namhyung Kim:
      
        - Decay all events in the evlist, we were decaying just the first event
          in a group.
      
        - Fix linking of histograms in different evsels in a event group with more
          than two events.
      
        With the two fixes above a command line such as:
      
          # perf top -e '{cycles,instructions,cache-misses,cache-references}
      
          Should work as expected, with four columns and with all of them being
          decayed over time, i.e. less weight is given for older samples.
      
      perf record:
      
        Arnaldo Carvalho de Melo:
      
        - Fix collection of build-ids when using setns() to get into namespaces,
          which had been broken with the introduction of the extra thread to
          react to PERF_RECORD_BPF_EVENT, i.e. to collect extra info for BPF
          programs. We need to unshare(CLONE_FS) in that thread so that the
          main one can do the setns(CLONE_NEWNS) when collectingthe build-ids.
          Without that symbol resolution gets more difficult and potentially
          misresolves symbols.
      
      core:
      
        Igor Lubashev:
      
        - Further alignment in permission checking via capabilities to how the
          kernel checks what tooling tries to do.
      
      PowerPC:
      
        Naveen N. Rao:
      
        - Sync powerpc syscall.tbl, so that 'perf trace' gets the definitions
          for recent syscalls.
      
      libperf:
      
        Jiri Olsa:
      
        - Move the rest of the PERF_RECORD_ metadata struct definitions so that
          we can use 'union perf_event'.
      
      libtraceevent:
      
        Steven Rostedt (VMware):
      
        - Do not free tep->cmdlines in add_new_comm() on failure.
      
        - Remove unneeded qsort and uses memmove instead
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      39c2ca43
  2. Aug 29, 2019
    • Steven Rostedt (VMware)'s avatar
      tools lib traceevent: Remove unneeded qsort and uses memmove instead · 301011ba
      Steven Rostedt (VMware) authored
      While reading a trace data file that had 100,000s of tasks, the process
      took an extremely long time. I profiled it down to add_new_comm(), which
      was doing a qsort() call on an array that was pretty much already sorted
      (all but the last element. qsort() isn't very efficient when dealing
      with mostly sorted arrays, and this definitely showed its issues.
      
      When adding a new task to the task list, instead of using qsort(), do
      another bsearch() with a function that will find the element before
      where the new task will be inserted in. Then simply shift the rest of
      the array, and insert the task where it belongs.
      
      Fixes: f7d82350
      
       ("tools/events: Add files to create libtraceevent.a")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linux-trace-devel@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190828191820.127233764@goodmis.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      301011ba
    • Steven Rostedt (VMware)'s avatar
      tools lib traceevent: Do not free tep->cmdlines in add_new_comm() on failure · b0215e2d
      Steven Rostedt (VMware) authored
      If the re-allocation of tep->cmdlines succeeds, then the previous
      allocation of tep->cmdlines will be freed. If we later fail in
      add_new_comm(), we must not free cmdlines, and also should assign
      tep->cmdlines to the new allocation. Otherwise when freeing tep, the
      tep->cmdlines will be pointing to garbage.
      
      Fixes: a6d2a61a
      
       ("tools lib traceevent: Remove some die() calls")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linux-trace-devel@vger.kernel.org
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190828191819.970121417@goodmis.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b0215e2d
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Use unshare(CLONE_FS) in sb threads to let setns(CLONE_NEWNS) work · b397f846
      Arnaldo Carvalho de Melo authored
      When we started using a thread to catch the PERF_RECORD_BPF_EVENT meta
      data events to then ask the kernel for further info (BTF, etc) for BPF
      programs shortly after they get loaded, we forgot to use
      unshare(CLONE_FS) as was done in:
      
        868a8329
      
       ("perf top: Support lookup of symbols in other mount namespaces.")
      
      Do it so that we can enter the namespaces to read the build-ids at the
      end of a 'perf record' session for the DSOs that had hits.
      
      Before:
      
      Starting a 'stress-ng --cpus 8' inside a container and then, outside the
      container running:
      
        # perf record -a --namespaces sleep 5
        # perf buildid-list | grep stress-ng
        #
      
      We would end up with a 'perf.data' file that had no entry in its
      build-id table for the /usr/bin/stress-ng binary inside the container
      that got tons of PERF_RECORD_SAMPLEs.
      
      After:
      
        # perf buildid-list | grep stress-ng
        f2ed02c68341183a124b9b0f6e2e6c493c465b29 /usr/bin/stress-ng
        #
      
      Then its just a matter of making sure that that binary debuginfo package
      gets available in a place that 'perf report' will look at build-id keyed
      ELF files, which, in my case, on a f30 notebook, was a matter of
      installing the debuginfo file for the distro used in the container,
      fedora 31:
      
        # rpm -ivh http://fedora.c3sl.ufpr.br/linux/development/31/Everything/x86_64/debug/tree/Packages/s/stress-ng-debuginfo-0.07.29-10.fc31.x86_64.rpm
      
      Then, because perf currently looks for those debuginfo files (richer ELF
      symtab) inside that namespace (look at the setns calls):
      
        openat(AT_FDCWD, "/proc/self/ns/mnt", O_RDONLY) = 137
        openat(AT_FDCWD, "/proc/13169/ns/mnt", O_RDONLY) = 139
        setns(139, CLONE_NEWNS)                 = 0
        stat("/usr/bin/stress-ng", {st_mode=S_IFREG|0755, st_size=3065416, ...}) = 0
        openat(AT_FDCWD, "/usr/bin/stress-ng", O_RDONLY) = 140
        fcntl(140, F_GETFD)                     = 0
        fstat(140, {st_mode=S_IFREG|0755, st_size=3065416, ...}) = 0
        mmap(NULL, 3065416, PROT_READ, MAP_PRIVATE, 140, 0) = 0x7ff2fdc5b000
        munmap(0x7ff2fdc5b000, 3065416)         = 0
        close(140)                              = 0
        stat("stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/bin/.debug/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29", 0x7fff45d711e0) = -1 ENOENT (No such file or directory)
      
      To only then go back to the "host" namespace to look just in the users's
      ~/.debug cache:
      
        setns(137, CLONE_NEWNS)                 = 0
        chdir("/root")                          = 0
        close(137)                              = 0
        close(139)                              = 0
        stat("/root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf", 0x7fff45d732e0) = -1 ENOENT (No such file or directory)
      
      It continues to fail to resolve symbols:
      
        # perf report | grep stress-ng | head -5
           9.50%  stress-ng-cpu    stress-ng    [.] 0x0000000000021ac1
           8.58%  stress-ng-cpu    stress-ng    [.] 0x0000000000021ab4
           8.51%  stress-ng-cpu    stress-ng    [.] 0x0000000000021489
           7.17%  stress-ng-cpu    stress-ng    [.] 0x00000000000219b6
           3.93%  stress-ng-cpu    stress-ng    [.] 0x0000000000021478
        #
      
      To overcome that we use:
      
        # perf buildid-cache -v --add /usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug
        Adding f2ed02c68341183a124b9b0f6e2e6c493c465b29 /usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug: Ok
        #
        # ls -la /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        -rw-r--r--. 3 root root 2401184 Jul 27 07:03 /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        # file /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter \004, BuildID[sha1]=f2ed02c68341183a124b9b0f6e2e6c493c465b29, for GNU/Linux 3.2.0, with debug_info, not stripped, too many notes (256)
        #
      
      Now it finally works:
      
        # perf report | grep stress-ng | head -5
          23.59%  stress-ng-cpu    stress-ng    [.] ackermann
          23.33%  stress-ng-cpu    stress-ng    [.] is_prime
          17.36%  stress-ng-cpu    stress-ng    [.] stress_cpu_sieve
           6.08%  stress-ng-cpu    stress-ng    [.] stress_cpu_correlate
           3.55%  stress-ng-cpu    stress-ng    [.] queens_try
        #
      
      I'll make sure that it looks for the build-id keyed files in both the
      "host" namespace (the namespace the user running 'perf record' was a the
      time of the recording) and in the container namespace, as it shouldn't
      matter where a content based key lookup finds the ELF file to use in
      resolving symbols, etc.
      
      Reported-by: default avatarKarl Rister <krister@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Fixes: 657ee553
      
       ("perf evlist: Introduce side band thread")
      Link: https://lkml.kernel.org/n/tip-g79k0jz41adiaeuqud742t2l@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b397f846
    • Jiri Olsa's avatar
      libperf: Move 'enum perf_user_event_type' to perf/event.h · 653dd8e6
      Jiri Olsa authored
      
      
      So it's available for libperf's users.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-24-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      653dd8e6
    • Jiri Olsa's avatar
      libperf: Rename the PERF_RECORD_ structs to have a "perf" prefix · 72932371
      Jiri Olsa authored
      
      
      Even more, to have a "perf_record_" prefix, so that they match the
      PERF_RECORD_ enum they map to.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-23-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72932371
    • Jiri Olsa's avatar
      libperf: Add 'union perf_event' to perf/event.h · 7510410a
      Jiri Olsa authored
      
      
      So it's available for libperf's users.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-22-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7510410a
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_COMPRESSED 'struct compressed_event' to perf/event.h · f5f68432
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_COMPRESSED event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-21-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f5f68432
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_HEADER_FEATURE 'struct feature_event' to perf/event.h · 1b8896fb
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_HEADER_FEATURE event definition to libperf's
      event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-20-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1b8896fb
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_TIME_CONV 'struct time_conv_event' to perf/event.h · bfd922d8
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_TIME_CONV event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-19-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bfd922d8
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_STAT_ROUND 'struct stat_round_event' to perf/event.h · 782adbe2
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_STAT_ROUND event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-18-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      782adbe2
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_STAT 'struct stat_event' to perf/event.h · 18a13a60
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_STAT event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-17-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      18a13a60
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_STAT_CONFIG 'struct stat_config_event' to perf/event.h · c5f416e6
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_STAT_CONFIG event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-16-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c5f416e6
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_THREAD_MAP 'struct thread_map_event' to perf/event.h · 3e4c453f
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_THREAD_MAP event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-15-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3e4c453f
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_SWITCH 'struct context_switch_event' to perf/event.h · 6b49aaeb
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_SWITCH event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-14-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6b49aaeb
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_ITRACE_START 'struct itrace_start_event' to perf/event.h · f279ad63
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_ITRACE_START event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-13-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f279ad63
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_AUX 'struct aux_event' to perf/event.h · aedebdca
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_AUX event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-12-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aedebdca
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_AUXTRACE_ERROR 'struct auxtrace_error_event' to perf/event.h · 3460efb2
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_AUXTRACE_ERROR event definition to libperf's
      event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-11-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3460efb2
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_AUXTRACE 'struct auxtrace_event' to perf/event.h · 306c9d24
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_AUXTRACE event definition to libperf's event.h.
      
      Ipn order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-10-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      306c9d24
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_AUXTRACE_INFO 'struct auxtrace_info_event' to perf/event.h · 9a8dad04
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_AUXTRACE_INFO event definition to libperf's
      event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-9-jolsa@kernel.org
      [ Fix cs_etm__print_auxtrace_info() arg to be __u64 too to fix the CORESIGHT=1 build ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9a8dad04
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_ID_INDEX 'struct id_index_event' to perf/event.h · fecb4100
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_ID_INDEX event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Add the PRI_ld64 define, so we can use it in printf output.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-8-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fecb4100
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_HEADER_BUILD_ID 'struct build_id_event' to perf/event.h · ffd337b4
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_HEADER_BUILD_ID event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Adding the fix value for build_id variable, because it will never
      change.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-7-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ffd337b4
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_HEADER_TRACING_DATA 'struct tracing_data_event' to perf/event.h · 4fd7a4d2
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_HEADER_TRACING_DATA event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-6-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4fd7a4d2
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_HEADER_EVENT_TYPE 'struct event_type_event' to perf/event.h · 0f5b1a28
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_HEADER_EVENT_TYPE event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-5-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f5b1a28
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_EVENT_UPDATE 'struct event_update_event' to perf/event.h · 5ded068e
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_EVENT_UPDATE event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-4-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ded068e
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_CPU_MAP 'struct cpu_map_event' to perf/event.h · 78e5ea16
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_CPU_MAP event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8'
      types used events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-3-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      78e5ea16
    • Jiri Olsa's avatar
      libperf: Add PERF_RECORD_HEADER_ATTR 'struct attr_event' to perf/event.h · c78ad994
      Jiri Olsa authored
      
      
      Move the PERF_RECORD_HEADER_ATTR event definition to libperf's event.h.
      
      In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
      events to their generic '__u*' versions.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@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/20190828135717.7245-2-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c78ad994
    • Namhyung Kim's avatar
      perf top: Fix event group with more than two events · be5863b7
      Namhyung Kim authored
      
      
      The event group feature links relevant hist entries among events so that
      they can be displayed together.  During the link process, each hist
      entry in non-leader events is connected to a hist entry in the leader
      event.  This is done in order of events specified in the command line so
      it assumes that events are linked in the order.
      
      But 'perf top' can break the assumption since it does the link process
      multiple times.  For example, a hist entry can be in the third event
      only at first so it's linked after the leader.  Some time later, second
      event has a hist entry for it and it'll be linked after the entry of the
      third event.
      
      This makes the code compilicated to deal with such unordered entries.
      This patch simply unlink all the entries after it's printed so that they
      can assume the correct order after the repeated link process.  Also it'd
      be easy to deal with decaying old entries IMHO.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190827231555.121411-2-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      be5863b7
    • Namhyung Kim's avatar
      perf top: Decay all events in the evlist · ea4385f8
      Namhyung Kim authored
      
      
      Currently perf top only decays entries in a selected evsel.  I don't
      know whether it's intended (maybe due to performance reason?) but anyway
      it might show incorrect output when event group is used since users will
      see leader event is decayed but others are not.
      
      This patch moves the decay code into perf_top__resort_hists() so that
      stdio and TUI code shared the logic.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190827231555.121411-1-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ea4385f8
    • Arnaldo Carvalho de Melo's avatar
      perf clang: Delete needless util-cxx.h header · 630aec1a
      Arnaldo Carvalho de Melo authored
      
      
      It was put in place just to make sure the 'new' C++ operator wouldn't
      clash with some argument name in util.h, but there is not anymore any
      such argument and also the reason stated for util.h to be included there
      was to get the __maybe_unused definition, that is in linux/compiler.h,
      so use that instead and nuke util-cxx.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-1r5tvfnwiydjxhukgqs6bi11@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      630aec1a
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Remove needless util.h from evlist.h · 2da39f1c
      Arnaldo Carvalho de Melo authored
      
      
      There is no need for that util/util.h include there and, remove it,
      pruning the include tree, fix the fallout by adding necessary headers to
      places that were getting needed includes indirectly from evlist.h ->
      util.h.
      
      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-s9f7uve8wvykr5itcm7m7d8q@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2da39f1c
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Remove needless util.h include from builtin.h · efa73d37
      Arnaldo Carvalho de Melo authored
      
      
      And fix up places where util.h is needed but was obtained indirectly via
      builtin.h.
      
      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-a01ig3c4t76ye5wkqmtgk9qn@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      efa73d37
    • Igor Lubashev's avatar
      perf tools: Warn that perf_event_paranoid can restrict kernel symbols · d06e5fad
      Igor Lubashev authored
      
      
      Warn that /proc/sys/kernel/perf_event_paranoid can also restrict kernel
      symbols.
      
      Signed-off-by: default avatarIgor Lubashev <ilubashe@akamai.com>
      Tested-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1566869956-7154-6-git-send-email-ilubashe@akamai.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d06e5fad
    • Igor Lubashev's avatar
      perf symbols: Use CAP_SYSLOG with kptr_restrict checks · 8859aede
      Igor Lubashev authored
      
      
      The kernel is using CAP_SYSLOG capability instead of uid==0 and euid==0
      when checking kptr_restrict. Make perf do the same.
      
      Also, the kernel is a more restrictive than "no restrictions" in case of
      kptr_restrict==0, so add the same logic to perf.
      
      Signed-off-by: default avatarIgor Lubashev <ilubashe@akamai.com>
      Tested-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1566869956-7154-5-git-send-email-ilubashe@akamai.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8859aede