diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-10-30 04:43:08 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-30 04:43:08 -0400 |
commit | 169ed55bd30305b933f52bfab32a58671d44ab68 (patch) | |
tree | 32e280957474f458901abfce16fa2a1687ef7497 /tools/perf | |
parent | 3d7851b3cdd43a734e5cc4c643fd886ab28ad4d5 (diff) | |
parent | 45f81b1c96d9793e47ce925d257ea693ce0b193e (diff) |
Merge branch 'tip/perf/jump-label-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into perf/urgent
Diffstat (limited to 'tools/perf')
27 files changed, 199 insertions, 50 deletions
diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index 43e3dd284b90..399751befeed 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt | |||
@@ -15,6 +15,23 @@ DESCRIPTION | |||
15 | This command displays the symbolic event types which can be selected in the | 15 | This command displays the symbolic event types which can be selected in the |
16 | various perf commands with the -e option. | 16 | various perf commands with the -e option. |
17 | 17 | ||
18 | EVENT MODIFIERS | ||
19 | --------------- | ||
20 | |||
21 | Events can optionally have a modifer by appending a colon and one or | ||
22 | more modifiers. Modifiers allow the user to restrict when events are | ||
23 | counted with 'u' for user-space, 'k' for kernel, 'h' for hypervisor. | ||
24 | |||
25 | The 'p' modifier can be used for specifying how precise the instruction | ||
26 | address should be. The 'p' modifier is currently only implemented for | ||
27 | Intel PEBS and can be specified multiple times: | ||
28 | 0 - SAMPLE_IP can have arbitrary skid | ||
29 | 1 - SAMPLE_IP must have constant skid | ||
30 | 2 - SAMPLE_IP requested to have 0 skid | ||
31 | 3 - SAMPLE_IP must have 0 skid | ||
32 | |||
33 | The PEBS implementation now supports up to 2. | ||
34 | |||
18 | RAW HARDWARE EVENT DESCRIPTOR | 35 | RAW HARDWARE EVENT DESCRIPTOR |
19 | ----------------------------- | 36 | ----------------------------- |
20 | Even when an event is not available in a symbolic form within perf right now, | 37 | Even when an event is not available in a symbolic form within perf right now, |
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 3ee27dccfde9..a91f9f9e6e5c 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
@@ -83,6 +83,10 @@ OPTIONS | |||
83 | --call-graph:: | 83 | --call-graph:: |
84 | Do call-graph (stack chain/backtrace) recording. | 84 | Do call-graph (stack chain/backtrace) recording. |
85 | 85 | ||
86 | -q:: | ||
87 | --quiet:: | ||
88 | Don't print any message, useful for scripting. | ||
89 | |||
86 | -v:: | 90 | -v:: |
87 | --verbose:: | 91 | --verbose:: |
88 | Be more verbose (show counter open errors, etc). | 92 | Be more verbose (show counter open errors, etc). |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index ff77b805de71..4e75583ddd6d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -353,7 +353,7 @@ try_again: | |||
353 | } | 353 | } |
354 | 354 | ||
355 | if (read(fd[nr_cpu][counter][thread_index], &read_data, sizeof(read_data)) == -1) { | 355 | if (read(fd[nr_cpu][counter][thread_index], &read_data, sizeof(read_data)) == -1) { |
356 | perror("Unable to read perf file descriptor\n"); | 356 | perror("Unable to read perf file descriptor"); |
357 | exit(-1); | 357 | exit(-1); |
358 | } | 358 | } |
359 | 359 | ||
@@ -626,7 +626,7 @@ static int __cmd_record(int argc, const char **argv) | |||
626 | 626 | ||
627 | nr_cpus = read_cpu_map(cpu_list); | 627 | nr_cpus = read_cpu_map(cpu_list); |
628 | if (nr_cpus < 1) { | 628 | if (nr_cpus < 1) { |
629 | perror("failed to collect number of CPUs\n"); | 629 | perror("failed to collect number of CPUs"); |
630 | return -1; | 630 | return -1; |
631 | } | 631 | } |
632 | 632 | ||
@@ -761,6 +761,9 @@ static int __cmd_record(int argc, const char **argv) | |||
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | if (quiet) | ||
765 | return 0; | ||
766 | |||
764 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); | 767 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); |
765 | 768 | ||
766 | /* | 769 | /* |
@@ -820,6 +823,7 @@ static const struct option options[] = { | |||
820 | "do call-graph (stack chain/backtrace) recording"), | 823 | "do call-graph (stack chain/backtrace) recording"), |
821 | OPT_INCR('v', "verbose", &verbose, | 824 | OPT_INCR('v', "verbose", &verbose, |
822 | "be more verbose (show counter open errors, etc)"), | 825 | "be more verbose (show counter open errors, etc)"), |
826 | OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"), | ||
823 | OPT_BOOLEAN('s', "stat", &inherit_stat, | 827 | OPT_BOOLEAN('s', "stat", &inherit_stat, |
824 | "per thread counts"), | 828 | "per thread counts"), |
825 | OPT_BOOLEAN('d', "data", &sample_address, | 829 | OPT_BOOLEAN('d', "data", &sample_address, |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 40a6a2992d15..2f8df45c4dcb 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -46,9 +46,6 @@ static struct scripting_ops *scripting_ops; | |||
46 | 46 | ||
47 | static void setup_scripting(void) | 47 | static void setup_scripting(void) |
48 | { | 48 | { |
49 | /* make sure PERF_EXEC_PATH is set for scripts */ | ||
50 | perf_set_argv_exec_path(perf_exec_path()); | ||
51 | |||
52 | setup_perl_scripting(); | 49 | setup_perl_scripting(); |
53 | setup_python_scripting(); | 50 | setup_python_scripting(); |
54 | 51 | ||
@@ -285,7 +282,7 @@ static int parse_scriptname(const struct option *opt __used, | |||
285 | script++; | 282 | script++; |
286 | } else { | 283 | } else { |
287 | script = str; | 284 | script = str; |
288 | ext = strchr(script, '.'); | 285 | ext = strrchr(script, '.'); |
289 | if (!ext) { | 286 | if (!ext) { |
290 | fprintf(stderr, "invalid script extension"); | 287 | fprintf(stderr, "invalid script extension"); |
291 | return -1; | 288 | return -1; |
@@ -593,6 +590,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
593 | suffix = REPORT_SUFFIX; | 590 | suffix = REPORT_SUFFIX; |
594 | } | 591 | } |
595 | 592 | ||
593 | /* make sure PERF_EXEC_PATH is set for scripts */ | ||
594 | perf_set_argv_exec_path(perf_exec_path()); | ||
595 | |||
596 | if (!suffix && argc >= 2 && strncmp(argv[1], "-", strlen("-")) != 0) { | 596 | if (!suffix && argc >= 2 && strncmp(argv[1], "-", strlen("-")) != 0) { |
597 | char *record_script_path, *report_script_path; | 597 | char *record_script_path, *report_script_path; |
598 | int live_pipe[2]; | 598 | int live_pipe[2]; |
@@ -625,12 +625,13 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
625 | dup2(live_pipe[1], 1); | 625 | dup2(live_pipe[1], 1); |
626 | close(live_pipe[0]); | 626 | close(live_pipe[0]); |
627 | 627 | ||
628 | __argv = malloc(5 * sizeof(const char *)); | 628 | __argv = malloc(6 * sizeof(const char *)); |
629 | __argv[0] = "/bin/sh"; | 629 | __argv[0] = "/bin/sh"; |
630 | __argv[1] = record_script_path; | 630 | __argv[1] = record_script_path; |
631 | __argv[2] = "-o"; | 631 | __argv[2] = "-q"; |
632 | __argv[3] = "-"; | 632 | __argv[3] = "-o"; |
633 | __argv[4] = NULL; | 633 | __argv[4] = "-"; |
634 | __argv[5] = NULL; | ||
634 | 635 | ||
635 | execvp("/bin/sh", (char **)__argv); | 636 | execvp("/bin/sh", (char **)__argv); |
636 | exit(-1); | 637 | exit(-1); |
diff --git a/tools/perf/scripts/perl/bin/failed-syscalls-report b/tools/perf/scripts/perl/bin/failed-syscalls-report index e3a5e55d54ff..4028d92dc4ae 100644 --- a/tools/perf/scripts/perl/bin/failed-syscalls-report +++ b/tools/perf/scripts/perl/bin/failed-syscalls-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/perl/failed-syscalls.pl $comm | 10 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/failed-syscalls.pl $comm |
diff --git a/tools/perf/scripts/perl/bin/rw-by-file-report b/tools/perf/scripts/perl/bin/rw-by-file-report index d83070b7eeb5..ba25f4d41fb0 100644 --- a/tools/perf/scripts/perl/bin/rw-by-file-report +++ b/tools/perf/scripts/perl/bin/rw-by-file-report | |||
@@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then | |||
7 | fi | 7 | fi |
8 | comm=$1 | 8 | comm=$1 |
9 | shift | 9 | shift |
10 | perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm | 10 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-file.pl $comm |
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
diff --git a/tools/perf/scripts/perl/bin/rw-by-pid-report b/tools/perf/scripts/perl/bin/rw-by-pid-report index 7ef46983f62f..641a3f5d085c 100644 --- a/tools/perf/scripts/perl/bin/rw-by-pid-report +++ b/tools/perf/scripts/perl/bin/rw-by-pid-report | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # description: system-wide r/w activity | 2 | # description: system-wide r/w activity |
3 | perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl | 3 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-pid.pl |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
diff --git a/tools/perf/scripts/perl/bin/rwtop-report b/tools/perf/scripts/perl/bin/rwtop-report index 93e698cd3f38..4918dba77021 100644 --- a/tools/perf/scripts/perl/bin/rwtop-report +++ b/tools/perf/scripts/perl/bin/rwtop-report | |||
@@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then | |||
17 | interval=$1 | 17 | interval=$1 |
18 | shift | 18 | shift |
19 | fi | 19 | fi |
20 | perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval | 20 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rwtop.pl $interval |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
diff --git a/tools/perf/scripts/perl/bin/wakeup-latency-report b/tools/perf/scripts/perl/bin/wakeup-latency-report index a0d898f9ca1d..49052ebcb632 100644 --- a/tools/perf/scripts/perl/bin/wakeup-latency-report +++ b/tools/perf/scripts/perl/bin/wakeup-latency-report | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # description: system-wide min/max/avg wakeup latency | 2 | # description: system-wide min/max/avg wakeup latency |
3 | perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl | 3 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/wakeup-latency.pl |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
diff --git a/tools/perf/scripts/perl/bin/workqueue-stats-report b/tools/perf/scripts/perl/bin/workqueue-stats-report index 35081132ef97..df0c65f4ca93 100644 --- a/tools/perf/scripts/perl/bin/workqueue-stats-report +++ b/tools/perf/scripts/perl/bin/workqueue-stats-report | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # description: workqueue stats (ins/exe/create/destroy) | 2 | # description: workqueue stats (ins/exe/create/destroy) |
3 | perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl | 3 | perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/workqueue-stats.pl |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
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 | ||
19 | for_comm = None | 20 | for_comm = None |
21 | for_pid = None | ||
20 | 22 | ||
21 | if len(sys.argv) > 2: | 23 | if len(sys.argv) > 2: |
22 | sys.exit(usage) | 24 | sys.exit(usage) |
23 | 25 | ||
24 | if len(sys.argv) > 1: | 26 | if len(sys.argv) > 1: |
25 | for_comm = sys.argv[1] | 27 | try: |
28 | for_pid = int(sys.argv[1]) | ||
29 | except: | ||
30 | for_comm = sys.argv[1] | ||
26 | 31 | ||
27 | syscalls = autodict() | 32 | syscalls = autodict() |
28 | 33 | ||
29 | def trace_begin(): | 34 | def trace_begin(): |
30 | pass | 35 | print "Press control+C to stop and show the summary" |
31 | 36 | ||
32 | def trace_end(): | 37 | def trace_end(): |
33 | print_error_totals() | 38 | print_error_totals() |
@@ -35,9 +40,9 @@ def trace_end(): | |||
35 | def raw_syscalls__sys_exit(event_name, context, common_cpu, | 40 | def raw_syscalls__sys_exit(event_name, context, common_cpu, |
36 | common_secs, common_nsecs, common_pid, common_comm, | 41 | common_secs, common_nsecs, common_pid, common_comm, |
37 | id, ret): | 42 | id, ret): |
38 | if for_comm is not None: | 43 | if (for_comm and common_comm != for_comm) or \ |
39 | if common_comm != for_comm: | 44 | (for_pid and common_pid != for_pid ): |
40 | return | 45 | return |
41 | 46 | ||
42 | if ret < 0: | 47 | if ret < 0: |
43 | try: | 48 | try: |
@@ -62,7 +67,7 @@ def print_error_totals(): | |||
62 | print "\n%s [%d]\n" % (comm, pid), | 67 | print "\n%s [%d]\n" % (comm, pid), |
63 | id_keys = syscalls[comm][pid].keys() | 68 | id_keys = syscalls[comm][pid].keys() |
64 | for id in id_keys: | 69 | for id in id_keys: |
65 | print " syscall: %-16d\n" % (id), | 70 | print " syscall: %-16s\n" % syscall_name(id), |
66 | ret_keys = syscalls[comm][pid][id].keys() | 71 | ret_keys = syscalls[comm][pid][id].keys() |
67 | for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): | 72 | for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): |
68 | print " err = %-20d %10d\n" % (ret, val), | 73 | print " err = %-20s %10d\n" % (strerror(ret), val), |
diff --git a/tools/perf/scripts/python/futex-contention.py b/tools/perf/scripts/python/futex-contention.py new file mode 100644 index 000000000000..11e70a388d41 --- /dev/null +++ b/tools/perf/scripts/python/futex-contention.py | |||
@@ -0,0 +1,50 @@ | |||
1 | # futex contention | ||
2 | # (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com> | ||
3 | # Licensed under the terms of the GNU GPL License version 2 | ||
4 | # | ||
5 | # Translation of: | ||
6 | # | ||
7 | # http://sourceware.org/systemtap/wiki/WSFutexContention | ||
8 | # | ||
9 | # to perf python scripting. | ||
10 | # | ||
11 | # Measures futex contention | ||
12 | |||
13 | import os, sys | ||
14 | sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | ||
15 | from Util import * | ||
16 | |||
17 | process_names = {} | ||
18 | thread_thislock = {} | ||
19 | thread_blocktime = {} | ||
20 | |||
21 | lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time | ||
22 | process_names = {} # long-lived pid-to-execname mapping | ||
23 | |||
24 | def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, | ||
25 | nr, uaddr, op, val, utime, uaddr2, val3): | ||
26 | cmd = op & FUTEX_CMD_MASK | ||
27 | if cmd != FUTEX_WAIT: | ||
28 | return # we don't care about originators of WAKE events | ||
29 | |||
30 | process_names[tid] = comm | ||
31 | thread_thislock[tid] = uaddr | ||
32 | thread_blocktime[tid] = nsecs(s, ns) | ||
33 | |||
34 | def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, | ||
35 | nr, ret): | ||
36 | if thread_blocktime.has_key(tid): | ||
37 | elapsed = nsecs(s, ns) - thread_blocktime[tid] | ||
38 | add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) | ||
39 | del thread_blocktime[tid] | ||
40 | del thread_thislock[tid] | ||
41 | |||
42 | def trace_begin(): | ||
43 | print "Press control+C to stop and show the summary" | ||
44 | |||
45 | def trace_end(): | ||
46 | for (tid, lock) in lock_waits: | ||
47 | min, max, avg, count = lock_waits[tid, lock] | ||
48 | print "%s[%d] lock %x contended %d times, %d avg ns" % \ | ||
49 | (process_names[tid], tid, lock, count, avg) | ||
50 | |||
diff --git a/tools/perf/scripts/python/sctop.py b/tools/perf/scripts/python/sctop.py index 6cafad40c296..7a6ec2c7d8ab 100644 --- a/tools/perf/scripts/python/sctop.py +++ b/tools/perf/scripts/python/sctop.py | |||
@@ -8,10 +8,7 @@ | |||
8 | # will be refreshed every [interval] seconds. The default interval is | 8 | # will be refreshed every [interval] seconds. The default interval is |
9 | # 3 seconds. | 9 | # 3 seconds. |
10 | 10 | ||
11 | import thread | 11 | import os, sys, thread, time |
12 | import time | ||
13 | import os | ||
14 | import sys | ||
15 | 12 | ||
16 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 13 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ |
17 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | 14 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') |
@@ -20,7 +17,7 @@ from perf_trace_context import * | |||
20 | from Core import * | 17 | from Core import * |
21 | from Util import * | 18 | from Util import * |
22 | 19 | ||
23 | usage = "perf trace -s syscall-counts.py [comm] [interval]\n"; | 20 | usage = "perf trace -s sctop.py [comm] [interval]\n"; |
24 | 21 | ||
25 | for_comm = None | 22 | for_comm = None |
26 | default_interval = 3 | 23 | default_interval = 3 |
@@ -71,7 +68,7 @@ def print_syscall_totals(interval): | |||
71 | for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ | 68 | for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ |
72 | reverse = True): | 69 | reverse = True): |
73 | try: | 70 | try: |
74 | print "%-40d %10d\n" % (id, val), | 71 | print "%-40s %10d\n" % (syscall_name(id), val), |
75 | except TypeError: | 72 | except TypeError: |
76 | pass | 73 | pass |
77 | syscalls.clear() | 74 | syscalls.clear() |
diff --git a/tools/perf/scripts/python/syscall-counts-by-pid.py b/tools/perf/scripts/python/syscall-counts-by-pid.py index af722d6a4b3f..d1ee3ec10cf2 100644 --- a/tools/perf/scripts/python/syscall-counts-by-pid.py +++ b/tools/perf/scripts/python/syscall-counts-by-pid.py | |||
@@ -5,29 +5,33 @@ | |||
5 | # Displays system-wide system call totals, broken down by syscall. | 5 | # Displays system-wide system call totals, broken down by syscall. |
6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. | 6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. |
7 | 7 | ||
8 | import os | 8 | import os, sys |
9 | import sys | ||
10 | 9 | ||
11 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 10 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ |
12 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | 11 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') |
13 | 12 | ||
14 | from perf_trace_context import * | 13 | from perf_trace_context import * |
15 | from Core import * | 14 | from Core import * |
15 | from Util import syscall_name | ||
16 | 16 | ||
17 | usage = "perf trace -s syscall-counts-by-pid.py [comm]\n"; | 17 | usage = "perf trace -s syscall-counts-by-pid.py [comm]\n"; |
18 | 18 | ||
19 | for_comm = None | 19 | for_comm = None |
20 | for_pid = None | ||
20 | 21 | ||
21 | if len(sys.argv) > 2: | 22 | if len(sys.argv) > 2: |
22 | sys.exit(usage) | 23 | sys.exit(usage) |
23 | 24 | ||
24 | if len(sys.argv) > 1: | 25 | if len(sys.argv) > 1: |
25 | for_comm = sys.argv[1] | 26 | try: |
27 | for_pid = int(sys.argv[1]) | ||
28 | except: | ||
29 | for_comm = sys.argv[1] | ||
26 | 30 | ||
27 | syscalls = autodict() | 31 | syscalls = autodict() |
28 | 32 | ||
29 | def trace_begin(): | 33 | def trace_begin(): |
30 | pass | 34 | print "Press control+C to stop and show the summary" |
31 | 35 | ||
32 | def trace_end(): | 36 | def trace_end(): |
33 | print_syscall_totals() | 37 | print_syscall_totals() |
@@ -35,9 +39,10 @@ def trace_end(): | |||
35 | def raw_syscalls__sys_enter(event_name, context, common_cpu, | 39 | def raw_syscalls__sys_enter(event_name, context, common_cpu, |
36 | common_secs, common_nsecs, common_pid, common_comm, | 40 | common_secs, common_nsecs, common_pid, common_comm, |
37 | id, args): | 41 | id, args): |
38 | if for_comm is not None: | 42 | |
39 | if common_comm != for_comm: | 43 | if (for_comm and common_comm != for_comm) or \ |
40 | return | 44 | (for_pid and common_pid != for_pid ): |
45 | return | ||
41 | try: | 46 | try: |
42 | syscalls[common_comm][common_pid][id] += 1 | 47 | syscalls[common_comm][common_pid][id] += 1 |
43 | except TypeError: | 48 | except TypeError: |
@@ -61,4 +66,4 @@ def print_syscall_totals(): | |||
61 | id_keys = syscalls[comm][pid].keys() | 66 | id_keys = syscalls[comm][pid].keys() |
62 | for id, val in sorted(syscalls[comm][pid].iteritems(), \ | 67 | for id, val in sorted(syscalls[comm][pid].iteritems(), \ |
63 | key = lambda(k, v): (v, k), reverse = True): | 68 | key = lambda(k, v): (v, k), reverse = True): |
64 | print " %-38d %10d\n" % (id, val), | 69 | print " %-38s %10d\n" % (syscall_name(id), val), |
diff --git a/tools/perf/scripts/python/syscall-counts.py b/tools/perf/scripts/python/syscall-counts.py index f977e85ff049..ea183dc82d29 100644 --- a/tools/perf/scripts/python/syscall-counts.py +++ b/tools/perf/scripts/python/syscall-counts.py | |||
@@ -13,6 +13,7 @@ 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 syscall_name | ||
16 | 17 | ||
17 | usage = "perf trace -s syscall-counts.py [comm]\n"; | 18 | usage = "perf trace -s syscall-counts.py [comm]\n"; |
18 | 19 | ||
@@ -27,7 +28,7 @@ if len(sys.argv) > 1: | |||
27 | syscalls = autodict() | 28 | syscalls = autodict() |
28 | 29 | ||
29 | def trace_begin(): | 30 | def trace_begin(): |
30 | pass | 31 | print "Press control+C to stop and show the summary" |
31 | 32 | ||
32 | def trace_end(): | 33 | def trace_end(): |
33 | print_syscall_totals() | 34 | print_syscall_totals() |
@@ -55,4 +56,4 @@ def print_syscall_totals(): | |||
55 | 56 | ||
56 | for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ | 57 | for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ |
57 | reverse = True): | 58 | reverse = True): |
58 | print "%-40d %10d\n" % (id, val), | 59 | print "%-40s %10d\n" % (syscall_name(id), val), |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index f9c7e3ad1aa7..c8d81b00089d 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -12,8 +12,8 @@ | |||
12 | #include "debug.h" | 12 | #include "debug.h" |
13 | #include "util.h" | 13 | #include "util.h" |
14 | 14 | ||
15 | int verbose = 0; | 15 | int verbose; |
16 | bool dump_trace = false; | 16 | bool dump_trace = false, quiet = false; |
17 | 17 | ||
18 | int eprintf(int level, const char *fmt, ...) | 18 | int eprintf(int level, const char *fmt, ...) |
19 | { | 19 | { |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 7a17ee061bcb..7b514082bbaf 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -6,7 +6,7 @@ | |||
6 | #include "event.h" | 6 | #include "event.h" |
7 | 7 | ||
8 | extern int verbose; | 8 | extern int verbose; |
9 | extern bool dump_trace; | 9 | extern bool quiet, dump_trace; |
10 | 10 | ||
11 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 11 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
12 | void trace_event(event_t *event); | 12 | void trace_event(event_t *event); |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index c20bd52833aa..3991d73d1cff 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -1731,7 +1731,8 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data) | |||
1731 | struct line_finder *lf = param->data; | 1731 | struct line_finder *lf = param->data; |
1732 | struct line_range *lr = lf->lr; | 1732 | struct line_range *lr = lf->lr; |
1733 | 1733 | ||
1734 | pr_debug("find (%lx) %s\n", dwarf_dieoffset(sp_die), | 1734 | pr_debug("find (%llx) %s\n", |
1735 | (unsigned long long)dwarf_dieoffset(sp_die), | ||
1735 | dwarf_diename(sp_die)); | 1736 | dwarf_diename(sp_die)); |
1736 | if (dwarf_tag(sp_die) == DW_TAG_subprogram && | 1737 | if (dwarf_tag(sp_die) == DW_TAG_subprogram && |
1737 | die_compare_name(sp_die, lr->function)) { | 1738 | die_compare_name(sp_die, lr->function)) { |