1. 10 7月, 2020 1 次提交
  2. 09 7月, 2020 2 次提交
    • N
      perf annotate: Fix non-null terminated buffer returned by readlink() · b39730a6
      Numfor Mbiziwo-Tiapo 提交于
      Our local MSAN (Memory Sanitizer) build of perf throws a warning that
      comes from the "dso__disassemble_filename" function in
      "tools/perf/util/annotate.c" when running perf record.
      
      The warning stems from the call to readlink, in which "build_id_path"
      was being read into "linkname". Since readlink does not null terminate,
      an uninitialized memory access would later occur when "linkname" is
      passed into the strstr function. This is simply fixed by
      null-terminating "linkname" after the call to readlink.
      
      To reproduce this warning, build perf by running:
      
        $ make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins"
      
      (Additionally, llvm might have to be installed and clang might have to
      be specified as the compiler - export CC=/usr/bin/clang)
      
      Then running:
      
        tools/perf/perf record -o - ls / | tools/perf/perf --no-pager annotate -i - --stdio
      
      Please see the cover letter for why false positive warnings may be
      generated.
      Signed-off-by: NNumfor Mbiziwo-Tiapo <nums@google.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Drayton <mbd@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20190729205750.193289-1-nums@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b39730a6
    • S
      perf inject jit: Remove //anon mmap events · c8f6ae1f
      Steve MacLean 提交于
      **perf-<pid>.map and jit-<pid>.dump designs:
      
      When a JIT generates code to be executed, it must allocate memory and
      mark it executable using an mmap call.
      
      *** perf-<pid>.map design
      
      The perf-<pid>.map assumes that any sample recorded in an anonymous
      memory page is JIT code. It then tries to resolve the symbol name by
      looking at the process' perf-<pid>.map.
      
      *** jit-<pid>.dump design
      
      The jit-<pid>.dump mechanism takes a different approach. It requires a
      JIT to write a `<path>/jit-<pid>.dump` file. This file must also be
      mmapped so that perf inject -jit can find the file. The JIT must also
      add JIT_CODE_LOAD records for any functions it generates. The records
      are timestamped using a clock which can be correlated to the perf record
      clock.
      
      After perf record,  the `perf inject -jit` pass parses the recording
      looking for a `<path>/jit-<pid>.dump` file. When it finds the file, it
      parses it and for each JIT_CODE_LOAD record:
      * creates an elf file `<path>/jitted-<pid>-<code_index>.so
      * injects a new mmap record mapping the new elf file into the process.
      
      *** Coexistence design
      
      The kernel and perf support both of these mechanisms. We need to make
      sure perf works on an app supporting either or both of these mechanisms.
      Both designs rely on mmap records to determine how to resolve an ip
      address.
      
      The mmap records of both techniques by definition overlap. When the JIT
      compiles a method, it must:
      
      * allocate memory (mmap)
      * add execution privilege (mprotect or mmap. either will
      generate an mmap event form the kernel to perf)
      * compile code into memory
      * add a function record to perf-<pid>.map and/or jit-<pid>.dump
      
      Because the jit-<pid>.dump mechanism supports greater capabilities, perf
      prefers the symbols from jit-<pid>.dump. It implements this based on
      timestamp ordering of events. There is an implicit ASSUMPTION that the
      JIT_CODE_LOAD record timestamp will be after the // anon mmap event that
      was generated during memory allocation or adding the execution privilege setting.
      
      *** Problems with the ASSUMPTION
      
      The ASSUMPTION made in the Coexistence design section above is violated
      in the following scenario.
      
      *** Scenario
      
      While a JIT is jitting code it will eventually need to commit more
      pages and change these pages to executable permissions. Typically the
      JIT will want these collocated to minimize branch displacements.
      
      The kernel will coalesce these anonymous mapping with identical
      permissions before sending an MMAP event for the new pages. The address
      range of the new mmap will not be just the most recently mmap pages.
      It will include the entire coalesced mmap region.
      
      See mm/mmap.c
      
      unsigned long mmap_region(struct file *file, unsigned long addr,
                      unsigned long len, vm_flags_t vm_flags, unsigned long pgoff,
                      struct list_head *uf)
      {
      ...
              /*
               * Can we just expand an old mapping?
               */
      ...
              perf_event_mmap(vma);
      ...
      }
      
      *** Symptoms
      
      The coalesced // anon mmap event will be timestamped after the
      JIT_CODE_LOAD records. This means it will be used as the most recent
      mapping for that entire address range. For remaining events it will look
      at the inferior perf-<pid>.map for symbols.
      
      If both mechanisms are supported, the symbol will appear twice with
      different module names. This causes weird behavior in reporting.
      
      If only jit-<pid>.dump is supported, the symbol will no longer be resolved.
      
      ** Implemented solution
      
      This patch solves the issue by removing // anon mmap events for any
      process which has a valid jit-<pid>.dump file.
      
      It tracks on a per process basis to handle the case where some running
      apps support jit-<pid>.dump, but some only support perf-<pid>.map.
      
      It adds new assumptions:
      * // anon mmap events are only required for perf-<pid>.map support.
      * An app that uses jit-<pid>.dump, no longer needs
      perf-<pid>.map support. It assumes that any perf-<pid>.map info is
      inferior.
      
      *** Details
      
      Use thread->priv to store whether a jitdump file has been processed
      
      During "perf inject --jit", discard "//anon*" mmap events for any pid which
      has sucessfully processed a jitdump file.
      
      ** Testing:
      
      // jitdump case
      
        perf record <app with jitdump>
        perf inject --jit --input perf.data --output perfjit.data
      
      // verify mmap "//anon" events present initially
      
        perf script --input perf.data --show-mmap-events | grep '//anon'
      
      // verify mmap "//anon" events removed
      
        perf script --input perfjit.data --show-mmap-events | grep '//anon'
      
      // no jitdump case
      
        perf record <app without jitdump>
        perf inject --jit --input perf.data --output perfjit.data
      
      // verify mmap "//anon" events present initially
      
        perf script --input perf.data --show-mmap-events | grep '//anon'
      
      // verify mmap "//anon" events not removed
      
        perf script --input perfjit.data --show-mmap-events | grep '//anon'
      
      ** Repro:
      
      This issue was discovered while testing the initial CoreCLR jitdump
      implementation. https://github.com/dotnet/coreclr/pull/26897.
      
      ** Alternate solutions considered
      
      These were also briefly considered:
      
      * Change kernel to not coalesce mmap regions.
      
      * Change kernel reporting of coalesced mmap regions to perf. Only
      include newly mapped memory.
      
      * Only strip parts of // anon mmap events overlapping existing
      jitted-<pid>-<code_index>.so mmap events.
      Signed-off-by: NSteve MacLean <Steve.MacLean@Microsoft.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/1590544271-125795-1-git-send-email-steve.maclean@linux.microsoft.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c8f6ae1f
  3. 08 7月, 2020 1 次提交
  4. 06 7月, 2020 19 次提交
  5. 05 7月, 2020 1 次提交
  6. 03 7月, 2020 9 次提交
    • T
      tools lib traceevent: Add proper KBUFFER_TYPE_TIME_STAMP handling · 2160d6c8
      Tom Zanussi 提交于
      Kernel commit dc4e2801 (ring-buffer: Redefine the unimplemented
      RINGBUF_TYPE_TIME_STAMP) changed the way the ring buffer timestamps work
      - after that commit the previously unimplemented RINGBUF_TYPE_TIME_STAMP
      type causes the time delta to be used as a timestamp rather than a delta
      to be added to the timestamp.
      
      The trace-cmd code didn't get updated to handle this, so misinterprets
      the event data for this case, which causes a cascade of errors,
      including trace-report not being able to identify synthetic (or any
      other) events generated by the histogram code (which uses TIME_STAMP
      mode).  For example, the following triggers along with the trace-cmd
      shown cause an UNKNOWN_EVENT error and trace-cmd report crash:
      
        # echo 'wakeup_latency  u64 lat pid_t pid char comm[16]' > /sys/kernel/debug/tracing/synthetic_events
      
        # echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
        # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).trace(wakeup_latency,$wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
        # echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
      
        # trace-cmd record -e wakeup_latency -e sched_wakeup -f comm==\"ping\" ping localhost -c 5
      
        # trace-cmd report
        CPU 0 is empty
        CPU 1 is empty
        CPU 2 is empty
        CPU 3 is empty
        CPU 5 is empty
        CPU 6 is empty
        CPU 7 is empty
        cpus=8
          ug! no event found for type 0
        [UNKNOWN TYPE 0]
          ug! no event found for type 11520
        Segmentation fault (core dumped)
      
      After this patch we get the correct interpretation and the events are
      shown properly:
      
        # trace-cmd report
        CPU 0 is empty
        CPU 1 is empty
        CPU 2 is empty
        CPU 3 is empty
        CPU 5 is empty
        CPU 6 is empty
        CPU 7 is empty
        cpus=8
                <idle>-0     [004] 23284.341392: sched_wakeup:         ping:12031 [120] success=1 CPU:004
                <idle>-0     [004] 23284.341464: wakeup_latency:       lat=58, pid=12031, comm=ping
                <idle>-0     [004] 23285.365303: sched_wakeup:         ping:12031 [120] success=1 CPU:004
                <idle>-0     [004] 23285.365382: wakeup_latency:       lat=64, pid=12031, comm=ping
                <idle>-0     [004] 23286.389290: sched_wakeup:         ping:12031 [120] success=1 CPU:004
                <idle>-0     [004] 23286.389378: wakeup_latency:       lat=72, pid=12031, comm=ping
                <idle>-0     [004] 23287.413213: sched_wakeup:         ping:12031 [120] success=1 CPU:004
                <idle>-0     [004] 23287.413291: wakeup_latency:       lat=64, pid=12031, comm=ping
      
      Link: http://lkml.kernel.org/r/1567628224.13841.4.camel@kernel.org
      Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-3-tz.stoyanov@gmail.comSigned-off-by: NTom Zanussi <zanussi@kernel.org>
      [ Ported from trace-cmd.git ]
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linux-trace-devel@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200702185703.785094515@goodmis.orgSigned-off-by: NTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2160d6c8
    • S
      tools lib traceevent: Add API to read time information from kbuffer · 374855c5
      Steven Rostedt (Red Hat) 提交于
      Add the functions kbuffer_subbuf_timestamp() and kbuffer_ptr_delta() to
      get the timing data stored in the ring buffer that is used to produced
      the time stamps of the records.
      
      This is useful for tools like trace-cmd to be able to display the
      content of the read data to understand why the records show the time
      stamps that they do.
      
      Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-2-tz.stoyanov@gmail.comSigned-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      [ Ported from trace-cmd.git ]
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linux-trace-devel@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200702185703.619656282@goodmis.orgSigned-off-by: NTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      374855c5
    • A
      perf scripts python: exported-sql-viewer.py: Fix time chart call tree · f18d5cf8
      Adrian Hunter 提交于
      Using Python version 3.8.2 and PySide2 version 5.14.0, time chart call tree
      would not expand the tree to the result. Fix by using setExpanded().
      
      Example:
      
        $ perf record -e intel_pt//u uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.034 MB perf.data ]
        $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
        2020-06-26 15:32:14.928997 Creating database ...
        2020-06-26 15:32:14.933971 Writing records...
        2020-06-26 15:32:15.535251 Adding indexes
        2020-06-26 15:32:15.542993 Dropping unused tables
        2020-06-26 15:32:15.549716 Done
        $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db
      
        Select: Charts -> Time chart by CPU
        Move mouse over middle of chart
        Right-click and select Show Call Tree
      
      Before: displays Call Tree but not expanded to selected time
      After: displays Call Tree expanded to selected time
      
      Fixes: e69d5df7 ("perf scripts python: exported-sql-viewer.py: Add ability for Call tree to open at a specified task and time")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200629091955.17090-7-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f18d5cf8
    • A
      perf scripts python: exported-sql-viewer.py: Fix zero id in call tree 'Find' result · 031c8d5e
      Adrian Hunter 提交于
      Using ctrl-F ('Find') would not find 'unknown' because it matches id
      zero.  Fix by excluding id zero from selection.
      
      Example:
      
         $ perf record -e intel_pt//u uname
         Linux
         [ perf record: Woken up 1 times to write data ]
         [ perf record: Captured and wrote 0.034 MB perf.data ]
         $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
         2020-06-26 15:32:14.928997 Creating database ...
         2020-06-26 15:32:14.933971 Writing records...
         2020-06-26 15:32:15.535251 Adding indexes
         2020-06-26 15:32:15.542993 Dropping unused tables
         2020-06-26 15:32:15.549716 Done
         $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db
      
         Select: Reports -> Call Tree
         Press: Ctrl-F
         Enter: unknown
         Press: Enter
      
      Before: displays 'unknown' not found
      After: tree is expanded to line showing 'unknown'
      
      Fixes: ae8b887c ("perf scripts python: exported-sql-viewer.py: Add call tree")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200629091955.17090-6-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      031c8d5e
    • A
      perf scripts python: exported-sql-viewer.py: Fix zero id in call graph 'Find' result · 7ff520b0
      Adrian Hunter 提交于
      Using ctrl-F ('Find') would not find 'unknown' because it matches id zero.
      Fix by excluding id zero from selection.
      
      Example:
      
        $ perf record -e intel_pt//u uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.034 MB perf.data ]
        $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
        2020-06-26 15:32:14.928997 Creating database ...
        2020-06-26 15:32:14.933971 Writing records...
        2020-06-26 15:32:15.535251 Adding indexes
        2020-06-26 15:32:15.542993 Dropping unused tables
        2020-06-26 15:32:15.549716 Done
        $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db
      
        Select: Reports -> Context-Sensitive Call Graph
        Press: Ctrl-F
        Enter: unknown
        Press: Enter
      
      Before: gets stuck
      After: tree is expanded to line showing 'unknown'
      
      Fixes: 254c0d82 ("perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200629091955.17090-5-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7ff520b0
    • A
      perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result · 3a3cf7c5
      Adrian Hunter 提交于
      Using Python version 3.8.2 and PySide2 version 5.14.0, ctrl-F ('Find')
      would not expand the tree to the result. Fix by using setExpanded().
      
      Example:
      
        $ perf record -e intel_pt//u uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.034 MB perf.data ]
        $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
        2020-06-26 15:32:14.928997 Creating database ...
        2020-06-26 15:32:14.933971 Writing records...
        2020-06-26 15:32:15.535251 Adding indexes
        2020-06-26 15:32:15.542993 Dropping unused tables
        2020-06-26 15:32:15.549716 Done
        $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db
      
        Select: Reports -> Context-Sensitive Call Graph    or     Reports -> Call Tree
        Press: Ctrl-F
        Enter: main
        Press: Enter
      
      Before: line showing 'main' does not display
      
      After: tree is expanded to line showing 'main'
      
      Fixes: ebd70c7d ("perf scripts python: exported-sql-viewer.py: Add ability to find symbols in the call-graph")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200629091955.17090-4-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3a3cf7c5
    • A
      perf record: Fix duplicated sideband events with Intel PT system wide tracing · 442ad225
      Adrian Hunter 提交于
      Commit 0a892c1c ("perf record: Add dummy event during system wide
      synthesis") reveals an issue with Intel PT system wide tracing.
      Specifically that Intel PT already adds a dummy tracking event, and it
      is not the first event.  Adding another dummy tracking event causes
      duplicated sideband events.  Fix by checking for an existing dummy
      tracking event first.
      
      Example showing duplicated switch events:
      
       Before:
      
         # perf record -a -e intel_pt//u uname
         Linux
         [ perf record: Woken up 1 times to write data ]
         [ perf record: Captured and wrote 0.895 MB perf.data ]
         # perf script --no-itrace --show-switch-events | head
                  swapper     0 [007]  6390.516222: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
                  swapper     0 [007]  6390.516222: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
                rcu_sched    11 [007]  6390.516223: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                rcu_sched    11 [007]  6390.516224: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                rcu_sched    11 [007]  6390.516227: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                rcu_sched    11 [007]  6390.516227: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                  swapper     0 [007]  6390.516228: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
                  swapper     0 [007]  6390.516228: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
                  swapper     0 [002]  6390.516415: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  5556/5559
                  swapper     0 [002]  6390.516416: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  5556/5559
      
       After:
      
         # perf record -a -e intel_pt//u uname
         Linux
         [ perf record: Woken up 1 times to write data ]
         [ perf record: Captured and wrote 0.868 MB perf.data ]
         #  perf script --no-itrace --show-switch-events | head
                  swapper     0 [005]  6450.567013: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  7179/7181
                     perf  7181 [005]  6450.567014: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                     perf  7181 [005]  6450.567028: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                  swapper     0 [005]  6450.567029: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:  7179/7181
                  swapper     0 [005]  6450.571699: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
                rcu_sched    11 [005]  6450.571700: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                rcu_sched    11 [005]  6450.571702: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                  swapper     0 [005]  6450.571703: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
                  swapper     0 [005]  6450.579703: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
                rcu_sched    11 [005]  6450.579704: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20200629091955.17090-3-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      442ad225
    • A
      perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument · 640432e6
      Adrian Hunter 提交于
      Python 3.8 is requiring that arguments being packed as integers are also
      integers.  Add int() accordingly.
      
       Before:
      
         $ perf record -e intel_pt//u uname
         $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
         2020-06-25 16:09:10.547256 Creating database...
         2020-06-25 16:09:10.733185 Writing to intermediate files...
         Traceback (most recent call last):
           File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1106, in synth_data
             cbr(id, raw_buf)
           File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1058, in cbr
             value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, MHz, 4, percent)
         struct.error: required argument is not an integer
         Fatal Python error: problem in Python trace event handler
         Python runtime state: initialized
      
         Current thread 0x00007f35d3695780 (most recent call first):
         <no Python frame>
         Aborted (core dumped)
      
       After:
      
         $ dropdb perf_data_db
         $ rm -rf perf_data_db-perf-data
         $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
         2020-06-25 16:09:40.990267 Creating database...
         2020-06-25 16:09:41.207009 Writing to intermediate files...
         2020-06-25 16:09:41.270915 Copying to database...
         2020-06-25 16:09:41.382030 Removing intermediate files...
         2020-06-25 16:09:41.384630 Adding primary keys
         2020-06-25 16:09:41.541894 Adding foreign keys
         2020-06-25 16:09:41.677044 Dropping unused tables
         2020-06-25 16:09:41.703761 Done
      
      Fixes: aba44287 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200629091955.17090-2-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      640432e6
    • A
      tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy' · eb25de27
      Arnaldo Carvalho de Melo 提交于
      To bring in the change made in this cset:
      
        e3a9e681 ("x86/entry: Fixup bad_iret vs noinstr")
      
      This doesn't cause any functional changes to tooling, just a rebuild.
      
      Addresses this perf 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'
        diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      eb25de27
  7. 02 7月, 2020 2 次提交
    • I
      perf parse-events: Disable a subset of bison warnings · 1f16fcad
      Ian Rogers 提交于
      Rather than disable all warnings with -w, disable specific warnings.
      
      Predicate enabling the warnings on a recent version of bison.
      
      Tested with GCC 9.3.0 and clang 9.0.1.
      
      Committer testing:
      
      The full set of compilers, gcc and clang that this will be tested on
      will be on the signed tag when this change goes upstream.
      
      Had to add -Wno-switch-enum to build on opensuse tumbleweed:
      
        /tmp/build/perf/util/parse-events-bison.c: In function 'yydestruct':
        /tmp/build/perf/util/parse-events-bison.c:1200:3: error: enumeration value 'YYSYMBOL_YYEMPTY' not handled in switch [-Werror=switch-enum]
         1200 |   switch (yykind)
              |   ^~~~~~
        /tmp/build/perf/util/parse-events-bison.c:1200:3: error: enumeration value 'YYSYMBOL_YYEOF' not handled in switch [-Werror=switch-enum]
      
      Also replace -Wno-error=implicit-function-declaration with -Wno-implicit-function-declaration.
      
      Also needed to check just the first two levels of the bison version, as
      the patch was assuming that all versions were of the form x.y.z, and
      there are several cases where it is just x.y, breaking the build.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200619043356.90024-11-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f16fcad
    • I
      perf parse-events: Disable a subset of flex warnings · 304d7a90
      Ian Rogers 提交于
      Rather than disable all warnings with -w, disable specific warnings.
      
      Predicate enabling the warnings on more recent flex versions.
      
      Tested with GCC 9.3.0 and clang 9.0.1.
      
      Committer notes:
      
      The full set of compilers, gcc and clang that this will be tested on
      will be on the signed tag when this change goes upstream.
      
      Added -Wno-misleading-indentation to the flex_flags to overcome this on
      opensuse tumbleweed when building with clang:
      
          CC       /tmp/build/perf/util/parse-events-flex.o
          CC       /tmp/build/perf/util/pmu.o
        /tmp/build/perf/util/parse-events-flex.c:5038:13: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                    if ( ! yyg->yy_state_buf )
                    ^
        /tmp/build/perf/util/parse-events-flex.c:5036:9: note: previous statement is here
                if ( ! yyg->yy_state_buf )
                ^
      
      And we need to use this to redirect stderr to stdin and then grep in a
      way that is acceptable for BusyBox shell:
      
        2>&1 |
      
      Previously I was using:
      
        |&
      
      Which seems to be bash specific.
      
      Added -Wno-sign-compare to overcome this on systems such as centos:7:
      
          CC       /tmp/build/perf/util/parse-events-flex.o
          CC       /tmp/build/perf/util/pmu.o
          CC       /tmp/build/perf/util/pmu-flex.o
        util/parse-events.l: In function 'parse_events_lex':
        /tmp/build/perf/util/parse-events-flex.c:193:36: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
                         for ( yyl = n; yyl < yyleng; ++yyl )\
                                            ^
        /tmp/build/perf/util/parse-events-flex.c:204:9: note: in expansion of macro 'YY_LESS_LINENO'
      
      Added -Wno-unused-parameter to overcome this in systems such as
      centos:7:
      
          CC       /tmp/build/perf/util/parse-events-flex.o
          CC       /tmp/build/perf/util/pmu.o
        /tmp/build/perf/util/parse-events-flex.c: In function 'yy_fatal_error':
        /tmp/build/perf/util/parse-events-flex.c:6265:58: error: unused parameter 'yyscanner' [-Werror=unused-parameter]
         static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
                                                                  ^
      Added -Wno-missing-declarations to build in systems such as centos:6:
      
        /tmp/build/perf/util/parse-events-flex.c:6313: error: no previous prototype for 'parse_events_get_column'
        /tmp/build/perf/util/parse-events-flex.c:6389: error: no previous prototype for 'parse_events_set_column'
      
      And -Wno-missing-prototypes to cover older compilers:
      
        -Wmissing-prototypes (C only)
        Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. The aim is to detect global functions that fail to be declared in header files.
        -Wmissing-declarations (C only)
        Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files.
      
      Older C compilers lack -Wno-misleading-indentation, check if it is
      available before using it.
      
      Also needed to check just the first two levels of the flex version, as
      the patch was assuming that all versions were of the form x.y.z, and
      there are several cases where it is just x.y, breaking the build.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@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: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200619043356.90024-8-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      304d7a90
  8. 01 7月, 2020 3 次提交
  9. 30 6月, 2020 2 次提交