summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-13 16:33:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-13 16:33:09 -0400
commitaa0a3247c01535303fc39c2bf0beb4493688a314 (patch)
tree992c35dad9ed29994b67f9455f0eca605c963356 /tools/perf
parent75adbd1386796c1234035996c6aec3ede4060eb2 (diff)
parent6e1d33b24a2b4aebcb05782e937ebc9a7a4a3f50 (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf tool fixes from Ingo Molnar: "Misc tooling fixes: python3 related fixes, gcc8 fix, bashism fixes and some other smaller fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf tools: Use python-config --includes rather than --cflags perf script python: Fix dict reference counting perf stat: Fix --interval_clear option perf tools: Fix compilation errors on gcc8 perf test shell: Prevent temporary editor files from being considered test scripts perf llvm-utils: Remove bashism from kernel include fetch script perf test shell: Make perf's inet_pton test more portable perf test shell: Replace '|&' with '2>&1 |' to work with more shells perf scripts python: Add Python 3 support to EventClass.py perf scripts python: Add Python 3 support to sched-migration.py perf scripts python: Add Python 3 support to Util.py perf scripts python: Add Python 3 support to SchedGui.py perf scripts python: Add Python 3 support to Core.py perf tools: Generate a Python script compatible with Python 2 and 3
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Makefile.config3
-rw-r--r--tools/perf/arch/x86/util/perf_regs.c2
-rw-r--r--tools/perf/builtin-stat.c2
-rw-r--r--tools/perf/jvmti/jvmti_agent.c3
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py40
-rwxr-xr-xtools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py4
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py2
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py11
-rw-r--r--tools/perf/scripts/python/sched-migration.py14
-rw-r--r--tools/perf/tests/builtin-test.c2
-rwxr-xr-xtools/perf/tests/shell/record+probe_libc_inet_pton.sh37
-rwxr-xr-xtools/perf/tests/shell/trace+probe_vfs_getname.sh2
-rw-r--r--tools/perf/util/llvm-utils.c6
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c37
14 files changed, 84 insertions, 81 deletions
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index b5ac356ba323..f5a3b402589e 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -207,8 +207,7 @@ ifdef PYTHON_CONFIG
207 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) 207 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
208 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 208 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
209 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 209 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
210 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 210 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
211 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
212 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 211 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
213endif 212endif
214 213
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index 4b2caf6d48e7..fead6b3b4206 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
226 else if (rm[2].rm_so != rm[2].rm_eo) 226 else if (rm[2].rm_so != rm[2].rm_eo)
227 prefix[0] = '+'; 227 prefix[0] = '+';
228 else 228 else
229 strncpy(prefix, "+0", 2); 229 scnprintf(prefix, sizeof(prefix), "+0");
230 } 230 }
231 231
232 /* Rename register */ 232 /* Rename register */
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 22547a490e1f..05be023c3f0e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1742,7 +1742,7 @@ static void print_interval(char *prefix, struct timespec *ts)
1742 } 1742 }
1743 } 1743 }
1744 1744
1745 if ((num_print_interval == 0 && metric_only) || interval_clear) 1745 if ((num_print_interval == 0 || interval_clear) && metric_only)
1746 print_metric_headers(" ", true); 1746 print_metric_headers(" ", true);
1747 if (++num_print_interval == 25) 1747 if (++num_print_interval == 25)
1748 num_print_interval = 0; 1748 num_print_interval = 0;
diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
index 0c6d1002b524..ac1bcdc17dae 100644
--- a/tools/perf/jvmti/jvmti_agent.c
+++ b/tools/perf/jvmti/jvmti_agent.c
@@ -35,6 +35,7 @@
35#include <sys/mman.h> 35#include <sys/mman.h>
36#include <syscall.h> /* for gettid() */ 36#include <syscall.h> /* for gettid() */
37#include <err.h> 37#include <err.h>
38#include <linux/kernel.h>
38 39
39#include "jvmti_agent.h" 40#include "jvmti_agent.h"
40#include "../util/jitdump.h" 41#include "../util/jitdump.h"
@@ -249,7 +250,7 @@ void *jvmti_open(void)
249 /* 250 /*
250 * jitdump file name 251 * jitdump file name
251 */ 252 */
252 snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid()); 253 scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
253 254
254 fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666); 255 fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666);
255 if (fd == -1) 256 if (fd == -1)
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.
11from __future__ import print_function
11 12
12import struct 13import 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 @@
11try: 11try:
12 import wx 12 import wx
13except ImportError: 13except 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
17class RootFrame(wx.Frame): 17class 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.
8from __future__ import print_function
8 9
9import errno, os 10import errno, os
10 11
@@ -33,7 +34,7 @@ def nsecs_str(nsecs):
33 return str 34 return str
34 35
35def add_stats(dict, key, value): 36def 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:
72except: 73except:
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
80def syscall_name(id): 81def 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 12from __future__ import print_function
13 13
14import os 14import os
15import sys 15import sys
16 16
17from collections import defaultdict 17from collections import defaultdict
18from UserList import UserList 18try:
19 from UserList import UserList
20except ImportError:
21 # Python 3: UserList moved to the collections package
22 from collections import UserList
19 23
20sys.path.append(os.environ['PERF_EXEC_PATH'] + \ 24sys.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
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 2bde505e2e7e..dd850a26d579 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -422,7 +422,7 @@ static const char *shell_test__description(char *description, size_t size,
422 422
423#define for_each_shell_test(dir, base, ent) \ 423#define for_each_shell_test(dir, base, ent) \
424 while ((ent = readdir(dir)) != NULL) \ 424 while ((ent = readdir(dir)) != NULL) \
425 if (!is_directory(base, ent)) 425 if (!is_directory(base, ent) && ent->d_name[0] != '.')
426 426
427static const char *shell_tests__dir(char *path, size_t size) 427static const char *shell_tests__dir(char *path, size_t size)
428{ 428{
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 263057039693..94e513e62b34 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -14,35 +14,40 @@ libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1
14nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254 14nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
15 15
16trace_libc_inet_pton_backtrace() { 16trace_libc_inet_pton_backtrace() {
17 idx=0 17
18 expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" 18 expected=`mktemp -u /tmp/expected.XXX`
19 expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 19
20 echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected
21 echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
20 case "$(uname -m)" in 22 case "$(uname -m)" in
21 s390x) 23 s390x)
22 eventattr='call-graph=dwarf,max-stack=4' 24 eventattr='call-graph=dwarf,max-stack=4'
23 expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 25 echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
24 expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 26 echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
25 expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" 27 echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
26 ;; 28 ;;
27 *) 29 *)
28 eventattr='max-stack=3' 30 eventattr='max-stack=3'
29 expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" 31 echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected
30 expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" 32 echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
31 ;; 33 ;;
32 esac 34 esac
33 35
34 file=`mktemp -u /tmp/perf.data.XXX` 36 perf_data=`mktemp -u /tmp/perf.data.XXX`
37 perf_script=`mktemp -u /tmp/perf.script.XXX`
38 perf record -e probe_libc:inet_pton/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
39 perf script -i $perf_data > $perf_script
35 40
36 perf record -e probe_libc:inet_pton/$eventattr/ -o $file ping -6 -c 1 ::1 > /dev/null 2>&1 41 exec 3<$perf_script
37 perf script -i $file | while read line ; do 42 exec 4<$expected
43 while read line <&3 && read -r pattern <&4; do
44 [ -z "$pattern" ] && break
38 echo $line 45 echo $line
39 echo "$line" | egrep -q "${expected[$idx]}" 46 echo "$line" | egrep -q "$pattern"
40 if [ $? -ne 0 ] ; then 47 if [ $? -ne 0 ] ; then
41 printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line" 48 printf "FAIL: expected backtrace entry \"%s\" got \"%s\"\n" "$pattern" "$line"
42 exit 1 49 exit 1
43 fi 50 fi
44 let idx+=1
45 [ -z "${expected[$idx]}" ] && break
46 done 51 done
47 52
48 # If any statements are executed from this point onwards, 53 # If any statements are executed from this point onwards,
@@ -58,6 +63,6 @@ skip_if_no_perf_probe && \
58perf probe -q $libc inet_pton && \ 63perf probe -q $libc inet_pton && \
59trace_libc_inet_pton_backtrace 64trace_libc_inet_pton_backtrace
60err=$? 65err=$?
61rm -f ${file} 66rm -f ${perf_data} ${perf_script} ${expected}
62perf probe -q -d probe_libc:inet_pton 67perf probe -q -d probe_libc:inet_pton
63exit $err 68exit $err
diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
index 55ad9793d544..4ce276efe6b4 100755
--- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
@@ -17,7 +17,7 @@ skip_if_no_perf_probe || exit 2
17file=$(mktemp /tmp/temporary_file.XXXXX) 17file=$(mktemp /tmp/temporary_file.XXXXX)
18 18
19trace_open_vfs_getname() { 19trace_open_vfs_getname() {
20 evts=$(echo $(perf list syscalls:sys_enter_open* |& egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') 20 evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
21 perf trace -e $evts touch $file 2>&1 | \ 21 perf trace -e $evts touch $file 2>&1 | \
22 egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" 22 egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
23} 23}
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 976e658e38dc..5e94857dfca2 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -266,16 +266,16 @@ static const char *kinc_fetch_script =
266"#!/usr/bin/env sh\n" 266"#!/usr/bin/env sh\n"
267"if ! test -d \"$KBUILD_DIR\"\n" 267"if ! test -d \"$KBUILD_DIR\"\n"
268"then\n" 268"then\n"
269" exit -1\n" 269" exit 1\n"
270"fi\n" 270"fi\n"
271"if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n" 271"if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
272"then\n" 272"then\n"
273" exit -1\n" 273" exit 1\n"
274"fi\n" 274"fi\n"
275"TMPDIR=`mktemp -d`\n" 275"TMPDIR=`mktemp -d`\n"
276"if test -z \"$TMPDIR\"\n" 276"if test -z \"$TMPDIR\"\n"
277"then\n" 277"then\n"
278" exit -1\n" 278" exit 1\n"
279"fi\n" 279"fi\n"
280"cat << EOF > $TMPDIR/Makefile\n" 280"cat << EOF > $TMPDIR/Makefile\n"
281"obj-y := dummy.o\n" 281"obj-y := dummy.o\n"
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 46e9e19ab1ac..bc32e57d17be 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -908,14 +908,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
908 if (_PyTuple_Resize(&t, n) == -1) 908 if (_PyTuple_Resize(&t, n) == -1)
909 Py_FatalError("error resizing Python tuple"); 909 Py_FatalError("error resizing Python tuple");
910 910
911 if (!dict) { 911 if (!dict)
912 call_object(handler, t, handler_name); 912 call_object(handler, t, handler_name);
913 } else { 913 else
914 call_object(handler, t, default_handler_name); 914 call_object(handler, t, default_handler_name);
915 Py_DECREF(dict);
916 }
917 915
918 Py_XDECREF(all_entries_dict);
919 Py_DECREF(t); 916 Py_DECREF(t);
920} 917}
921 918
@@ -1235,7 +1232,6 @@ static void python_process_general_event(struct perf_sample *sample,
1235 1232
1236 call_object(handler, t, handler_name); 1233 call_object(handler, t, handler_name);
1237 1234
1238 Py_DECREF(dict);
1239 Py_DECREF(t); 1235 Py_DECREF(t);
1240} 1236}
1241 1237
@@ -1627,6 +1623,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1627 fprintf(ofp, "# See the perf-script-python Documentation for the list " 1623 fprintf(ofp, "# See the perf-script-python Documentation for the list "
1628 "of available functions.\n\n"); 1624 "of available functions.\n\n");
1629 1625
1626 fprintf(ofp, "from __future__ import print_function\n\n");
1630 fprintf(ofp, "import os\n"); 1627 fprintf(ofp, "import os\n");
1631 fprintf(ofp, "import sys\n\n"); 1628 fprintf(ofp, "import sys\n\n");
1632 1629
@@ -1636,10 +1633,10 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1636 fprintf(ofp, "from Core import *\n\n\n"); 1633 fprintf(ofp, "from Core import *\n\n\n");
1637 1634
1638 fprintf(ofp, "def trace_begin():\n"); 1635 fprintf(ofp, "def trace_begin():\n");
1639 fprintf(ofp, "\tprint \"in trace_begin\"\n\n"); 1636 fprintf(ofp, "\tprint(\"in trace_begin\")\n\n");
1640 1637
1641 fprintf(ofp, "def trace_end():\n"); 1638 fprintf(ofp, "def trace_end():\n");
1642 fprintf(ofp, "\tprint \"in trace_end\"\n\n"); 1639 fprintf(ofp, "\tprint(\"in trace_end\")\n\n");
1643 1640
1644 while ((event = trace_find_next_event(pevent, event))) { 1641 while ((event = trace_find_next_event(pevent, event))) {
1645 fprintf(ofp, "def %s__%s(", event->system, event->name); 1642 fprintf(ofp, "def %s__%s(", event->system, event->name);
@@ -1675,7 +1672,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1675 "common_secs, common_nsecs,\n\t\t\t" 1672 "common_secs, common_nsecs,\n\t\t\t"
1676 "common_pid, common_comm)\n\n"); 1673 "common_pid, common_comm)\n\n");
1677 1674
1678 fprintf(ofp, "\t\tprint \""); 1675 fprintf(ofp, "\t\tprint(\"");
1679 1676
1680 not_first = 0; 1677 not_first = 0;
1681 count = 0; 1678 count = 0;
@@ -1736,31 +1733,31 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1736 fprintf(ofp, "%s", f->name); 1733 fprintf(ofp, "%s", f->name);
1737 } 1734 }
1738 1735
1739 fprintf(ofp, ")\n\n"); 1736 fprintf(ofp, "))\n\n");
1740 1737
1741 fprintf(ofp, "\t\tprint 'Sample: {'+" 1738 fprintf(ofp, "\t\tprint('Sample: {'+"
1742 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); 1739 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n");
1743 1740
1744 fprintf(ofp, "\t\tfor node in common_callchain:"); 1741 fprintf(ofp, "\t\tfor node in common_callchain:");
1745 fprintf(ofp, "\n\t\t\tif 'sym' in node:"); 1742 fprintf(ofp, "\n\t\t\tif 'sym' in node:");
1746 fprintf(ofp, "\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])"); 1743 fprintf(ofp, "\n\t\t\t\tprint(\"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name']))");
1747 fprintf(ofp, "\n\t\t\telse:"); 1744 fprintf(ofp, "\n\t\t\telse:");
1748 fprintf(ofp, "\n\t\t\t\tprint \"\t[%%x]\" %% (node['ip'])\n\n"); 1745 fprintf(ofp, "\n\t\t\t\tprint(\"\t[%%x]\" %% (node['ip']))\n\n");
1749 fprintf(ofp, "\t\tprint \"\\n\"\n\n"); 1746 fprintf(ofp, "\t\tprint()\n\n");
1750 1747
1751 } 1748 }
1752 1749
1753 fprintf(ofp, "def trace_unhandled(event_name, context, " 1750 fprintf(ofp, "def trace_unhandled(event_name, context, "
1754 "event_fields_dict, perf_sample_dict):\n"); 1751 "event_fields_dict, perf_sample_dict):\n");
1755 1752
1756 fprintf(ofp, "\t\tprint get_dict_as_string(event_fields_dict)\n"); 1753 fprintf(ofp, "\t\tprint(get_dict_as_string(event_fields_dict))\n");
1757 fprintf(ofp, "\t\tprint 'Sample: {'+" 1754 fprintf(ofp, "\t\tprint('Sample: {'+"
1758 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); 1755 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n");
1759 1756
1760 fprintf(ofp, "def print_header(" 1757 fprintf(ofp, "def print_header("
1761 "event_name, cpu, secs, nsecs, pid, comm):\n" 1758 "event_name, cpu, secs, nsecs, pid, comm):\n"
1762 "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" 1759 "\tprint(\"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t"
1763 "(event_name, cpu, secs, nsecs, pid, comm),\n\n"); 1760 "(event_name, cpu, secs, nsecs, pid, comm), end=\"\")\n\n");
1764 1761
1765 fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n" 1762 fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n"
1766 "\treturn delimiter.join" 1763 "\treturn delimiter.join"