1. 23 6月, 2016 1 次提交
  2. 19 4月, 2016 1 次提交
    • C
      perf jit: memset() variable 'st' using the correct size · f56ebf20
      Colin Ian King 提交于
      The current code is memsetting the 'struct stat' variable 'st' with the size of
      'stat' (which turns out to be 1 byte) rather than the size of variable 'sz'.
      
      Committer notes:
      
      sizeof(function) isn't valid, the result depends on the compiler used, with
      gcc, enabling pedantic warnings we get:
      
        $ cat sizeof_function.c
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <unistd.h>
        #include <stdio.h>
      
        int main(void)
        {
      	  printf("sizeof(stat)=%zd, stat=%p\n", sizeof(stat), stat);
      	  return 0;
        }
        $ readelf -sW sizeof_function | grep -w stat
            49: 0000000000400630    16 FUNC    WEAK   HIDDEN    13 stat
        $ cc -pedantic sizeof_function.c   -o sizeof_function
        sizeof_function.c: In function ‘main’:
        sizeof_function.c:8:46: warning: invalid application of ‘sizeof’ to a function type [-Wpointer-arith]
          printf("sizeof(stat)=%zd, stat=%p\n", sizeof(stat), stat);
                                                    ^
        $ ./sizeof_function
        sizeof(stat)=1, stat=0x400630
        $
      
        Standard C, section 6.5.3.4:
      
        "The sizeof operator shall not be applied to an expression that has function
         type or an incomplete type, to the parenthesized name of such a type,
         or to an expression that designates a bit-field member."
      
        http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdfSigned-off-by: NColin Ian King <colin.king@canonical.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Fixes: 9b07e27f ("perf inject: Add jitdump mmap injection support")
      Link: http://lkml.kernel.org/r/1461020838-9260-1-git-send-email-colin.king@canonical.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f56ebf20
  3. 02 4月, 2016 1 次提交
  4. 30 3月, 2016 1 次提交
    • A
      perf tools: Add missing initialization of perf_sample.cpumode in synthesized samples · 3ea223ad
      Arnaldo Carvalho de Melo 提交于
      In 473398a2 ("perf tools: Add cpumode to struct perf_sample"), I
      missed some places where perf_sample fields are directly initialized in
      addition to what is done in perf_evsel__parse_sample(), namely when
      synthesizing PERF_RECORD_{MMAP*,COMM,FORK,EXIT} for pre-existing threads
      and also in intel_pt and intel_bts when synthesizing events from
      processor trace, the jitdump code also was affected, fix it.
      
      The problem was noticed with running:
      
        # perf record -e intel_pt//u true
        # perf script
      
      Where the samples wouldn't get resolved because perf_sample.cpumode
      would be left as zero, i.e. PERF_RECORD_MISC_CPUMODE_UNKNOWN, not
      resolving as kernel, hypervisor or user cpu modes.
      
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 473398a2 ("perf tools: Add cpumode to struct perf_sample")
      Link: http://lkml.kernel.org/n/tip-n5sdauxgk24d5nun8kuuu2mh@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3ea223ad
  5. 08 3月, 2016 2 次提交
  6. 05 2月, 2016 2 次提交
    • S
      perf jit: add source line info support · 598b7c69
      Stephane Eranian 提交于
      This patch adds source line information support to perf for jitted code.
      
      The source line info must be emitted by the runtime, such as JVMTI.
      
      Perf injects extract the source line info from the jitdump file and adds
      the corresponding .debug_lines section in the ELF image generated for
      each jitted function.
      
      The source line enables matching any address in the profile with a
      source file and line number.
      
      The improvement is visible in perf annotate with the source code
      displayed alongside the assembly code.
      
      The dwarf code leverages the support from OProfile which is also
      released under GPLv2.  Copyright 2007 OProfile authors.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Carl Love <cel@us.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John McCutchan <johnmccutchan@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pawel Moll <pawel.moll@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sonny Rao <sonnyrao@chromium.org>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1448874143-7269-5-git-send-email-eranian@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      598b7c69
    • S
      perf inject: Add jitdump mmap injection support · 9b07e27f
      Stephane Eranian 提交于
      This patch adds a --jit/-j option to perf inject.
      
      This options injects MMAP records into the perf.data file to cover the
      jitted code mmaps. It also emits ELF images for each function in the
      jidump file.  Those images are created where the jitdump file is.  The
      MMAP records point to that location as well.
      
      Typical flow:
      
        $ perf record -k mono -- java -agentpath:libpjvmti.so java_class
        $ perf inject --jit -i perf.data -o perf.data.jitted
        $ perf report -i perf.data.jitted
      
      Note that jitdump.h support is not limited to Java, it works with any
      jitted environment modified to emit the jitdump file format, include
      those where code can be jitted multiple times and moved around.
      
      The jitdump.h format is adapted from the Oprofile project.
      
      The genelf.c (ELF binary generation) depends on MD5 hash encoding for
      the buildid. To enable this, libssl-dev must be installed. If not, then
      genelf.c defaults to using urandom to generate the buildid, which is not
      ideal.  The Makefile auto-detects the presence on libssl-dev.
      
      This version mmaps the jitdump file to create a marker MMAP record in
      the perf.data file. The marker is used to detect jitdump and cause perf
      inject to inject the jitted mmaps and generate ELF images for jitted
      functions.
      
      In V8, the following fixes and changes were made among other things:
      
        -  the jidump header format include a new flags field to be used
           to carry information about the configuration of the runtime agent.
           Contributed by: Adrian Hunter <adrian.hunter@intel.com>
      
        - Fix mmap pgoff: MMAP event pgoff must be the offset within the ELF file
          at which the code resides.
          Contributed by: Adrian Hunter <adrian.hunter@intel.com>
      
        - Fix ELF virtual addresses: perf tools expect the ELF virtual addresses of dynamic
          objects to match the file offset.
          Contributed by: Adrian Hunter <adrian.hunter@intel.com>
      
        - JIT MMAP injection does not obey finished_round semantics. JIT MMAP injection injects all
          MMAP events in one go, so it does not obey finished_round semantics, so drop the
          finished_round events from the output perf.data file.
          Contributed by: Adrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Carl Love <cel@us.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John McCutchan <johnmccutchan@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pawel Moll <pawel.moll@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sonny Rao <sonnyrao@chromium.org>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1448874143-7269-3-git-send-email-eranian@google.com
      [ Moved inject.build_ids ordering bits to a separate patch, fixed the NO_LIBELF=1 build ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b07e27f