1. 31 7月, 2018 1 次提交
    • A
      perf tools: Fix the build on the alpine:edge distro · 44fe619b
      Arnaldo Carvalho de Melo 提交于
      The UAPI file byteorder/little_endian.h uses the __always_inline define
      without including the header where it is defined, linux/stddef.h, this
      ends up working in all the other distros because that file gets included
      seemingly by luck from one of the files included from little_endian.h.
      
      But not on Alpine:edge, that fails for all files where perf_event.h is
      included but linux/stddef.h isn't include before that.
      
      Adding the missing linux/stddef.h file where it breaks on Alpine:edge to
      fix that, in all other distros, that is just a very small header anyway.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.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-9r1pifftxvuxms8l7ir73p5l@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      44fe619b
  2. 30 7月, 2018 1 次提交
    • A
      tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy' · 1f27a050
      Arnaldo Carvalho de Melo 提交于
      To cope with the changes in:
      
        12c89130 ("x86/asm/memcpy_mcsafe: Add write-protection-fault handling")
        60622d68 ("x86/asm/memcpy_mcsafe: Return bytes remaining")
        bd131544 ("x86/asm/memcpy_mcsafe: Add labels for __memcpy_mcsafe() write fault handling")
        da7bc9c5 ("x86/asm/memcpy_mcsafe: Remove loop unrolling")
      
      This needed introducing a file with a copy of the mcsafe_handle_tail()
      function, that is used in the new memcpy_64.S file, as well as a dummy
      mcsafe_test.h header.
      
      Testing it:
      
        $ nm ~/bin/perf | grep mcsafe
        0000000000484130 T mcsafe_handle_tail
        0000000000484300 T __memcpy_mcsafe
        $
        $ perf bench mem memcpy
        # Running 'mem/memcpy' benchmark:
        # function 'default' (Default memcpy() provided by glibc)
        # Copying 1MB bytes ...
      
            44.389205 GB/sec
        # function 'x86-64-unrolled' (unrolled memcpy() in arch/x86/lib/memcpy_64.S)
        # Copying 1MB bytes ...
      
            22.710756 GB/sec
        # function 'x86-64-movsq' (movsq-based memcpy() in arch/x86/lib/memcpy_64.S)
        # Copying 1MB bytes ...
      
            42.459239 GB/sec
        # function 'x86-64-movsb' (movsb-based memcpy() in arch/x86/lib/memcpy_64.S)
        # Copying 1MB bytes ...
      
            42.459239 GB/sec
        $
      
      This silences this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S'
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mika Penttilä <mika.penttila@nextfour.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-igdpciheradk3gb3qqal52d0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f27a050
  3. 12 7月, 2018 1 次提交
  4. 11 7月, 2018 14 次提交
    • J
      perf tools: Use python-config --includes rather than --cflags · 32aa928a
      Jeremy Cline 提交于
      Builds started failing in Fedora on Python 3.7 with:
      
          `.gnu.debuglto_.debug_macro' referenced in section
          `.gnu.debuglto_.debug_macro' of
          util/scripting-engines/trace-event-python.o: defined in discarded
          section
      
      In Fedora, Python 3.7 added -flto to the list of --cflags and since it
      was only applied to util/scripting-engines/trace-event-python.c and
      scripts/python/Perf-Trace-Util/Context.c, linking failed.
      
      It's not the first time the addition of flags has broken builds: commit
      c6707fde ("perf tools: Fix up build in hardnened environments")
      appears to have fixed a similar problem. "python-config --includes"
      provides the proper -I flags and doesn't introduce additional CFLAGS.
      Signed-off-by: NJeremy Cline <jcline@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180710154612.6285-1-jcline@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32aa928a
    • J
      perf script python: Fix dict reference counting · db0ba84c
      Janne Huttunen 提交于
      The dictionaries are attached to the parameter tuple that steals the
      references and takes care of releasing them when appropriate.  The code
      should not decrement the reference counts explicitly.  E.g. if libpython
      has been built with reference debugging enabled, the superfluous DECREFs
      will trigger this error when running perf script:
      
        Fatal Python error: Objects/tupleobject.c:238 object at
        0x7f10f2041b40 has negative ref count -1
        Aborted (core dumped)
      
      If the reference debugging is not enabled, the superfluous DECREFs might
      cause the dict objects to be silently released while they are still in
      use. This may trigger various other assertions or just cause perf
      crashes and/or weird and unexpected data changes in the stored Python
      objects.
      Signed-off-by: NJanne Huttunen <janne.huttunen@nokia.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jaroslav Skarvada <jskarvad@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1531133990-17485-1-git-send-email-janne.huttunen@nokia.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      db0ba84c
    • J
      perf stat: Fix --interval_clear option · c818cc06
      Jiri Olsa 提交于
      Currently we display extra header line, like:
      
        # perf stat -I 1000 -a --interval-clear
        #           time             counts unit events
               insn per cycle branch-misses of all branches
             2.964917103        3855.349912      cpu-clock (msec)          #    3.855 CPUs utilized
             2.964917103             23,993      context-switches          #    0.006 M/sec
             2.964917103              1,301      cpu-migrations            #    0.329 K/sec
             ...
      
      Fixing the condition and getting proper:
      
        # perf stat -I 1000 -a --interval-clear
        #           time             counts unit events
             2.359048938        1432.492228      cpu-clock (msec)          #    1.432 CPUs utilized
             2.359048938              7,613      context-switches          #    0.002 M/sec
             2.359048938                419      cpu-migrations            #    0.133 K/sec
             ...
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: 9660e08e ("perf stat: Add --interval-clear option")
      Link: http://lkml.kernel.org/r/20180702134202.17745-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c818cc06
    • J
      perf tools: Fix compilation errors on gcc8 · a09603f8
      Jiri Olsa 提交于
      We are getting following warnings on gcc8 that break compilation:
      
        $ make
          CC       jvmti/jvmti_agent.o
        jvmti/jvmti_agent.c: In function ‘jvmti_open’:
        jvmti/jvmti_agent.c:252:35: error: ‘/jit-’ directive output may be truncated \
          writing 5 bytes into a region of size between 1 and 4096 [-Werror=format-truncation=]
          snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
      
      There's no point in checking the result of snprintf call in
      jvmti_open, the following open call will fail in case the
      name is mangled or too long.
      
      Using tools/lib/ function scnprintf that touches the return value from
      the snprintf() calls and thus get rid of those warnings.
      
        $ make DEBUG=1
          CC       arch/x86/util/perf_regs.o
        arch/x86/util/perf_regs.c: In function ‘arch_sdt_arg_parse_op’:
        arch/x86/util/perf_regs.c:229:4: error: ‘strncpy’ output truncated before terminating nul
        copying 2 bytes from a string of the same length [-Werror=stringop-truncation]
          strncpy(prefix, "+0", 2);
          ^~~~~~~~~~~~~~~~~~~~~~~~
      
      Using scnprintf instead of the strncpy (which we know is safe in here)
      to get rid of that warning.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180702134202.17745-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a09603f8
    • K
      perf test shell: Prevent temporary editor files from being considered test scripts · db8fec58
      Kim Phillips 提交于
      Allows a perf shell test developer to concurrently edit and run their
      test scripts, avoiding perf test attempts to execute their editor
      temporary files, such as seen here:
      
       $ sudo taskset -c 0 ./perf test -vvvvvvvv -F 63
       63: 0VIM 8.0                                              :
       --- start ---
       sh: 1: ./tests/shell/.record+probe_libc_inet_pton.sh.swp: Permission denied
       ---- end ----
       0VIM 8.0: FAILED!
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20180629124658.15a506b41fc4539c08eb9426@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      db8fec58
    • K
      perf llvm-utils: Remove bashism from kernel include fetch script · f6432b9f
      Kim Phillips 提交于
      Like system(), popen() calls /bin/sh, which may/may not be bash.
      
      Script when run on dash and encounters the line, yields:
      
       exit: Illegal number: -1
      
      checkbashisms report on script content:
      
       possible bashism (exit|return with negative status code):
       exit -1
      
      Remove the bashism and use the more portable non-zero failure
      status code 1.
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20180629124652.8d0af7e2281fd3fd8262cacc@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6432b9f
    • K
      perf test shell: Make perf's inet_pton test more portable · 98c6c8a1
      Kim Phillips 提交于
      Debian based systems such as Ubuntu have dash as their default shell.
      Even if the normal or root user's shell is bash, certain scripts still
      call /bin/sh, which points to dash, so we fix this perf test by
      rewriting it in a more portable way.
      
      BEFORE:
      
       $ sudo perf test -v 64
       64: probe libc's inet_pton & backtrace it with ping       :
       --- start ---
       test child forked, pid 31942
       ./tests/shell/record+probe_libc_inet_pton.sh: 18: ./tests/shell/record+probe_libc_inet_pton.sh: expected[0]=ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\): not found
       ./tests/shell/record+probe_libc_inet_pton.sh: 19: ./tests/shell/record+probe_libc_inet_pton.sh: expected[1]=.*inet_pton\+0x[[:xdigit:]]+[[:space:]]\(/lib/x86_64-linux-gnu/libc-2.27.so|inlined\)$: not found
       ./tests/shell/record+probe_libc_inet_pton.sh: 29: ./tests/shell/record+probe_libc_inet_pton.sh: expected[2]=getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\(/lib/x86_64-linux-gnu/libc-2.27.so\)$: not found
       ./tests/shell/record+probe_libc_inet_pton.sh: 30: ./tests/shell/record+probe_libc_inet_pton.sh: expected[3]=.*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$: not found
       ping 31963 [004] 83577.670613: probe_libc:inet_pton: (7fe15f87f4b0)
       ./tests/shell/record+probe_libc_inet_pton.sh: 39: ./tests/shell/record+probe_libc_inet_pton.sh: Bad substitution
       ./tests/shell/record+probe_libc_inet_pton.sh: 41: ./tests/shell/record+probe_libc_inet_pton.sh: Bad substitution
       test child finished with -2
       ---- end ----
       probe libc's inet_pton & backtrace it with ping: Skip
      
      AFTER:
      
       $ sudo perf test -v 64
       64: probe libc's inet_pton & backtrace it with ping       :
       --- start ---
       test child forked, pid 32277
       ping 32295 [001] 83679.690020: probe_libc:inet_pton: (7ff244f504b0)
       7ff244f504b0 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.27.so)
       7ff244f14ce4 getaddrinfo+0x124 (/lib/x86_64-linux-gnu/libc-2.27.so)
       556ac036b57d _init+0xb75 (/bin/ping)
       test child finished with 0
       ---- end ----
       probe libc's inet_pton & backtrace it with ping: Ok
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20180629124643.2089b3ce59960eba34e87b27@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      98c6c8a1
    • K
      perf test shell: Replace '|&' with '2>&1 |' to work with more shells · 508ef3e7
      Kim Phillips 提交于
      Since we do not specify bash (and/or zsh) as a requirement, use the
      standard error redirection that is more widely supported.
      
      BEFORE:
      
       $ sudo perf test -v 62
       62: Check open filename arg using perf trace + vfs_getname:
       --- start ---
       test child forked, pid 27305
       ./tests/shell/trace+probe_vfs_getname.sh: 20: ./tests/shell/trace+probe_vfs_getname.sh: Syntax error: "&" unexpected
       test child finished with -2
       ---- end ----
       Check open filename arg using perf trace + vfs_getname: Skip
      
      AFTER:
      
       $ sudo perf test -v 62
       64: Check open filename arg using perf trace + vfs_getname               :
       --- start ---
       test child forked, pid 23008
       Added new event:
         probe:vfs_getname    (on getname_flags:72 with pathname=result->name:string)
      
       You can now use it in all perf tools, such as:
      
               perf record -e probe:vfs_getname -aR sleep 1
      
            0.361 ( 0.008 ms): touch/23032 openat(dfd: CWD, filename: /tmp/temporary_file.VEh0n, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 4
       test child finished with 0
       ---- end ----
       Check open filename arg using perf trace + vfs_getname: Ok
      
      Similar to commit 35435cd0, with the same title.
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20180629124633.0a9f4bea54b8d2c28f265de2@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      508ef3e7
    • J
      perf scripts python: Add Python 3 support to EventClass.py · 12aa6c73
      Jeremy Cline 提交于
      Support both Python 2 and Python 3 in EventClass.py. ``print`` is now a
      function rather than a statement. This should have no functional change.
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a73aac-e0734bdc-dcab-4c61-8333-d8be97524aa0-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      12aa6c73
    • J
      perf scripts python: Add Python 3 support to sched-migration.py · 8c1c1ab2
      Jeremy Cline 提交于
      Support both Python 2 and Python 3 in the sched-migration.py script.
      This should have no functional change.
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8c1c1ab2
    • J
      perf scripts python: Add Python 3 support to Util.py · c45b168e
      Jeremy Cline 提交于
      Support both Python 2 and Python 3 in Util.py. The dict class no longer
      has a ``has_key`` method and print is now a function rather than a
      statement. This should have no functional change.
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a730c6-8db8b9b1-da2d-4ee3-96bf-47e0ae9796bd-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c45b168e
    • J
      perf scripts python: Add Python 3 support to SchedGui.py · 2ab89262
      Jeremy Cline 提交于
      Fix a single syntax error in SchedGui.py to support both Python 2 and
      Python 3. This should have no functional change.
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a72d26-75729663-fe55-4309-8c9b-302e065ed2f1-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2ab89262
    • J
      perf scripts python: Add Python 3 support to Core.py · 770d2f86
      Jeremy Cline 提交于
      Support both Python 2 and Python 3 in Core.py. This should have no
      functional change.
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a72ebe-e572899e-f445-4765-98f0-c314935727f9-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      770d2f86
    • J
      perf tools: Generate a Python script compatible with Python 2 and 3 · 877cc639
      Jeremy Cline 提交于
      When generating a Python script with "perf script -g python", produce
      one that is compatible with Python 2 and 3. The difference between the
      two generated scripts is:
      
        --- python2-perf-script.py	2018-05-08 15:35:00.865889705 -0400
        +++ python3-perf-script.py	2018-05-08 15:34:49.019789564 -0400
        @@ -7,6 +7,8 @@
         # be retrieved using Python functions of the form common_*(context).
         # See the perf-script-python Documentation for the list of available functions.
      
        +from __future__ import print_function
        +
         import os
         import sys
      
        @@ -18,10 +20,10 @@
      
         def trace_begin():
        -	print "in trace_begin"
        +	print("in trace_begin")
      
         def trace_end():
        -	print "in trace_end"
        +	print("in trace_end")
      
         def raw_syscalls__sys_enter(event_name, context, common_cpu,
         	common_secs, common_nsecs, common_pid, common_comm,
        @@ -29,26 +31,26 @@
         		print_header(event_name, common_cpu, common_secs, common_nsecs,
         			common_pid, common_comm)
      
        -		print "id=%d, args=%s" % \
        -		(id, args)
        +		print("id=%d, args=%s" % \
        +		(id, args))
      
        -		print 'Sample: {'+get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'
        +		print('Sample: {'+get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')
      
         		for node in common_callchain:
         			if 'sym' in node:
        -				print "\t[%x] %s" % (node['ip'], node['sym']['name'])
        +				print("\t[%x] %s" % (node['ip'], node['sym']['name']))
         			else:
        -				print "	[%x]" % (node['ip'])
        +				print("	[%x]" % (node['ip']))
      
        -		print "\n"
        +		print()
      
         def trace_unhandled(event_name, context, event_fields_dict, perf_sample_dict):
        -		print get_dict_as_string(event_fields_dict)
        -		print 'Sample: {'+get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'
        +		print(get_dict_as_string(event_fields_dict))
        +		print('Sample: {'+get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')
      
         def print_header(event_name, cpu, secs, nsecs, pid, comm):
        -	print "%-20s %5u %05u.%09u %8u %-20s " % \
        -	(event_name, cpu, secs, nsecs, pid, comm),
        +	print("%-20s %5u %05u.%09u %8u %-20s " % \
        +	(event_name, cpu, secs, nsecs, pid, comm), end="")
      
         def get_dict_as_string(a_dict, delimiter=' '):
         	return delimiter.join(['%s=%s'%(k,str(v))for k,v in sorted(a_dict.items())])
      Signed-off-by: NJeremy Cline <jeremy@jcline.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Herton Krzesinski <herton@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/0100016341a7278a-d178c724-2b0f-49ca-be93-80a7d51aaa0d-000000@email.amazonses.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      877cc639
  5. 25 6月, 2018 15 次提交
    • R
      perf tools: Fix crash caused by accessing feat_ops[HEADER_LAST_FEATURE] · 92ead7ee
      Ravi Bangoria 提交于
      perf_event__process_feature() accesses feat_ops[HEADER_LAST_FEATURE]
      which is not defined and thus perf is crashing. HEADER_LAST_FEATURE is
      used as an end marker for the perf report but it's unused for perf
      script/annotate. Ignore HEADER_LAST_FEATURE for perf script/annotate,
      just like it is done in 'perf report'.
      
      Before:
        # perf record -o - ls | perf script
        <SNIP 'ls' output>
        Segmentation fault (core dumped)
        #
      
      After:
        # perf record -o - ls | perf script
        <SNIP 'ls' output>
        Segmentation fault (core dumped)
        ls 7031 4392.099856:  250000 cpu-clock:uhH:  7f5e0ce7cd60
        ls 7031 4392.100355:  250000 cpu-clock:uhH:  7f5e0c706ef7
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: 57b5de46 ("perf report: Support forced leader feature in pipe mode")
      Link: http://lkml.kernel.org/r/20180625124220.6434-4-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      92ead7ee
    • R
      perf script: Fix crash because of missing evsel->priv · a3af66f5
      Ravi Bangoria 提交于
      'perf script' in piped mode is crashing because evsel->priv is not set
      properly. Fix it.
      
      Before:
      
        # perf record -o - -- ls | perf script
        <SNIP 'ls' output>
          Segmentation fault (core dumped)
        #
      
      After:
      
        # perf record -o - -- ls | perf script
        <SNIP 'ls' output>
        ls 2282 1031.731974:  250000 cpu-clock:uhH:  7effe4b3d29e
        ls 2282 1031.732222:  250000 cpu-clock:uhH:  7effe4b3a650
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: a14390fd ("perf script: Allow creating per-event dump files")
      Link: http://lkml.kernel.org/r/20180625124220.6434-3-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a3af66f5
    • R
      perf script: Add missing output fields in a hint · 10e9cec9
      Ravi Bangoria 提交于
      A few fields are missing in a perf script -F hint. Add them.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/20180625124220.6434-2-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      10e9cec9
    • J
      perf bench: Fix numa report output code · 98310707
      Jiri Olsa 提交于
      Currently we can hit following assert when running numa bench:
      
        $ perf bench numa mem -p 3 -t 1 -P 512 -s 100 -zZ0cm --thp 1
        perf: bench/numa.c:1577: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed.
      
      The assertion is correct, because we hit the SIGFPE in following line:
      
        Thread 2.2 "thread 0/0" received signal SIGFPE, Arithmetic exception.
        [Switching to Thread 0x7fffd28c6700 (LWP 11750)]
        0x000.. in worker_thread (__tdata=0x7.. ) at bench/numa.c:1257
        1257 td->speed_gbs = bytes_done / (td->runtime_ns / NSEC_PER_SEC) / 1e9;
      
      We don't check if the runtime is actually bigger than 1 second,
      and thus this might end up with zero division within FPU.
      
      Adding the check to prevent this.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180620094036.17278-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      98310707
    • T
      perf stat: Remove duplicate event counting · 6dde6429
      Thomas Richter 提交于
      'perf stat' shows a mismatch in perf stat regarding counter names on
      s390:
      
      Run command:
      
         [root@s35lp76 perf]# ./perf stat -e tx_nc_tend  -v --
                      ~/mytesttx 1 >/tmp/111
         tx_nc_tend: 1 573146 573146
         tx_nc_tend: 1 573146 573146
      
         Performance counter stats for '/root/mytesttx 1':
      
                       3      tx_nc_tend
      
             0.001037252 seconds time elapsed
      
         [root@s35lp76 perf]#
      
      shows transaction counter tx_nc_tend with value 3 but it was triggered
      only once as seen by the output of mytesttx.
      
      When looking up the event name tx_nc_tend the following function
      sequence is called:
      
      parse_events_multi_pmu_add()
      +--> perf_pmu__scan() being called with NULL argument
           +--> pmu_read_sysfs() scans directory ../devices/ for
                                 all PMUs
                +--> perf_pmu__find() tries to find a PMU in the
                                 global pmu list.
                     +--> pmu_lookup() called to read all file
                                       entries when not in global
                                       list.
      
      pmu_lookup() causes the issue. It calls
      +---> pmu_aliases() to read all the entries in the PMU directory.
                          On s390 this is named
                          /sys/devices/cpum_cf/events.
            +--> pmu_aliases_parse() reads all files and creates an
                             alias for each file name.
      
                             So we end up with first entry created by
                             reading the sysfs file
                             [root@s35lp76 perf]# cat /sys/devices/cpum_cf
                                                      /events/TX_NC_TEND
                             event=0x008d
                             [root@s35lp76 perf]#
      
                             Debug output shows this entry
                             tx_nc_tend -> 'cpum_cf'/'event=0x008d
                             '/
                             After all files in this directory have been
                             read and aliases created this function is called:
            +--> pmu_add_cpu_aliases()
                             This function looks up the CPU tables
                             created by the json files.
                             With json files for s390 now available all
                             the aliases are added to
                             the PMU alias list a second time.
                             The second entry is added by
                             reading the json file converted by jevent
                             resulting in file pmu-events/pmu-events.c:
      
                             {
                               .name = "tx_nc_tend",
                               .event = "event=0x8d",
                               .desc = "Unit: cpum_cf Completed TEND \
                                        instructions \
                                        in non-constrained TX mode",
                               .topic = "extended",
                               .long_desc = "A TEND instruction has \
                                             completed  in a \
                                             non-constrained \
                                             transactional-execution mode",
                               .pmu = "cpum_cf",
                              },
      
                              Debug output shows this entry
                              tx_nc_tend -> 'cpum_cf'/'event=0x8d'/
      
      Function pmu_aliases_parse() and pmu_add_cpu_aliases() both use
      __perf_pmu__new_alias() to add an alias to the PMU alias list. There is
      no check if an alias already exist
      
      So we end up with 2 entries for tx_nc_tend in the PMU alias list.
      
      Having set up the PMU alias list for this PMU now
      parse_events_multi_add_pmu() reads the complete alias list and adds each
      alias with parse_events_add_pmu() to the global perfev_list.  This
      causes the alias to be added multiple times to the event list.
      
      Fix this by making __perf_pmu__new_alias() to merge alias definitions if
      an alias is already on the alias list.  Also print a debug message when
      the alias has mismatches in some fields.
      
      Output before:
      
        [root@s35lp76 perf]# ./perf stat -e tx_nc_tend  -v \
                              -- ~/mytesttx 1 >/tmp/111
        tx_nc_tend: 1 551446 551446
      
         Performance counter stats for '/root/mytesttx 1':
      
                         3      tx_nc_tend
      
               0.000961134 seconds time elapsed
      
        [root@s35lp76 perf]#
      
      Output after:
      
        [root@s35lp76 perf]#  ./perf stat -e tx_nc_tend  -v \
                              -- ~/mytesttx 1 >/tmp/111
        tx_nc_tend: 1 551446 551446
      
         Performance counter stats for '/root/mytesttx 1':
      
                         1      tx_nc_tend
      
               0.000961134 seconds time elapsed
      
        [root@s35lp76 perf]#
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Reviewed-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180615101105.47047-3-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6dde6429
    • T
      perf alias: Rebuild alias expression string to make it comparable · 0c24d6fb
      Thomas Richter 提交于
      PMU alias definitions in sysfs files may have spaces, newlines and
      numbers with leading zeroes. Some alias definitions may also appear in
      JSON files without spaces, etc.
      
      Scan alias definitions and remove leading zeroes, spaces, newlines, etc
      and rebuild string to make alias->str member comparable.
      
      s390 for example  has terms specified as event=0x0091 (read from files
      ../<PMU>/events/<FILE> and terms specified as event=0x91 (read from JSON
      files).
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180615101105.47047-2-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0c24d6fb
    • T
      perf alias: Remove trailing newline when reading sysfs files · ea23ac73
      Thomas Richter 提交于
      Remove a trailing newline when reading sysfs file contents such as
      /sys/devices/cpum_cf/events/TX_NC_TEND.  This shows when verbose option
      -v is used.
      
      Output before:
      
        tx_nc_tend -> 'cpum_cf'/'event=0x008d
        '/
      
      Output after:
      
        tx_nc_tend -> 'cpum_cf'/'event=0x8d'/
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180615101105.47047-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ea23ac73
    • Y
      perf tools: Fix a clang 7.0 compilation error · c6555c14
      Yonghong Song 提交于
      Arnaldo reported the perf build failure with latest llvm/clang compiler
      (7.0).
      
         $ make LIBCLANGLLVM=1 -C tools/perf/
         <SNIP>
          CC       /tmp/tmp.t53Qo38zci/tests/kmod-path.o
         util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::SmallVectorImpl<char> >
             perf::getBPFObjectFromModule(llvm::Module*)’:
         util/c++/clang.cpp:150:43: error: no matching function for call to
             ‘llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManager&,
              llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)’
                     TargetMachine::CGFT_ObjectFile)) {
                                                   ^
         In file included from util/c++/clang.cpp:25:0:
         /usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate:
             virtual bool llvm::TargetMachine::addPassesToEmitFile(
             llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&,
             llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bool,
             llvm::MachineModuleInfo*)
           virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
                        ^~~~~~~~~~~~~~~~~~~
        /usr/local/include/llvm/Target/TargetMachine.h:254:16: note:
            candidate expects 6 arguments, 3 provided
        mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such file or directory
        make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101:
            /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1
        make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] Error 2
        make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
        make[5]: *** Waiting for unfinished jobs....
          CC       /tmp/tmp.t53Qo38zci/tests/thread-map.o
      
      The function addPassesToEmitFile signature changed in llvm 7.0 and such
      a change caused the failure. This patch fixed the issue with using
      proper function signatures under different compiler versions.
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20180616174739.1076733-1-yhs@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c6555c14
    • A
      perf tools: Update x86's syscall_64.tbl, adding 'io_pgetevents' and 'rseq' · b1494ec0
      Arnaldo Carvalho de Melo 提交于
      This updates the tools/perf/ copy of the system call table for x86 which makes
      'perf trace' become aware of the new 'io_pgetevents' and 'rseq' syscalls, no
      matter in which system it gets built, i.e. older systems where the syscalls are
      not available in the running kernel (via tracefs) or in the system headers will
      still be aware of these syscalls/.
      
      These are the csets introducing the source drift:
      
        05c17ced ("x86: Wire up restartable sequence system call")
        7a074e96 ("aio: implement io_pgetevents")
      
      This results in this build time change:
      
        $ diff -u /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c.old /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c
        --- /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c.old	2018-06-15 11:48:17.648948094 -0300
        +++ /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c	2018-06-15 11:48:22.133942480 -0300
        @@ -332,5 +332,7 @@
                [330] = "pkey_alloc",
                [331] = "pkey_free",
                [332] = "statx",
        +       [333] = "io_pgetevents",
        +       [334] = "rseq",
         };
        -#define SYSCALLTBL_x86_64_MAX_ID 332
        +#define SYSCALLTBL_x86_64_MAX_ID 334
        $
      
      This silences the following tools/perf/ build warning:
      
        Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-tfvyz51sabuzemrszbrhzxni@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b1494ec0
    • A
      perf intel-pt: Fix packet decoding of CYC packets · 621a5a32
      Adrian Hunter 提交于
      Use a 64-bit type so that the cycle count is not limited to 32-bits.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/1528371002-8862-1-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      621a5a32
    • J
      perf tests: Add valid callback for parse-events test · 16ddcfbf
      Jiri Olsa 提交于
      Adding optional 'valid' callback for events tests in parse-events
      object, so we don't try to parse PMUs, which are not supported.
      
      Following line is displayed for skipped test:
      
        running test 52 'intel_pt//u'... SKIP
      
      Committer note:
      
      Use named initializers in the struct evlist_test variable to avoid
      breaking the build on centos:5, 6 and others with a similar gcc:
      
        cc1: warnings being treated as errors
        tests/parse-events.c: In function 'test_pmu_events':
        tests/parse-events.c:1817: error: missing initializer
        tests/parse-events.c:1817: error: (near initialization for 'e.type')
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20180611093422.1005-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      16ddcfbf
    • J
      perf tests: Add event parsing error handling to parse events test · 933ccf20
      Jiri Olsa 提交于
      Add missing error handling for parse_events calls in test_event function
      that led to following segfault on s390:
      
        running test 52 'intel_pt//u'
        perf: Segmentation fault
        ...
        /lib64/libc.so.6(vasprintf+0xe6) [0x3fffca3f106]
        /lib64/libc.so.6(asprintf+0x46) [0x3fffca1aa96]
        ./perf(parse_events_add_pmu+0xb8) [0x80132088]
        ./perf(parse_events_parse+0xc62) [0x8019529a]
        ./perf(parse_events+0x98) [0x801341c0]
        ./perf(test__parse_events+0x48) [0x800cd140]
        ./perf(cmd_test+0x26a) [0x800bd44a]
        test child interrupted
      
      Adding the struct parse_events_error argument to parse_events call. Also
      adding parse_events_print_error to get more details on the parsing
      failures, like:
      
        # perf test 6 -v
        running test 52 'intel_pt//u'failed to parse event 'intel_pt//u', err 1, str 'Cannot find PMU `intel_pt'. Missing kernel support?'
        event syntax error: 'intel_pt//u'
                             \___ Cannot find PMU `intel_pt'. Missing kernel support?
      
      Committer note:
      
      Use named initializers in the struct parse_events_error variable to
      avoid breaking the build on centos5, 6 and others with a similar gcc:
      
        cc1: warnings being treated as errors
        tests/parse-events.c: In function 'test_event':
        tests/parse-events.c:1696: error: missing initializer
        tests/parse-events.c:1696: error: (near initialization for 'err.str')
      Reported-by: NKim Phillips <kim.phillips@arm.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20180611093422.1005-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      933ccf20
    • S
      perf report powerpc: Fix crash if callchain is empty · 143c99f6
      Sandipan Das 提交于
      For some cases, the callchain provided by the kernel may be empty. So,
      the callchain ip filtering code will cause a crash if we do not check
      whether the struct ip_callchain pointer is NULL before accessing any
      members.
      
      This can be observed on a powerpc64le system running Fedora 27 as shown
      below.
      
        # perf record -b -e cycles:u ls
      
      Before:
      
        # perf report --branch-history
      
        perf: Segmentation fault
        -------- backtrace --------
        perf[0x1027615c]
        linux-vdso64.so.1(__kernel_sigtramp_rt64+0x0)[0x7fff856304d8]
        perf(arch_skip_callchain_idx+0x44)[0x10257c58]
        perf[0x1017f2e4]
        perf(thread__resolve_callchain+0x124)[0x1017ff5c]
        perf(sample__resolve_callchain+0xf0)[0x10172788]
        ...
      
      After:
      
        # perf report --branch-history
      
        Samples: 25  of event 'cycles:u', Event count (approx.): 2306870
          Overhead  Source:Line            Symbol                   Shared Object
        +   11.60%  _init+35736            [.] _init                ls
        +    9.84%  strcoll_l.c:137        [.] __strcoll_l          libc-2.26.so
        +    9.16%  memcpy.S:175           [.] __memcpy_power7      libc-2.26.so
        +    9.01%  gconv_charset.h:54     [.] _nl_find_locale      libc-2.26.so
        +    8.87%  dl-addr.c:52           [.] _dl_addr             libc-2.26.so
        +    8.83%  _init+236              [.] _init                ls
        ...
      Reported-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Signed-off-by: NSandipan Das <sandipan@linux.ibm.com>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20180611104049.11048-1-sandipan@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      143c99f6
    • T
      perf test session topology: Fix test on s390 · b930e62e
      Thomas Richter 提交于
      On s390 this test case fails because the socket identifiction numbers
      assigned to the CPU are higher than the CPU identification numbers.
      
      F/ix this by adding the platform architecture into the perf data header
      flag information. This helps identifiing the test platform and handles
      s390 specifics in process_cpu_topology().
      
      Before:
      
        [root@p23lp27 perf]# perf test -vvvvv -F 39
        39: Session topology                                      :
        --- start ---
        templ file: /tmp/perf-test-iUv755
        socket_id number is too big.You may need to upgrade the perf tool.
        ---- end ----
        Session topology: Skip
        [root@p23lp27 perf]#
      
      After:
      
        [root@p23lp27 perf]# perf test -vvvvv -F 39
        39: Session topology                                      :
        --- start ---
        templ file: /tmp/perf-test-8X8VTs
        CPU 0, core 0, socket 6
        CPU 1, core 1, socket 3
        ---- end ----
        Session topology: Ok
        [root@p23lp27 perf]#
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Fixes: c84974ed ("perf test: Add entry to test cpu topology")
      Link: http://lkml.kernel.org/r/20180611073153.15592-2-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b930e62e
    • T
      perf record: Support s390 random socket_id assignment · 01766229
      Thomas Richter 提交于
      On s390 the socket identifier assigned to a CPU identifier is random and
      (depending on the configuration of the LPAR) may be higher than the CPU
      identifier. This is currently not supported.
      
      Fix this by allowing arbitrary socket identifiers being assigned to
      CPU id.
      
      Output before:
      
        [root@p23lp27 perf]# ./perf report --header -I -v
        ...
        socket_id number is too big.You may need to upgrade the perf tool.
        Error:
        The perf.data file has no samples!
        # ========
        # captured on    : Tue May 29 09:29:57 2018
        # header version : 1
        ...
        # Core ID and Socket ID information is not available
        ...
        [root@p23lp27 perf]#
      
      Output after:
      
        [root@p23lp27 perf]# ./perf report --header -I -v
        ...
        Error:
        The perf.data file has no samples!
        # ========
        # captured on    : Tue May 29 09:29:57 2018
        # header version : 1
        ...
        # CPU 0: Core ID 0, Socket ID 6
        # CPU 1: Core ID 1, Socket ID 3
        # CPU 2: Core ID -1, Socket ID -1
        ...
        [root@p23lp27 perf]#
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180611073153.15592-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      01766229
  6. 16 6月, 2018 1 次提交
  7. 09 6月, 2018 2 次提交
    • S
      perf script: Show hw-cache events · fad76d43
      Seeteena Thoufeek 提交于
      'perf script' fails to report hardware cache events (PERF_TYPE_HW_CACHE)
      where as 'perf report' shows the samples. Fix it. Ex,
      
        # perf record -e L1-dcache-loads ./a.out
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.008 MB perf.data (11 samples)]
      
      Before patch:
      
        # perf script | wc -l
        0
      
      After patch:
      
        # perf script | wc -l
        11
      
      Committer testing:
      
        [root@jouet ~]# perf script | head -30 | tail
              Timer 9803 [2] 8.963330:  1554 L1-dcache-loads: 7ffef89baae4 __vdso_clock_gettime+0xf4 ([vdso])
            swapper    0 [2] 8.963343:  5626 L1-dcache-loads: ffffffffa66f4f6b cpuidle_not_av+0xb (/lib/modules/4.17.0-rc5/build/vmlinux)
            firefox 4853 [2] 8.964070: 18935 L1-dcache-loads: 7f0b9a00dc30 xcb_poll_for_event+0x0 (/usr/lib64/libxcb.so.1.1.0)
        Softwar~cTh 4928 [2] 8.964548: 15928 L1-dcache-loads: ffffffffa60d795c update_curr+0x10c (/lib/modules/4.17.0-rc5/build/vmlinux)
            firefox 4853 [2] 8.964675: 14978 L1-dcache-loads: ffffffffa6897018 mutex_unlock+0x18 (/lib/modules/4.17.0-rc5/build/vmlinux)
        gnome-shell 2026 [3] 8.964693: 50670 L1-dcache-loads: 7fa08854de6d g_source_iter_next+0x6d (/usr/lib64/libglib-2.0.so.0.5400.3)
         Compositor 4929 [1] 8.964784: 71772 L1-dcache-loads: 7f0b936bf078 [unknown] (/usr/lib64/firefox/libxul.so)
           Xwayland 2096 [2] 8.964919: 16799 L1-dcache-loads: 7f68ce2fcb8a glXGetCurrentContext+0x1a (/usr/lib64/libGLX.so.0.0.0)
        gnome-shell 2026 [3] 8.964997: 50670 L1-dcache-loads: 7fa08854de6d g_source_iter_next+0x6d (/usr/lib64/libglib-2.0.so.0.5400.3)
        [root@jouet ~]#
      Signed-off-by: NSeeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1528455748-20087-1-git-send-email-s1seetee@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fad76d43
    • J
      perf c2c: Keep struct hist_entry at the end of struct c2c_hist_entry · 4c820527
      Jiri Olsa 提交于
      Exactly as the comment just before 'struct c2c_hist_entry" says, i.e.
      the last entry in struct hist_entry is a zero length array, that when
      allocating space for hist_entry gets extra space if callchains are in
      use, which, if hist_entry is not at the end of c2c_hist_entry, the
      members after it gets corrupted when callchains get added to the rb
      trees collecting them, etc.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Reported-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Fixes: 7f834c2e ("perf c2c report: Display node for cacheline address")
      Link: http://lkml.kernel.org/n/tip-bh0ke4fh2ygpj3yowna7o1di@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4c820527
  8. 08 6月, 2018 5 次提交