1. 07 Jun, 2016 16 commits
    • He Kuang's avatar
      perf callchain: Support x86 target platform · 52ffe0ff
      He Kuang authored
      Support x86(32-bit) cross platform callchain unwind.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-14-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      52ffe0ff
    • He Kuang's avatar
      perf unwind: Introduce flag to separate local/remote unwind compilation · 19473e7b
      He Kuang authored
      This is a preparation for including unwind-libunwind-local.c in other
      files for remote libunwind.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-13-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      19473e7b
    • He Kuang's avatar
      perf unwind: Change fixed name of libunwind__arch_reg_id to macro · eeb118c5
      He Kuang authored
      For local libunwind, it uses the fixed methods to convert register id
      according to the host platform, but in remote libunwind, this convert
      function should be the one for remote architecture. This patch changes
      the fixed name to macro and code for each remote platform can be
      compiled indivadually.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-12-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eeb118c5
    • He Kuang's avatar
      perf unwind: Check the target platform before assigning unwind methods · d64ec10e
      He Kuang authored
      Currently, 'perf script' uses host unwind methods to parse perf.data
      callchain info without taking the target architecture into account, i.e.
      assuming the perf.data file was generated on the same machine where the
      analysis is being performed. So we get wrong result without any warnings
      when unwinding callchains of x86(32-bit) on x86(64-bit) machine.
      
      This patch adds an extra step that checks the target platform before
      assigning unwind methods. In later patches in this series, we can use
      this info to assign the right unwind methods for supported platforms.
      
      Committer note:
      
      After fixing it to register the local unwinder for live mode tools
      ('perf trace', 'perf top'), i.e. tools that don't use a perf.data file,
      it works as intended and passes the 'perf test unwind' test:
      
        # perf trace -e nanosleep --call dwarf usleep 1
           0.328 ( 0.058 ms): usleep/11115 nanosleep(rqtp: 0x7fff083fa480) = 0
                                             __nanosleep_nocancel+0x7 (/usr/lib64/libc-2.22.so)
                                             usleep+0x34 (/usr/lib64/libc-2.22.so)
                                             main+0x1eb (/usr/bin/usleep)
                                             __libc_start_main+0xf0 (/usr/lib64/libc-2.22.so)
                                             _start+0x29 (/usr/bin/usleep)
        # perf test 48
        48: Test dwarf unwind         : Ok
        #
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-11-git-send-email-hekuang@huawei.com
      [ Fixed exit path for 'live' mode tools, where we need to default to local unwinding ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d64ec10e
    • He Kuang's avatar
      perf tools: Export normalize_arch() function · 940e6987
      He Kuang authored
      Export normalize_arch() function, so other part of perf can get
      normalized form of arch string.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-10-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      940e6987
    • He Kuang's avatar
      perf tools: Extract common API out of unwind-libunwind-local.c · f6d72532
      He Kuang authored
      This patch extracts common unwind-libunwind APIs out of
      unwind-libunwind-local.c, this part will be used by both local and
      remote libunwind.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-9-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6d72532
    • He Kuang's avatar
      perf unwind: Rename unwind-libunwind.c to unwind-libunwind-local.c · a597b547
      He Kuang authored
      Since unwind-libunwind.c contains code for specific arithecture, we
      change it's name to unwind-libunwind-local.c, and let it only be built
      if local libunwind is supported.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-8-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a597b547
    • He Kuang's avatar
      perf unwind: Separate local/remote libunwind config · 9d8e14d3
      He Kuang authored
      CONFIG_LIBUNWIND/NO_LIBUNWIND are changed to CONFIG_LOCAL_LIBUNWIND/
      NO_LOCAL_LIBUNWIND for retaining local unwind features. The new
      CONFIG_LIBUNWIND stands for either local or remote or both unwind are
      supported, and NO_LIBUNWIND means that neither local nor remote unwind
      is supported.
      
      LIBUNWIND_LIBS is eliminated in LDFLAGS if local libunwind is not
      supported.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-7-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d8e14d3
    • He Kuang's avatar
      perf unwind: Don't mix LIBUNWIND_LIBS into LIBUNWIND_LDFLAGS · 403cacb8
      He Kuang authored
      LIBUNWIND_LIBS contains libunwind libraries used for local only, don't
      mix this into LIBUNWIND_LDFLAGS so we can later use LIBUNWIND_LDFLAGS
      both for local and remote libunwind.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-6-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      403cacb8
    • He Kuang's avatar
      perf unwind: Move unwind__prepare_access from thread_new into thread__insert_map · 8132a2a8
      He Kuang authored
      To determine the libunwind methods to use, we should get the
      32bit/64bit information from maps of a thread. When a thread is newly
      created, the information is not prepared. This patch moves
      unwind__prepare_access() into thread__insert_map() so we can get the
      information we need from maps. Meanwhile, let thread__insert_map()
      return value and show messages on error.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-5-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8132a2a8
    • He Kuang's avatar
      perf unwind: Introduce 'struct unwind_libunwind_ops' for local unwind · f83c0415
      He Kuang authored
      Currently, libunwind operations are fixed, and they are chosen according
      to the host architecture. This will lead to a problem that if a thread
      is run as x86_32 on a x86_64 machine, perf will use libunwind methods
      for x86_64 to parse the callchain and get wrong results.
      
      This patch changes the fixed methods of libunwind operations to be
      thread/map related, and each thread can have individual libunwind
      operations. Local libunwind methods are registered as default value.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-4-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f83c0415
    • He Kuang's avatar
      perf unwind: Decouple thread->address_space on libunwind · c1d1d0d9
      He Kuang authored
      Currently, the type of thread->addr_space is unw_addr_space_t, which is
      a pointer defined in libunwind headers. For local libunwind, we can
      simple include "libunwind.h", but for remote libunwind, the header file
      is depends on the target libunwind platform. This patch uses 'void *'
      instead to decouple the dependence on libunwind.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-3-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c1d1d0d9
    • He Kuang's avatar
      perf unwind: Use LIBUNWIND_DIR for remote libunwind feature check · 195106b9
      He Kuang authored
      Pass LIBUNWIND_DIR to feature check flags for remote libunwind
      tests. So perf can be able to detect remote libunwind libraries from
      arbitrary directory.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.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: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1464924803-22214-2-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      195106b9
    • Taeung Song's avatar
      perf config: Use new perf_config_set__init() to initialize config set · 8beeb00f
      Taeung Song authored
      Instead of perf_config(), this function initializes config set by
      reading various files: user config ~/.perfconfig and system config
      $(sysconfdir)/perfconfig).
      
      If there are the same config variable in both user and system config
      files, user config has higher priority than system config.
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1465291577-20973-3-git-send-email-treeze.taeung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8beeb00f
    • Taeung Song's avatar
      perf config: Constructor should free its allocated memory when failing · 25d8f48f
      Taeung Song authored
      Because of die() at perf_parse_file() a config set was freed in
      collect_config(), if failed.  But it is natural to free a config set
      after collect_config() is done when some problems happened.
      
      So, in case of failure, lastly free a config set at perf_config_set__new()
      instead of freeing the config set in collect_config().
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1465291577-20973-2-git-send-email-treeze.taeung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      25d8f48f
    • Wang Nan's avatar
      perf tools: Fix crash in build_id_cache__kallsyms_path() · c58c49ac
      Wang Nan authored
      build_id_cache__kallsyms_path() accepts a string buffer but also allocs
      a buffer using asnprintf. Unfortunately, the its only user passes it a
      stack-allocated buffer. Freeing it causes crashes like this:
      
        $ perf script
        *** Error in `/home/wangnan/perf': free(): invalid pointer: 0x00007fffffff9630 ***
        ======= Backtrace: =========
        lib64/libc.so.6(+0x6eeef)[0x7ffff5dbaeef]
        lib64/libc.so.6(+0x78cae)[0x7ffff5dc4cae]
        lib64/libc.so.6(+0x79987)[0x7ffff5dc5987]
        /home/w00229757/perf(build_id_cache__kallsyms_path+0x6b)[0x49681b]
        /home/w00229757/perf[0x4bdd40]
        /home/w00229757/perf(dso__load+0xa3a)[0x4c048a]
        /home/w00229757/perf(map__load+0x6f)[0x4d561f]
        /home/w00229757/perf(thread__find_addr_map+0x235)[0x49e935]
        /home/w00229757/perf(machine__resolve+0x7d)[0x49ec6d]
        /home/w00229757/perf[0x4555a8]
        /home/w00229757/perf[0x4d9507]
        /home/w00229757/perf[0x4d9e80]
        /home/w00229757/perf(ordered_events__flush+0x354)[0x4dd444]
        /home/w00229757/perf(perf_session__process_events+0x3d0)[0x4dc140]
        /home/w00229757/perf(cmd_script+0x12b0)[0x4592e0]
        /home/w00229757/perf[0x4911f1]
        /home/w00229757/perf(main+0x68f)[0x4352ef]
        /lib64/libc.so.6(__libc_start_main+0xf5)[0x7ffff5d6dbd5]
        /home/w00229757/perf[0x435415]
        ======= Memory map: ========
      
      This patch simplifies build_id_cache__kallsyms_path(), not even
      considering allocating a string buffer, so never frees anything. Its
      caller should manage memory allocation.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Fixes: 01412261 ("perf buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid")
      Link: http://lkml.kernel.org/r/1465271678-7392-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c58c49ac
  2. 06 Jun, 2016 14 commits
  3. 03 Jun, 2016 10 commits
    • He Kuang's avatar
      perf script: Show call graphs when 1st event doesn't have it but some other has · 40f20e50
      He Kuang authored
      There's a display inconsistency when there are multiple tracepoint
      events, some of which have the 'call-graph' config option set but the
      first one hasn't, i.e. the whole logic for call graph processing is
      enabled only if the first tracepoint event has call-graph set.
      
      For instance, if we record signal_deliver with call-graph and
      signal_generate without:
      
        $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/
      
        [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
      
        $ perf script
      
        kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
        perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
                    7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
                    7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
                    7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
                    ...
      
      Then we exchange the order of these two events in commandline, and keep
      signal_generate without call-graph.
      
        $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver
      
        [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
      
        $ perf script
      
          kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
                  perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
      
      This time, the callchain of the event signal_deliver disappeared. The
      problem is caused by that perf only checks for the first evsel in evlist
      and decides if callchain should be printed.
      
      This patch traverses all evsels in evlist to see if any of them have
      callchains, and shows the right result:
      
        $ perf script
      
        kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
        perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
                    7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
                    7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
                    7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
                    ...
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1463374279-97209-1-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      40f20e50
    • Lucas Stach's avatar
      tools lib api: Respect CROSS_COMPILE for the linker · 703e0165
      Lucas Stach authored
      This fixes cross compilation of libapi.
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: kernel@pengutronix.de
      Cc: patchwork-lst@pengutronix.de
      Link: http://lkml.kernel.org/r/1458235670-27341-1-git-send-email-l.stach@pengutronix.deSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      703e0165
    • Wang Nan's avatar
      perf evlist: Fix alloc_mmap() failure path · 946ae1d4
      Wang Nan authored
      If zalloc fail, setting evlist->mmap[i].fd is unsafe and
      perf_evlist__alloc_mmap() should bail out right after that.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Fixes: d4c6fb36 ("perf evsel: Record fd into perf_mmap")
      Link: http://lkml.kernel.org/r/1464699975-230440-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      946ae1d4
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Provide way to extract integer value from format_field · 90525176
      Arnaldo Carvalho de Melo authored
      Out of perf_evsel__intval(), that requires passing the variable name,
      that will then be searched in the list of tracepoint variables for the
      given evsel.
      
      In cases such as syscall file descriptor ("fd") tracking, this is
      wasteful, we need just to use perf_evsel__field() and cache the
      format_field.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-r6f89jx9j5nkx037d0naviqy@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      90525176
    • Andi Kleen's avatar
      perf/x86/intel: Use new topology_max_smt_threads() in HT leak workaround · 030ba6cd
      Andi Kleen authored
      Now that we have topology_max_smt_threads() use it
      to detect the HT workarounds for older CPUs.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1463703002-19686-6-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      030ba6cd
    • Andi Kleen's avatar
      perf/x86/intel: Add topdown events to Intel Atom · eb12b8ec
      Andi Kleen authored
      Add topdown event declarations to Silvermont / Airmont.
      These cores do not support the full Top Down metrics, but an useful
      subset (FrontendBound, Retiring, Backend Bound/Bad Speculation).
      
      The perf stat tool automatically handles the missing events
      and combines the available metrics.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1463703002-19686-5-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      eb12b8ec
    • Andi Kleen's avatar
      perf/x86/intel: Add topdown events to Intel Core · a39fcae7
      Andi Kleen authored
      Add declarations for the events needed for topdown to the
      Intel big core CPUs starting with Sandy Bridge. We need
      to report different values if HyperThreading is on or off.
      
      The only thing this patch does is to export some events
      in sysfs.
      
      topdown level 1 uses a set of abstracted metrics which
      are generic to out of order CPU cores (although some
      CPUs may not implement all of them):
      
      topdown-total-slots	  Available slots in the pipeline
      topdown-slots-issued	  Slots issued into the pipeline
      topdown-slots-retired	  Slots successfully retired
      topdown-fetch-bubbles	  Pipeline gaps in the frontend
      topdown-recovery-bubbles  Pipeline gaps during recovery
      			  from misspeculation
      
      A slot is a single operation in the CPU pipe line.
      
      These metrics then allow to compute four useful metrics:
      FrontendBound, BackendBound, Retiring, BadSpeculation.
      
      The formulas to compute the metrics are generic, they
      only change based on the availability on the abstracted
      input values.
      
      The kernel declares the events supported by the current
      CPU and their scaling factors (such as the pipeline width)
      and perf stat then computes the formulas based on the
      available metrics.  This is similar how existing
      perf metrics, such as TSC metrics or IPC, are implemented.
      
      This abstracts all CPU pipe line specific knowledge in the
      kernel driver, but still avoids the need for larger scale perf
      interface changes.
      
      For HyperThreading the any bit is needed to get accurate
      values when both threads are executing. This implies that
      the events can only be collected as root or with
      perf_event_paranoid=-1 for now.
      
      The basic scheme is based on the following paper:
        Yasin, A Top Down Method for Performance analysis and Counter architecture ISPASS14 (pdf available via google)
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1463703002-19686-4-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      a39fcae7
    • Andi Kleen's avatar
      perf/x86: Support sysfs files depending on SMT status · fc07e9f9
      Andi Kleen authored
      Add a way to show different sysfs events attributes depending on
      HyperThreading is on or off. This is difficult to determine
      early at boot, so we just do it dynamically when the sysfs
      attribute is read.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1463703002-19686-3-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      fc07e9f9
    • Andi Kleen's avatar
      x86/topology: Add topology_max_smt_threads() · 70b8301f
      Andi Kleen authored
      For SMT specific workarounds it is useful to know if SMT is active
      on any online CPU in the system. This currently requires a loop
      over all online CPUs.
      
      Add a global variable that is updated with the maximum number
      of smt threads on any CPU on online/offline, and use it for
      topology_max_smt_threads()
      
      The single call is easier to use than a loop.
      
      Not exported to user space because user space already can use
      the existing sibling interfaces to find this out.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1463703002-19686-2-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      70b8301f
    • Vineet Gupta's avatar
      tools/perf: Handle -EOPNOTSUPP for sampling events · dc89e75a
      Vineet Gupta authored
      This allows (with a previous change to the perf error return ABI) for
      calling out in userspace the exact reason for perf record failing
      when PMU doesn't support overflow interrupts.
      
      Note that this needs to be put ahead of existing precise_ip check as
      that gets hit otherwise for the sampling fail case as well.
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <acme@redhat.com>
      Cc: <linux-snps-arc@lists.infradead.org>
      Cc: <vincent.weaver@maine.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>
      Link: http://lkml.kernel.org/r/1462786660-2900-2-git-send-email-vgupta@synopsys.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      dc89e75a