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/Perf-Trace-Util | |
| 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/Perf-Trace-Util')
| -rw-r--r-- | tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py | 58 |
1 files changed, 58 insertions, 0 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 | ||
