diff options
| author | Ingo Molnar <mingo@kernel.org> | 2018-07-12 09:52:35 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-07-12 09:52:35 -0400 |
| commit | 6e1d33b24a2b4aebcb05782e937ebc9a7a4a3f50 (patch) | |
| tree | 8f75c8e622d1e85a4cfb3b7695db41d7a6dca95e /tools/perf/scripts/python | |
| parent | 092150a25cb7bd6a79aa00bb1ad131063f58073d (diff) | |
| parent | 32aa928a7b817140c84987b726d5014911808fa4 (diff) | |
Merge tag 'perf-urgent-for-mingo-4.18-20180711' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
python interface fixes:
- Make 'perf script -g python' generate scripts that are compatible
with both python 2 and 3 (Jeremy Cline)
- Fix python dictionary reference counting (Janne Huttunen)
- Add python3 support for various python scripts (Jeremy Cline)
- Use python-config --includes rather than --cflags, fixing the build
on Fedora, where the python 3.7 started adding -flto to what
perf stat fixes:
- Remove needless extra header line in --interval_clear (Jiri Olsa)
python-config --cflags generate, breaking the perf build (Jeremy Cline)
Build fixes:
- Fix compilation errors on gcc8 (Jiri Olsa)
perf llvm-utils fixes:
- Remove bashism from kernel include fetch script (Kim Phillips)
perf test fixes: (Kim Phillips)
- Replace '|&' with '2>&1 |' to work with more shells
- Make perf's inet_pton test more portable
- Prevent temporary editor files from being considered test scripts
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
5 files changed, 36 insertions, 35 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py index 38dfb720fb6f..54ace2f6bc36 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py +++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py | |||
| @@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value): | |||
| 31 | string = "" | 31 | string = "" |
| 32 | 32 | ||
| 33 | if flag_fields[event_name][field_name]: | 33 | if flag_fields[event_name][field_name]: |
| 34 | print_delim = 0 | 34 | print_delim = 0 |
| 35 | keys = flag_fields[event_name][field_name]['values'].keys() | 35 | for idx in sorted(flag_fields[event_name][field_name]['values']): |
| 36 | keys.sort() | ||
| 37 | for idx in keys: | ||
| 38 | if not value and not idx: | 36 | if not value and not idx: |
| 39 | string += flag_fields[event_name][field_name]['values'][idx] | 37 | string += flag_fields[event_name][field_name]['values'][idx] |
| 40 | break | 38 | break |
| @@ -51,14 +49,12 @@ def symbol_str(event_name, field_name, value): | |||
| 51 | string = "" | 49 | string = "" |
| 52 | 50 | ||
| 53 | if symbolic_fields[event_name][field_name]: | 51 | if symbolic_fields[event_name][field_name]: |
| 54 | keys = symbolic_fields[event_name][field_name]['values'].keys() | 52 | for idx in sorted(symbolic_fields[event_name][field_name]['values']): |
| 55 | keys.sort() | ||
| 56 | for idx in keys: | ||
| 57 | if not value and not idx: | 53 | if not value and not idx: |
| 58 | string = symbolic_fields[event_name][field_name]['values'][idx] | 54 | string = symbolic_fields[event_name][field_name]['values'][idx] |
| 59 | break | 55 | break |
| 60 | if (value == idx): | 56 | if (value == idx): |
| 61 | string = symbolic_fields[event_name][field_name]['values'][idx] | 57 | string = symbolic_fields[event_name][field_name]['values'][idx] |
| 62 | break | 58 | break |
| 63 | 59 | ||
| 64 | return string | 60 | return string |
| @@ -74,19 +70,17 @@ def trace_flag_str(value): | |||
| 74 | string = "" | 70 | string = "" |
| 75 | print_delim = 0 | 71 | print_delim = 0 |
| 76 | 72 | ||
| 77 | keys = trace_flags.keys() | 73 | for idx in trace_flags: |
| 78 | 74 | if not value and not idx: | |
| 79 | for idx in keys: | 75 | string += "NONE" |
| 80 | if not value and not idx: | 76 | break |
| 81 | string += "NONE" | 77 | |
| 82 | break | 78 | if idx and (value & idx) == idx: |
| 83 | 79 | if print_delim: | |
| 84 | if idx and (value & idx) == idx: | 80 | string += " | "; |
| 85 | if print_delim: | 81 | string += trace_flags[idx] |
| 86 | string += " | "; | 82 | print_delim = 1 |
| 87 | string += trace_flags[idx] | 83 | value &= ~idx |
| 88 | print_delim = 1 | ||
| 89 | value &= ~idx | ||
| 90 | 84 | ||
| 91 | return string | 85 | return string |
| 92 | 86 | ||
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py index 81a56cd2b3c1..21a7a1298094 100755 --- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py +++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | # PerfEvent is the base class for all perf event sample, PebsEvent | 8 | # PerfEvent is the base class for all perf event sample, PebsEvent |
| 9 | # is a HW base Intel x86 PEBS event, and user could add more SW/HW | 9 | # is a HW base Intel x86 PEBS event, and user could add more SW/HW |
| 10 | # event classes based on requirements. | 10 | # event classes based on requirements. |
| 11 | from __future__ import print_function | ||
| 11 | 12 | ||
| 12 | import struct | 13 | import struct |
| 13 | 14 | ||
| @@ -44,7 +45,8 @@ class PerfEvent(object): | |||
| 44 | PerfEvent.event_num += 1 | 45 | PerfEvent.event_num += 1 |
| 45 | 46 | ||
| 46 | def show(self): | 47 | def show(self): |
| 47 | print "PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % (self.name, self.symbol, self.comm, self.dso) | 48 | print("PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % |
| 49 | (self.name, self.symbol, self.comm, self.dso)) | ||
| 48 | 50 | ||
| 49 | # | 51 | # |
| 50 | # Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer | 52 | # Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer |
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py index fdd92f699055..cac7b2542ee8 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py +++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | try: | 11 | try: |
| 12 | import wx | 12 | import wx |
| 13 | except ImportError: | 13 | except ImportError: |
| 14 | raise ImportError, "You need to install the wxpython lib for this script" | 14 | raise ImportError("You need to install the wxpython lib for this script") |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | class RootFrame(wx.Frame): | 17 | class RootFrame(wx.Frame): |
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py index f6c84966e4f8..7384dcb628c4 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py +++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | # This software may be distributed under the terms of the GNU General | 5 | # This software may be distributed under the terms of the GNU General |
| 6 | # Public License ("GPL") version 2 as published by the Free Software | 6 | # Public License ("GPL") version 2 as published by the Free Software |
| 7 | # Foundation. | 7 | # Foundation. |
| 8 | from __future__ import print_function | ||
| 8 | 9 | ||
| 9 | import errno, os | 10 | import errno, os |
| 10 | 11 | ||
| @@ -33,7 +34,7 @@ def nsecs_str(nsecs): | |||
| 33 | return str | 34 | return str |
| 34 | 35 | ||
| 35 | def add_stats(dict, key, value): | 36 | def add_stats(dict, key, value): |
| 36 | if not dict.has_key(key): | 37 | if key not in dict: |
| 37 | dict[key] = (value, value, value, 1) | 38 | dict[key] = (value, value, value, 1) |
| 38 | else: | 39 | else: |
| 39 | min, max, avg, count = dict[key] | 40 | min, max, avg, count = dict[key] |
| @@ -72,10 +73,10 @@ try: | |||
| 72 | except: | 73 | except: |
| 73 | if not audit_package_warned: | 74 | if not audit_package_warned: |
| 74 | audit_package_warned = True | 75 | audit_package_warned = True |
| 75 | print "Install the audit-libs-python package to get syscall names.\n" \ | 76 | print("Install the audit-libs-python package to get syscall names.\n" |
| 76 | "For example:\n # apt-get install python-audit (Ubuntu)" \ | 77 | "For example:\n # apt-get install python-audit (Ubuntu)" |
| 77 | "\n # yum install audit-libs-python (Fedora)" \ | 78 | "\n # yum install audit-libs-python (Fedora)" |
| 78 | "\n etc.\n" | 79 | "\n etc.\n") |
| 79 | 80 | ||
| 80 | def syscall_name(id): | 81 | def syscall_name(id): |
| 81 | try: | 82 | try: |
diff --git a/tools/perf/scripts/python/sched-migration.py b/tools/perf/scripts/python/sched-migration.py index de66cb3b72c9..3473e7f66081 100644 --- a/tools/perf/scripts/python/sched-migration.py +++ b/tools/perf/scripts/python/sched-migration.py | |||
| @@ -9,13 +9,17 @@ | |||
| 9 | # This software is distributed under the terms of the GNU General | 9 | # This software is distributed under the terms of the GNU General |
| 10 | # Public License ("GPL") version 2 as published by the Free Software | 10 | # Public License ("GPL") version 2 as published by the Free Software |
| 11 | # Foundation. | 11 | # Foundation. |
| 12 | 12 | from __future__ import print_function | |
| 13 | 13 | ||
| 14 | import os | 14 | import os |
| 15 | import sys | 15 | import sys |
| 16 | 16 | ||
| 17 | from collections import defaultdict | 17 | from collections import defaultdict |
| 18 | from UserList import UserList | 18 | try: |
| 19 | from UserList import UserList | ||
| 20 | except ImportError: | ||
| 21 | # Python 3: UserList moved to the collections package | ||
| 22 | from collections import UserList | ||
| 19 | 23 | ||
| 20 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 24 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ |
| 21 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | 25 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') |
| @@ -300,7 +304,7 @@ class TimeSliceList(UserList): | |||
| 300 | if i == -1: | 304 | if i == -1: |
| 301 | return | 305 | return |
| 302 | 306 | ||
| 303 | for i in xrange(i, len(self.data)): | 307 | for i in range(i, len(self.data)): |
| 304 | timeslice = self.data[i] | 308 | timeslice = self.data[i] |
| 305 | if timeslice.start > end: | 309 | if timeslice.start > end: |
| 306 | return | 310 | return |
| @@ -336,8 +340,8 @@ class SchedEventProxy: | |||
| 336 | on_cpu_task = self.current_tsk[headers.cpu] | 340 | on_cpu_task = self.current_tsk[headers.cpu] |
| 337 | 341 | ||
| 338 | if on_cpu_task != -1 and on_cpu_task != prev_pid: | 342 | if on_cpu_task != -1 and on_cpu_task != prev_pid: |
| 339 | print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ | 343 | print("Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ |
| 340 | (headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) | 344 | headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) |
| 341 | 345 | ||
| 342 | threads[prev_pid] = prev_comm | 346 | threads[prev_pid] = prev_comm |
| 343 | threads[next_pid] = next_comm | 347 | threads[next_pid] = next_comm |
