Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+83 -80
+1 -2
tools/perf/Makefile.config
··· 207 207 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) 208 208 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 209 209 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 210 - PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 211 - PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) 210 + PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) 212 211 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 213 212 endif 214 213
+1 -1
tools/perf/arch/x86/util/perf_regs.c
··· 226 226 else if (rm[2].rm_so != rm[2].rm_eo) 227 227 prefix[0] = '+'; 228 228 else 229 - strncpy(prefix, "+0", 2); 229 + scnprintf(prefix, sizeof(prefix), "+0"); 230 230 } 231 231 232 232 /* Rename register */
+1 -1
tools/perf/builtin-stat.c
··· 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 1746 print_metric_headers(" ", true); 1747 1747 if (++num_print_interval == 25) 1748 1748 num_print_interval = 0;
+2 -1
tools/perf/jvmti/jvmti_agent.c
··· 35 35 #include <sys/mman.h> 36 36 #include <syscall.h> /* for gettid() */ 37 37 #include <err.h> 38 + #include <linux/kernel.h> 38 39 39 40 #include "jvmti_agent.h" 40 41 #include "../util/jitdump.h" ··· 250 249 /* 251 250 * jitdump file name 252 251 */ 253 - snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid()); 252 + scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid()); 254 253 255 254 fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666); 256 255 if (fd == -1)
+16 -22
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
··· 31 31 string = "" 32 32 33 33 if flag_fields[event_name][field_name]: 34 - print_delim = 0 35 - keys = flag_fields[event_name][field_name]['values'].keys() 36 - keys.sort() 37 - for idx in keys: 34 + print_delim = 0 35 + for idx in sorted(flag_fields[event_name][field_name]['values']): 38 36 if not value and not idx: 39 37 string += flag_fields[event_name][field_name]['values'][idx] 40 38 break ··· 49 51 string = "" 50 52 51 53 if symbolic_fields[event_name][field_name]: 52 - keys = symbolic_fields[event_name][field_name]['values'].keys() 53 - keys.sort() 54 - for idx in keys: 54 + for idx in sorted(symbolic_fields[event_name][field_name]['values']): 55 55 if not value and not idx: 56 - string = symbolic_fields[event_name][field_name]['values'][idx] 56 + string = symbolic_fields[event_name][field_name]['values'][idx] 57 57 break 58 - if (value == idx): 59 - string = symbolic_fields[event_name][field_name]['values'][idx] 58 + if (value == idx): 59 + string = symbolic_fields[event_name][field_name]['values'][idx] 60 60 break 61 61 62 62 return string ··· 70 74 string = "" 71 75 print_delim = 0 72 76 73 - keys = trace_flags.keys() 77 + for idx in trace_flags: 78 + if not value and not idx: 79 + string += "NONE" 80 + break 74 81 75 - for idx in keys: 76 - if not value and not idx: 77 - string += "NONE" 78 - break 79 - 80 - if idx and (value & idx) == idx: 81 - if print_delim: 82 - string += " | "; 83 - string += trace_flags[idx] 84 - print_delim = 1 85 - value &= ~idx 82 + if idx and (value & idx) == idx: 83 + if print_delim: 84 + string += " | "; 85 + string += trace_flags[idx] 86 + print_delim = 1 87 + value &= ~idx 86 88 87 89 return string 88 90
+3 -1
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py
··· 8 8 # PerfEvent is the base class for all perf event sample, PebsEvent 9 9 # is a HW base Intel x86 PEBS event, and user could add more SW/HW 10 10 # event classes based on requirements. 11 + from __future__ import print_function 11 12 12 13 import struct 13 14 ··· 45 44 PerfEvent.event_num += 1 46 45 47 46 def show(self): 48 - print "PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % (self.name, self.symbol, self.comm, self.dso) 47 + print("PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % 48 + (self.name, self.symbol, self.comm, self.dso)) 49 49 50 50 # 51 51 # Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer
+1 -1
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py
··· 11 11 try: 12 12 import wx 13 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 17 class RootFrame(wx.Frame):
+6 -5
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
··· 5 5 # This software may be distributed under the terms of the GNU General 6 6 # Public License ("GPL") version 2 as published by the Free Software 7 7 # Foundation. 8 + from __future__ import print_function 8 9 9 10 import errno, os 10 11 ··· 34 33 return str 35 34 36 35 def add_stats(dict, key, value): 37 - if not dict.has_key(key): 36 + if key not in dict: 38 37 dict[key] = (value, value, value, 1) 39 38 else: 40 39 min, max, avg, count = dict[key] ··· 73 72 except: 74 73 if not audit_package_warned: 75 74 audit_package_warned = True 76 - print "Install the audit-libs-python package to get syscall names.\n" \ 77 - "For example:\n # apt-get install python-audit (Ubuntu)" \ 78 - "\n # yum install audit-libs-python (Fedora)" \ 79 - "\n etc.\n" 75 + print("Install the audit-libs-python package to get syscall names.\n" 76 + "For example:\n # apt-get install python-audit (Ubuntu)" 77 + "\n # yum install audit-libs-python (Fedora)" 78 + "\n etc.\n") 80 79 81 80 def syscall_name(id): 82 81 try:
+9 -5
tools/perf/scripts/python/sched-migration.py
··· 9 9 # This software is distributed under the terms of the GNU General 10 10 # Public License ("GPL") version 2 as published by the Free Software 11 11 # Foundation. 12 - 12 + from __future__ import print_function 13 13 14 14 import os 15 15 import sys 16 16 17 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 24 sys.path.append(os.environ['PERF_EXEC_PATH'] + \ 21 25 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') ··· 304 300 if i == -1: 305 301 return 306 302 307 - for i in xrange(i, len(self.data)): 303 + for i in range(i, len(self.data)): 308 304 timeslice = self.data[i] 309 305 if timeslice.start > end: 310 306 return ··· 340 336 on_cpu_task = self.current_tsk[headers.cpu] 341 337 342 338 if on_cpu_task != -1 and on_cpu_task != prev_pid: 343 - print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ 344 - (headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) 339 + 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) 345 341 346 342 threads[prev_pid] = prev_comm 347 343 threads[next_pid] = next_comm
+1 -1
tools/perf/tests/builtin-test.c
··· 422 422 423 423 #define for_each_shell_test(dir, base, ent) \ 424 424 while ((ent = readdir(dir)) != NULL) \ 425 - if (!is_directory(base, ent)) 425 + if (!is_directory(base, ent) && ent->d_name[0] != '.') 426 426 427 427 static const char *shell_tests__dir(char *path, size_t size) 428 428 {
+21 -16
tools/perf/tests/shell/record+probe_libc_inet_pton.sh
··· 14 14 nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254 15 15 16 16 trace_libc_inet_pton_backtrace() { 17 - idx=0 18 - expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" 19 - expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 17 + 18 + expected=`mktemp -u /tmp/expected.XXX` 19 + 20 + echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected 21 + echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 20 22 case "$(uname -m)" in 21 23 s390x) 22 24 eventattr='call-graph=dwarf,max-stack=4' 23 - expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 24 - expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 25 - expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" 25 + echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 26 + echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 27 + echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected 26 28 ;; 27 29 *) 28 30 eventattr='max-stack=3' 29 - expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" 30 - expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" 31 + echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected 32 + echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected 31 33 ;; 32 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 37 - perf script -i $file | while read line ; do 41 + exec 3<$perf_script 42 + exec 4<$expected 43 + while read line <&3 && read -r pattern <&4; do 44 + [ -z "$pattern" ] && break 38 45 echo $line 39 - echo "$line" | egrep -q "${expected[$idx]}" 46 + echo "$line" | egrep -q "$pattern" 40 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 49 exit 1 43 50 fi 44 - let idx+=1 45 - [ -z "${expected[$idx]}" ] && break 46 51 done 47 52 48 53 # If any statements are executed from this point onwards, ··· 63 58 perf probe -q $libc inet_pton && \ 64 59 trace_libc_inet_pton_backtrace 65 60 err=$? 66 - rm -f ${file} 61 + rm -f ${perf_data} ${perf_script} ${expected} 67 62 perf probe -q -d probe_libc:inet_pton 68 63 exit $err
+1 -1
tools/perf/tests/shell/trace+probe_vfs_getname.sh
··· 17 17 file=$(mktemp /tmp/temporary_file.XXXXX) 18 18 19 19 trace_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 21 perf trace -e $evts touch $file 2>&1 | \ 22 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 }
+3 -3
tools/perf/util/llvm-utils.c
··· 266 266 "#!/usr/bin/env sh\n" 267 267 "if ! test -d \"$KBUILD_DIR\"\n" 268 268 "then\n" 269 - " exit -1\n" 269 + " exit 1\n" 270 270 "fi\n" 271 271 "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n" 272 272 "then\n" 273 - " exit -1\n" 273 + " exit 1\n" 274 274 "fi\n" 275 275 "TMPDIR=`mktemp -d`\n" 276 276 "if test -z \"$TMPDIR\"\n" 277 277 "then\n" 278 - " exit -1\n" 278 + " exit 1\n" 279 279 "fi\n" 280 280 "cat << EOF > $TMPDIR/Makefile\n" 281 281 "obj-y := dummy.o\n"
+17 -20
tools/perf/util/scripting-engines/trace-event-python.c
··· 908 908 if (_PyTuple_Resize(&t, n) == -1) 909 909 Py_FatalError("error resizing Python tuple"); 910 910 911 - if (!dict) { 911 + if (!dict) 912 912 call_object(handler, t, handler_name); 913 - } else { 913 + else 914 914 call_object(handler, t, default_handler_name); 915 - Py_DECREF(dict); 916 - } 917 915 918 - Py_XDECREF(all_entries_dict); 919 916 Py_DECREF(t); 920 917 } 921 918 ··· 1232 1235 1233 1236 call_object(handler, t, handler_name); 1234 1237 1235 - Py_DECREF(dict); 1236 1238 Py_DECREF(t); 1237 1239 } 1238 1240 ··· 1623 1627 fprintf(ofp, "# See the perf-script-python Documentation for the list " 1624 1628 "of available functions.\n\n"); 1625 1629 1630 + fprintf(ofp, "from __future__ import print_function\n\n"); 1626 1631 fprintf(ofp, "import os\n"); 1627 1632 fprintf(ofp, "import sys\n\n"); 1628 1633 ··· 1633 1636 fprintf(ofp, "from Core import *\n\n\n"); 1634 1637 1635 1638 fprintf(ofp, "def trace_begin():\n"); 1636 - fprintf(ofp, "\tprint \"in trace_begin\"\n\n"); 1639 + fprintf(ofp, "\tprint(\"in trace_begin\")\n\n"); 1637 1640 1638 1641 fprintf(ofp, "def trace_end():\n"); 1639 - fprintf(ofp, "\tprint \"in trace_end\"\n\n"); 1642 + fprintf(ofp, "\tprint(\"in trace_end\")\n\n"); 1640 1643 1641 1644 while ((event = trace_find_next_event(pevent, event))) { 1642 1645 fprintf(ofp, "def %s__%s(", event->system, event->name); ··· 1672 1675 "common_secs, common_nsecs,\n\t\t\t" 1673 1676 "common_pid, common_comm)\n\n"); 1674 1677 1675 - fprintf(ofp, "\t\tprint \""); 1678 + fprintf(ofp, "\t\tprint(\""); 1676 1679 1677 1680 not_first = 0; 1678 1681 count = 0; ··· 1733 1736 fprintf(ofp, "%s", f->name); 1734 1737 } 1735 1738 1736 - fprintf(ofp, ")\n\n"); 1739 + fprintf(ofp, "))\n\n"); 1737 1740 1738 - fprintf(ofp, "\t\tprint 'Sample: {'+" 1739 - "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); 1741 + fprintf(ofp, "\t\tprint('Sample: {'+" 1742 + "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n"); 1740 1743 1741 1744 fprintf(ofp, "\t\tfor node in common_callchain:"); 1742 1745 fprintf(ofp, "\n\t\t\tif 'sym' in node:"); 1743 - fprintf(ofp, "\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])"); 1746 + fprintf(ofp, "\n\t\t\t\tprint(\"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name']))"); 1744 1747 fprintf(ofp, "\n\t\t\telse:"); 1745 - fprintf(ofp, "\n\t\t\t\tprint \"\t[%%x]\" %% (node['ip'])\n\n"); 1746 - fprintf(ofp, "\t\tprint \"\\n\"\n\n"); 1748 + fprintf(ofp, "\n\t\t\t\tprint(\"\t[%%x]\" %% (node['ip']))\n\n"); 1749 + fprintf(ofp, "\t\tprint()\n\n"); 1747 1750 1748 1751 } 1749 1752 1750 1753 fprintf(ofp, "def trace_unhandled(event_name, context, " 1751 1754 "event_fields_dict, perf_sample_dict):\n"); 1752 1755 1753 - fprintf(ofp, "\t\tprint get_dict_as_string(event_fields_dict)\n"); 1754 - fprintf(ofp, "\t\tprint 'Sample: {'+" 1755 - "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); 1756 + fprintf(ofp, "\t\tprint(get_dict_as_string(event_fields_dict))\n"); 1757 + fprintf(ofp, "\t\tprint('Sample: {'+" 1758 + "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n"); 1756 1759 1757 1760 fprintf(ofp, "def print_header(" 1758 1761 "event_name, cpu, secs, nsecs, pid, comm):\n" 1759 - "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" 1760 - "(event_name, cpu, secs, nsecs, pid, comm),\n\n"); 1762 + "\tprint(\"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" 1763 + "(event_name, cpu, secs, nsecs, pid, comm), end=\"\")\n\n"); 1761 1764 1762 1765 fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n" 1763 1766 "\treturn delimiter.join"