diff options
Diffstat (limited to 'tools/perf/scripts/python')
14 files changed, 152 insertions, 30 deletions
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 9689bc0acd9f..13cc02b5893a 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 | |||
| @@ -6,6 +6,14 @@ | |||
| 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 | 8 | ||
| 9 | import errno, os | ||
| 10 | |||
| 11 | FUTEX_WAIT = 0 | ||
| 12 | FUTEX_WAKE = 1 | ||
| 13 | FUTEX_PRIVATE_FLAG = 128 | ||
| 14 | FUTEX_CLOCK_REALTIME = 256 | ||
| 15 | FUTEX_CMD_MASK = ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME) | ||
| 16 | |||
| 9 | NSECS_PER_SEC = 1000000000 | 17 | NSECS_PER_SEC = 1000000000 |
| 10 | 18 | ||
| 11 | def avg(total, n): | 19 | def avg(total, n): |
| @@ -24,5 +32,55 @@ def nsecs_str(nsecs): | |||
| 24 | str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)), | 32 | str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)), |
| 25 | return str | 33 | return str |
| 26 | 34 | ||
| 35 | def add_stats(dict, key, value): | ||
| 36 | if not dict.has_key(key): | ||
| 37 | dict[key] = (value, value, value, 1) | ||
| 38 | else: | ||
| 39 | min, max, avg, count = dict[key] | ||
| 40 | if value < min: | ||
| 41 | min = value | ||
| 42 | if value > max: | ||
| 43 | max = value | ||
| 44 | avg = (avg + value) / 2 | ||
| 45 | dict[key] = (min, max, avg, count + 1) | ||
| 46 | |||
| 27 | def clear_term(): | 47 | def clear_term(): |
| 28 | print("\x1b[H\x1b[2J") | 48 | print("\x1b[H\x1b[2J") |
| 49 | |||
| 50 | audit_package_warned = False | ||
| 51 | |||
| 52 | try: | ||
| 53 | import audit | ||
| 54 | machine_to_id = { | ||
| 55 | 'x86_64': audit.MACH_86_64, | ||
| 56 | 'alpha' : audit.MACH_ALPHA, | ||
| 57 | 'ia64' : audit.MACH_IA64, | ||
| 58 | 'ppc' : audit.MACH_PPC, | ||
| 59 | 'ppc64' : audit.MACH_PPC64, | ||
| 60 | 's390' : audit.MACH_S390, | ||
| 61 | 's390x' : audit.MACH_S390X, | ||
| 62 | 'i386' : audit.MACH_X86, | ||
| 63 | 'i586' : audit.MACH_X86, | ||
| 64 | 'i686' : audit.MACH_X86, | ||
| 65 | } | ||
| 66 | try: | ||
| 67 | machine_to_id['armeb'] = audit.MACH_ARMEB | ||
| 68 | except: | ||
| 69 | pass | ||
| 70 | machine_id = machine_to_id[os.uname()[4]] | ||
| 71 | except: | ||
| 72 | if not audit_package_warned: | ||
| 73 | audit_package_warned = True | ||
| 74 | print "Install the audit-libs-python package to get syscall names" | ||
| 75 | |||
| 76 | def syscall_name(id): | ||
| 77 | try: | ||
| 78 | return audit.audit_syscall_to_name(id, machine_id) | ||
| 79 | except: | ||
| 80 | return str(id) | ||
| 81 | |||
| 82 | def strerror(nr): | ||
| 83 | try: | ||
| 84 | return errno.errorcode[abs(nr)] | ||
| 85 | except: | ||
| 86 | return "Unknown %d errno" % nr | ||
diff --git a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report index 30293545fcc2..03587021463d 100644 --- a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report +++ b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report | |||
| @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then | |||
| 7 | shift | 7 | shift |
| 8 | fi | 8 | fi |
| 9 | fi | 9 | fi |
| 10 | perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm | 10 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/failed-syscalls-by-pid.py $comm |
diff --git a/tools/perf/scripts/python/bin/futex-contention-record b/tools/perf/scripts/python/bin/futex-contention-record new file mode 100644 index 000000000000..5ecbb433caf4 --- /dev/null +++ b/tools/perf/scripts/python/bin/futex-contention-record | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | perf record -a -e syscalls:sys_enter_futex -e syscalls:sys_exit_futex $@ | ||
diff --git a/tools/perf/scripts/python/bin/futex-contention-report b/tools/perf/scripts/python/bin/futex-contention-report new file mode 100644 index 000000000000..c8268138fb7e --- /dev/null +++ b/tools/perf/scripts/python/bin/futex-contention-report | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # description: futext contention measurement | ||
| 3 | |||
| 4 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/futex-contention.py | ||
diff --git a/tools/perf/scripts/python/bin/netdev-times-report b/tools/perf/scripts/python/bin/netdev-times-report index c3d0a638123d..4ad361b31249 100644 --- a/tools/perf/scripts/python/bin/netdev-times-report +++ b/tools/perf/scripts/python/bin/netdev-times-report | |||
| @@ -2,4 +2,4 @@ | |||
| 2 | # description: display a process of packet and processing time | 2 | # description: display a process of packet and processing time |
| 3 | # args: [tx] [rx] [dev=] [debug] | 3 | # args: [tx] [rx] [dev=] [debug] |
| 4 | 4 | ||
| 5 | perf trace -s ~/libexec/perf-core/scripts/python/netdev-times.py $@ | 5 | perf trace -s "$PERF_EXEC_PATH"/scripts/python/netdev-times.py $@ |
diff --git a/tools/perf/scripts/python/bin/sched-migration-report b/tools/perf/scripts/python/bin/sched-migration-report index 61d05f72e443..df1791f07c24 100644 --- a/tools/perf/scripts/python/bin/sched-migration-report +++ b/tools/perf/scripts/python/bin/sched-migration-report | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | # description: sched migration overview | 2 | # description: sched migration overview |
| 3 | perf trace $@ -s ~/libexec/perf-core/scripts/python/sched-migration.py | 3 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/sched-migration.py |
diff --git a/tools/perf/scripts/python/bin/sctop-report b/tools/perf/scripts/python/bin/sctop-report index b01c842ae7b4..36b409c05e50 100644 --- a/tools/perf/scripts/python/bin/sctop-report +++ b/tools/perf/scripts/python/bin/sctop-report | |||
| @@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then | |||
| 21 | interval=$1 | 21 | interval=$1 |
| 22 | shift | 22 | shift |
| 23 | fi | 23 | fi |
| 24 | perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval | 24 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/sctop.py $comm $interval |
diff --git a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report index 9e9d8ddd72ce..4eb88c9fc83c 100644 --- a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report +++ b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report | |||
| @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then | |||
| 7 | shift | 7 | shift |
| 8 | fi | 8 | fi |
| 9 | fi | 9 | fi |
| 10 | perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm | 10 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts-by-pid.py $comm |
diff --git a/tools/perf/scripts/python/bin/syscall-counts-report b/tools/perf/scripts/python/bin/syscall-counts-report index dc076b618796..cb2f9c5cf17e 100644 --- a/tools/perf/scripts/python/bin/syscall-counts-report +++ b/tools/perf/scripts/python/bin/syscall-counts-report | |||
| @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then | |||
| 7 | shift | 7 | shift |
| 8 | fi | 8 | fi |
| 9 | fi | 9 | fi |
| 10 | perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm | 10 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts.py $comm |
diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py index 0ca02278fe69..acd7848717b3 100644 --- a/tools/perf/scripts/python/failed-syscalls-by-pid.py +++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py | |||
| @@ -13,21 +13,26 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | |||
| 13 | 13 | ||
| 14 | from perf_trace_context import * | 14 | from perf_trace_context import * |
| 15 | from Core import * | 15 | from Core import * |
| 16 | from Util import * | ||
| 16 | 17 | ||
| 17 | usage = "perf trace -s syscall-counts-by-pid.py [comm]\n"; | 18 | usage = "perf trace -s syscall-counts-by-pid.py [comm|pid]\n"; |
| 18 | 19 | ||
