diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:48:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:48:00 -0400 |
commit | a042e26137d7674ac04b1cd2d5c06b9ebc1ee2d5 (patch) | |
tree | c1a7a8bda41b99caa4b4a0fe320fc73278879f7d /tools/perf/scripts/python/syscall-counts-by-pid.py | |
parent | f66dd539feb849a3a00f7fac67c026e0935e373a (diff) | |
parent | e25804a0327dad954f7d43803178fdef2fd35b4e (diff) |
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (50 commits)
perf python scripting: Add futex-contention script
perf python scripting: Fixup cut'n'paste error in sctop script
perf scripting: Shut up 'perf record' final status
perf record: Remove newline character from perror() argument
perf python scripting: Support fedora 11 (audit 1.7.17)
perf python scripting: Improve the syscalls-by-pid script
perf python scripting: print the syscall name on sctop
perf python scripting: Improve the syscalls-counts script
perf python scripting: Improve the failed-syscalls-by-pid script
kprobes: Remove redundant text_mutex lock in optimize
x86/oprofile: Fix uninitialized variable use in debug printk
tracing: Fix 'faild' -> 'failed' typo
perf probe: Fix format specified for Dwarf_Off parameter
perf trace: Fix detection of script extension
perf trace: Use $PERF_EXEC_PATH in canned report scripts
perf tools: Document event modifiers
perf tools: Remove direct slang.h include
perf_events: Fix for transaction recovery in group_sched_in()
perf_events: Revert: Fix transaction recovery in group_sched_in()
perf, x86: Use NUMA aware allocations for PEBS/BTS/DS allocations
...
Diffstat (limited to 'tools/perf/scripts/python/syscall-counts-by-pid.py')
-rw-r--r-- | tools/perf/scripts/python/syscall-counts-by-pid.py | 21 |
1 files changed, 13 insertions, 8 deletions
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), |