Skip to content
  1. Jul 26, 2016
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160725' of... · 674d2d69
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-20160725' 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:
      
      - Add AVX-512 support to the instruction decoder, used by Intel PT,
        fix vcvtph2ps instruction decoding (Adrian Hunter)
      
      - Make objtool and vdso2c use the right arch header search path
        (Stephen Rothwell, Josh Poimboeuf, Arnaldo Carvalho de Melo)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      674d2d69
  2. Jul 25, 2016
  3. Jul 23, 2016
    • Josh Poimboeuf's avatar
      tools build: Fix objtool build with ARCH=x86_64 · 60cbdf5d
      Josh Poimboeuf authored
      
      
      The objtool build fails in a cross-compiled environment on a non-x86
      host with "ARCH=x86_64":
      
        tools/objtool/objtool-in.o: In function `decode_instructions':
        tools/objtool/builtin-check.c:276: undefined reference to `arch_decode_instruction'
      
      We could override the ARCH environment variable and change it back to
      x86, similar to what the objtool Makefile was doing before; but it's
      tricky to override environment variables consistently.
      
      Instead, take a similar approach used by the Linux top-level Makefile
      and introduce a SRCARCH Makefile variable which evaluates to "x86" when
      ARCH is either "x86_64" or "x86".
      
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20160722191920.ej62fnspnqurbaa7@treble
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      60cbdf5d
    • Arnaldo Carvalho de Melo's avatar
      objtool: Always use host headers · 0cf6eb60
      Arnaldo Carvalho de Melo authored
      
      
      From a conversation with Josh:
      
      From http://lkml.kernel.org/r/20160722034118.guckaniobf3f7czc@treble :
      
      It needs to be compiled with the host (powerpc) compiler, but then it
      needs to disassemble target (x86) files.
      
       ----
      
      So use HOSTARCH instead of ARCH.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20160722034118.guckaniobf3f7czc@treble
      Link: http://lkml.kernel.org/n/tip-le1m1yzxnfpt3msbblu40nm8@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0cf6eb60
    • Arnaldo Carvalho de Melo's avatar
      objtool: Use tools/scripts/Makefile.arch to get ARCH and HOSTARCH · 630e7a29
      Arnaldo Carvalho de Melo authored
      
      
      objtool's Makefile was setting up ARCH but fixing up just the x86_64 ->
      x86, using Makefile.arch will do the necessary fixups for all arches.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-hbq0bbh03u2b722vozcyql31@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      630e7a29
    • Arnaldo Carvalho de Melo's avatar
      tools build: Add HOSTARCH Makefile variable · 0a943cb1
      Arnaldo Carvalho de Melo authored
      
      
      For tools that needs to be always compiled with the host headers.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-907q32k2nep6q670dkxypmu6@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a943cb1
    • Arnaldo Carvalho de Melo's avatar
      perf tests kmod-path: Fix build on ubuntu:16.04-x-armhf · e5e6312b
      Arnaldo Carvalho de Melo authored
      
      
      Cross building it on Ubuntu 16.04 to ARM ends up showing we get
      the free() prototype by luck in other environments, fix it.
      
      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: http://lkml.kernel.org/n/tip-0ktfgmmyhcfw8ondka2013f3@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e5e6312b
  4. Jul 21, 2016
    • Adrian Hunter's avatar
      perf tools: Add AVX-512 instructions to the new instructions test · 6c4d0b41
      Adrian Hunter authored
      
      
      Previous patches added support for Intel's AVX-512 instructions to the
      kernel and perf tools instruction decoders.
      
      AVX-512 instructions are documented in Intel Architecture Instruction
      Set Extensions Programming Reference (February 2016).
      
      Add a representative set of instructions to perf's "new instructions"
      test. e.g.
      
      	perf test "new instructions"
      
      Or to view a particular instruction:
      
      	perf test -v "new instructions" 2>&1 | grep vbroadcasti64x4
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: X86 ML <x86@kernel.org>
      Link: http://lkml.kernel.org/r/1469003437-32706-5-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6c4d0b41
    • Adrian Hunter's avatar
      perf tools: Add AVX-512 support to the instruction decoder used by Intel PT · c61f4d5e
      Adrian Hunter authored
      
      
      Add support for Intel's AVX-512 instructions to perf tools instruction
      decoder used by Intel PT.  The kernel's instruction decoder was updated in
      a previous patch.
      
      AVX-512 instructions are documented in Intel Architecture Instruction Set
      Extensions Programming Reference (February 2016).
      
      AVX-512 instructions are identified by a EVEX prefix which, for the purpose
      of instruction decoding, can be treated as though it were a 4-byte VEX
      prefix.
      
      Existing instructions which can now accept an EVEX prefix need not be
      further annotated in the op code map (x86-opcode-map.txt). In the case of
      new instructions, the op code map is updated accordingly.
      
      Also add associated Mask Instructions that are used to manipulate mask
      registers used in AVX-512 instructions.
      
      A representative set of instructions is added to the perf tools new
      instructions test in a subsequent patch.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: X86 ML <x86@kernel.org>
      Link: http://lkml.kernel.org/r/1469003437-32706-4-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c61f4d5e
    • Adrian Hunter's avatar
      x86/insn: Add AVX-512 support to the instruction decoder · 25af37f4
      Adrian Hunter authored
      
      
      Add support for Intel's AVX-512 instructions to the instruction decoder.
      
      AVX-512 instructions are documented in Intel Architecture Instruction
      Set Extensions Programming Reference (February 2016).
      
      AVX-512 instructions are identified by a EVEX prefix which, for the
      purpose of instruction decoding, can be treated as though it were a
      4-byte VEX prefix.
      
      Existing instructions which can now accept an EVEX prefix need not be
      further annotated in the op code map (x86-opcode-map.txt). In the case
      of new instructions, the op code map is updated accordingly.
      
      Also add associated Mask Instructions that are used to manipulate mask
      registers used in AVX-512 instructions.
      
      The 'perf tools' instruction decoder is updated in a subsequent patch.
      And a representative set of instructions is added to the perf tools new
      instructions test in a subsequent patch.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: X86 ML <x86@kernel.org>
      Link: http://lkml.kernel.org/r/1469003437-32706-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      25af37f4
  5. Jul 20, 2016
  6. Jul 19, 2016
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160718' of... · 5048c2af
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-20160718' 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:
      
      User visible changes:
      
       - Properly report when a function wildcard produces no matches in 'perf probe'
         (Masami Hiramatsu)
      
       - Balance opening and reading events in 'perf stat', which could cause
         it to get stuck trying to close invalid file descriptors (Mark Rutland)
      
      Infrastructure changes:
      
       - Copy more headers from the kernel, this time for headers that
         were just including the contents of its kernel counterparts, should
         help resolving the problems with linux-next, where some uapi related
         patches seem to be breaking tools/object/ build. (Arnaldo Carvalho de Melo)
      
         Some more combing will be done, but at least it is possible to build
         perf out of tree, via a detached tarball (make help | grep perf),
         without including kernel files in its MANIFEST (Arnaldo Carvalho de Melo)
      
       - Fix smatch found errors that were not causing problems, but are
         mistakes nonetheless (Dan Carpenter)
      
       - Fix string vs. byte array resolving in the python script code (Jiri Olsa)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5048c2af
    • Jiri Olsa's avatar
      perf tests: Add is_printable_array test · 988dd774
      Jiri Olsa authored
      
      
      Add automated test for is_printable_array function.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1468685480-18951-4-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      988dd774
    • Jiri Olsa's avatar
      perf tools: Make is_printable_array global · accaed26
      Jiri Olsa authored
      
      
      It's used from 2 objects in perf, so it's better to keep just one copy.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1468685480-18951-3-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      accaed26
    • Jiri Olsa's avatar
      perf script python: Fix string vs byte array resolving · 249de6e0
      Jiri Olsa authored
      
      
      Jirka reported that python code returns all arrays as strings.  This
      makes impossible to get all items for byte array tracepoint field
      containing 0x00 value item.
      
      Fixing this by scanning full length of the array and returning it as
      PyByteArray object in case non printable byte is found.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Reported-and-Tested-by: default avatarJiri Pirko <jiri@mellanox.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1468685480-18951-2-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      249de6e0
    • Masami Hiramatsu's avatar
      perf probe: Warn unmatched function filter correctly · e7049342
      Masami Hiramatsu authored
      
      
      Warn unmatched function filter correctly instead of warning
      "symbol-loading error", since that can be a filter issue.
      
      From the technical point of view, this adds a filter chech in map__load
      and if there is a filter, it returns -2 (filter-out), instead of -1
      (error), and perf-probe checks it and change message.
      
      E.g. without this fix:
      
        # perf probe -F rt_sp*
        no symbols found in [kernel.kallsyms], maybe install a debug package?
        Failed to load symbols in kernel
      
      With this fix:
      
        # perf probe -F rt_sp*
        no symbols passed the given filter.
        Failed to find symbols matched to "rt_sp*"
          Error: Failed to show functions.
      
      Reported-and-Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146885835596.16106.2293540792775552481.stgit@devbox
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e7049342
    • Mark Rutland's avatar
      perf cpu_map: Add more helpers · 9a6c582d
      Mark Rutland authored
      
      
      In some cases it's necessry to figure out the map-local index of a given
      Linux logical CPU ID. Add a new helper, cpu_map__idx, to acquire this.
      As the logic is largely the same as the existing cpu_map__has, this is
      rewritten in terms of the new helper.
      
      At the same time, add the inverse operation, cpu_map__cpu, which yields
      the logical CPU id for a map-local index. While this can be performed
      manually, wrapping this in a helper can make code more legible.
      
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1468577293-19667-3-git-send-email-mark.rutland@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9a6c582d
    • Mark Rutland's avatar
      perf stat: Balance opening and reading events · 00e727bb
      Mark Rutland authored
      
      
      In create_perf_stat_counter, when a target CPU has not been provided, we
      call __perf_evsel__open with empty_cpu_map, and open a single FD per
      thread. However, in read_counter we assume that we opened events for the
      product of threads and CPUs described in the evsel's cpu_map.
      
      Thus, if an evsel has a cpu_map with more than one entry, we will
      attempt to access FDs that we didn't open. This could result in a number
      of problems (e.g. blocking while reading from STDIN if the fd memory
      happened to be initialised to zero).
      
      This is problematic for systems were a logical CPU PMU covers some
      arbitrary subset of CPUs. The cpu_map of any evsel for that PMU will be
      initialised based on the cpumask exposed through sysfs, even if the user
      requests per-thread events.
      
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1468577293-19667-2-git-send-email-mark.rutland@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      00e727bb
    • Arnaldo Carvalho de Melo's avatar
      tools: Copy linux/{hash,poison}.h and check for drift · ae3c14a0
      Arnaldo Carvalho de Melo authored
      
      
      We were also using this directly from the kernel sources, the two last
      cases, fix it.
      
      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: http://lkml.kernel.org/n/tip-7o14xvacqcjc5llc7gvjjyl8@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae3c14a0
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Remove include/linux/list.h from perf's MANIFEST · 3aa00427
      Arnaldo Carvalho de Melo authored
      It hasn't been used since we made tools/ self sufficiente wrt list.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: d1b39d41
      
       ("tools: Make list.h self-sufficient")
      Link: http://lkml.kernel.org/n/tip-w20ueqlf22kh7ctjqo0zjpig@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3aa00427
    • Arnaldo Carvalho de Melo's avatar
      tools: Copy the bitops files accessed from the kernel and check for drift · de1e17b1
      Arnaldo Carvalho de Melo authored
      
      
      copy some more kernel files accessed from tools/, check for drift.
      
      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: http://lkml.kernel.org/n/tip-omz8xdyvvxgjiuqzwj6ecm6j@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      de1e17b1
    • Arnaldo Carvalho de Melo's avatar
      Remove: kernel unistd*h files from perf's MANIFEST, not used · ad430729
      Arnaldo Carvalho de Melo authored
      
      
      No need to copy it to a detached tarball as they aren't used anymore
      
      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: http://lkml.kernel.org/n/tip-lopmaqi439ke10g1j9cxrxwt@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad430729
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Remove tools/perf/util/include/linux/const.h · e0643c4e
      Arnaldo Carvalho de Melo authored
      
      
      Not used anymore, remove one more file referencing kernel sources, i.e.
      outside of tools/
      
      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: http://lkml.kernel.org/n/tip-ykfjt3t8l0npxfwmekiwwyu6@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e0643c4e
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Remove tools/perf/util/include/asm/byteorder.h · 7e3f3641
      Arnaldo Carvalho de Melo authored
      
      
      Not used anymore. This also stops include linux/swab.h directly
      from the kernel sources, remove that reference from the MANIFEST.
      
      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>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7e3f3641
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Add missing linux/compiler.h include to perf-sys.h · 14f0652b
      Arnaldo Carvalho de Melo authored
      
      
      It uses the likely/unlikely macros, so need to include
      <linux/compiler.h>.
      
      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: http://lkml.kernel.org/n/tip-p0xrhgbkicsii9ohmhhprqpi@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      14f0652b
  7. Jul 18, 2016
  8. Jul 17, 2016
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160715' of... · 09211e25
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-20160715' 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:
      
      User visible changes:
      
       - Allow reading from a backward ring buffer (one setup via sys_perf_event_open()
         with perf_event_attr.write_backward = 1) (Wang Nan)
      
      Infrastructure changes:
      
       - Fix the build on Android NDK r12b (initially just for ARM), that is now port
         of my perf-build container collection and will get tested prior to sending
         patches upstream (Arnaldo Carvalho de Melo)
      
       - Add correct header for IPv6 definitions
      
       - Fix bitsperlong.h fallout (Arnaldo Carvalho de Melo, Peter Zijlstra)
      
       - Use base 0 (auto) in filename__read_ull(), so that we can handle hex values too (Jiri Olsa)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      09211e25
  9. Jul 16, 2016
    • Arnaldo Carvalho de Melo's avatar
      objtool: Initialize variable to silence old compiler · b49364f3
      Arnaldo Carvalho de Melo authored
      
      
      gcc version 4.1.2 20080704 (Red Hat 4.1.2-55) barfs with:
      
          CC       /tmp/build/objtool/builtin-check.o
        cc1: warnings being treated as errors
        builtin-check.c: In function 'cmd_check':
        builtin-check.c:667: warning: 'prev_rela' may be used uninitialized in this function
        mv: cannot stat `/tmp/build/objtool/.builtin-check.o.tmp': No such file or directory
        make[1]: *** [/tmp/build/objtool/builtin-check.o] Error 1
      
      Init it to NULL to silence it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-qolo31rl2ojlwj1lj9dhemyz@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b49364f3
    • Arnaldo Carvalho de Melo's avatar
      objtool: Add -I$(srctree)/tools/arch/$(ARCH)/include/uapi · 4a0982f9
      Arnaldo Carvalho de Melo authored
      
      
      So that it can find asm/bitsperlong.h to get the __BITS_PER_LONG
      definition.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-pr3pvskh65pey4po7t122z4j@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4a0982f9
    • Wang Nan's avatar
      perf record: Add --tail-synthesize option · 4ea648ae
      Wang Nan authored
      
      
      When working with overwritable ring buffer there's a inconvenience
      problem: if perf dumps data after a long period after it starts,
      non-sample events may lost, which makes following 'perf report' unable
      to identify proc name and mmap layout. For example:
      
       # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output \
              dd if=/dev/zero of=/dev/null
      
      send SIGUSR2 after dd runs long enough. The resuling perf.data lost
      correct comm and mmap events:
      
       # perf script -i perf.data.2016061522374354
       perf 24478 [004] 2581325.601789:  raw_syscalls:sys_exit: NR 0 = 512
       ^^^^
       Should be 'dd'
                         27b2e8 syscall_slow_exit_work+0xfe2000e3 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                         203cc7 do_syscall_64+0xfe200117 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                         b18d83 return_from_SYSCALL_64+0xfe200000 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                   7f47c417edf0 [unknown] ([unknown])
                   ^^^^^^^^^^^^
                   Fail to unwind
      
      This patch provides a '--tail-synthesize' option, allows perf to collect
      system status when finalizing output file. In resuling output file, the
      non-sample events reflect system status when dumping data.
      
      After this patch:
       # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output --tail-synthesize \
              dd if=/dev/zero of=/dev/null
      
       # perf script -i perf.data.2016061600544998
       dd 27364 [004] 2583244.994464: raw_syscalls:sys_enter: NR 1 (1, ...
       ^^
       Correct comm
                         203a18 syscall_trace_enter_phase2+0xfe2001a8 ([kernel.kallsyms])
                         203aa5 syscall_trace_enter+0xfe200055 ([kernel.kallsyms])
                         203caa do_syscall_64+0xfe2000fa ([kernel.kallsyms])
                         b18d83 return_from_SYSCALL_64+0xfe200000 ([kernel.kallsyms])
                          d8e50 __GI___libc_write+0xffff01d9639f4010 (/tmp/oxygen_root-w00229757/lib64/libc-2.18.so)
                          ^^^^^
                          Correct unwind
      
      This option doesn't aim to solve this problem completely. If a process
      terminates before SIGUSR2, we still lost its COMM and MMAP events. For
      example, we can't unwind correctly from the final perf.data we get from
      the previous example, because when perf collects the final output file
      (when we press C-c), 'dd' has been terminated so its '/proc/<pid>/mmap'
      becomes empty.
      
      However, this is a cheaper choice. To completely solve this problem we
      need to continously output non-sample events. To satisify the
      requirement of daemonization, we need to merge them periodically. It is
      possible but requires much more code and cycles.
      
      Automatically select --tail-synthesize when --overwrite is provided.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-16-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4ea648ae
    • Wang Nan's avatar
      perf session: Don't warn about out of order event if write_backward is used · f06149c0
      Wang Nan authored
      
      
      If write_backward attribute is set, records are written into kernel
      ring buffer from end to beginning, but read from beginning to end.
      To avoid 'XX out of order events recorded' warning message (timestamps
      of records is in reverse order when using write_backward), suppress the
      warning message if write_backward is selected by at lease one event.
      
      Result:
      
      Before this patch:
        # perf record -m 1 -e raw_syscalls:sys_exit/overwrite/ \
                           -e raw_syscalls:sys_enter \
                           dd if=/dev/zero of=/dev/null count=300
        300+0 records in
        300+0 records out
        153600 bytes (154 kB) copied, 0.000601617 s, 255 MB/s
        [ perf record: Woken up 5 times to write data ]
        Warning:
        40 out of order events recorded.
        [ perf record: Captured and wrote 0.096 MB perf.data (696 samples) ]
      
      After this patch:
        # perf record -m 1 -e raw_syscalls:sys_exit/overwrite/ \
                           -e raw_syscalls:sys_enter \
                           dd if=/dev/zero of=/dev/null count=300
        300+0 records in
        300+0 records out
        153600 bytes (154 kB) copied, 0.000644873 s, 238 MB/s
        [ perf record: Woken up 5 times to write data ]
        [ perf record: Captured and wrote 0.096 MB perf.data (696 samples) ]
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-15-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f06149c0
    • Wang Nan's avatar
      perf tools: Enable overwrite settings · 626a6b78
      Wang Nan authored
      
      
      This patch allows following config terms and option:
      
      Globally setting events to overwrite;
      
        # perf record --overwrite ...
      
      Set specific events to be overwrite or no-overwrite.
      
        # perf record --event cycles/overwrite/ ...
        # perf record --event cycles/no-overwrite/ ...
      
      Add missing config terms and update the config term array size because
      the longest string length has changed.
      
      For overwritable events, it automatically selects attr.write_backward
      since perf requires it to be backward for reading.
      
      Test result:
      
        # perf record --overwrite -e syscalls:*enter_nanosleep* usleep 1
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ]
        # perf evlist -v
        syscalls:sys_enter_nanosleep: type: 2, size: 112, config: 0x134, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, write_backward: 1
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-14-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      626a6b78
    • Wang Nan's avatar
      perf evlist: Make {pause,resume} internal helpers · f6cdff83
      Wang Nan authored
      
      
      There's no user of these two function outside evlist.c. Remove them from
      public namespace.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-13-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6cdff83
    • Wang Nan's avatar
      perf record: Read from overwritable ring buffer · 05737464
      Wang Nan authored
      
      
      Drive the evlist->bkw_mmap_state state machine during draining and when
      SIGUSR2 is received. Read the backward ring buffer in record__mmap_read_all.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-12-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      05737464
    • Wang Nan's avatar
      perf evlist: Setup backward mmap state machine · 54cc54de
      Wang Nan authored
      
      
      Introduce a bkw_mmap_state state machine to evlist:
      
                           .________________(forbid)_____________.
                           |                                     V
       NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
                           ^  ^              |   ^               |
                           |  |__(forbid)____/   |___(forbid)___/|
                           |                                     |
                            \_________________(3)_______________/
      
       NOTREADY     : Backward ring buffers are not ready
       RUNNING      : Backward ring buffers are recording
       DATA_PENDING : We are required to collect data from backward ring buffers
       EMPTY        : We have collected data from backward ring buffers.
      
       (0): Setup backward ring buffer
       (1): Pause ring buffers for reading
       (2): Read from ring buffers
       (3): Resume ring buffers for recording
      
      We can't avoid this complexity. Since we deliberately drop records from
      overwritable ring buffer, there's no way for us to check remaining from
      ring buffer itself (by checking head and old pointers). Therefore, we
      need DATA_PENDING and EMPTY state to help us recording what we have done
      to the ring buffer.
      
      In record__mmap_read_evlist(), drive this state machine from DATA_PENDING
      to EMPTY.
      
      In perf_evlist__mmap_per_evsel(), drive this state machine from NOTREADY
      to RUNNING when creating backward mmap.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-11-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54cc54de
    • Wang Nan's avatar
      perf evlist: Drop evlist->backward · a0c6f451
      Wang Nan authored
      
      
      Now there's no real user of evlist->backward. Drop it. We are going to
      use evlist->backward_mmap as a container for backward ring buffer.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-10-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a0c6f451
    • Wang Nan's avatar
      perf evlist: Map backward events to backward_mmap · 078c3386
      Wang Nan authored
      
      
      In perf_evlist__mmap_per_evsel(), select backward_mmap for backward
      events.  Utilize new perf_mmap APIs. Dynamically alloc backward_mmap.
      
      Remove useless functions.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-9-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      078c3386
    • Wang Nan's avatar
      perf evlist: Introduce backward_mmap array for evlist · b2cb615d
      Wang Nan authored
      
      
      Add backward_mmap to evlist, free it together with normal mmap.
      
      Improve perf_evlist__pick_pc(), search backward_mmap if evlist->mmap is
      not available.
      
      This patch doesn't alloc this array. It will be allocated conditionally
      in the following commits.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-8-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2cb615d