[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-a64fa198ba1cd232871710c37476e006ed5516ed@git.kernel.org>
Date: Tue, 26 Oct 2010 10:23:19 GMT
From: tip-bot for Arnaldo Carvalho de Melo <acme@...hat.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, eranian@...gle.com, paulus@...ba.org,
acme@...hat.com, hpa@...or.com, mingo@...hat.com,
tzanussi@...il.com, peterz@...radead.org, efault@....de,
davem@...emloft.net, fweisbec@...il.com, tglx@...utronix.de,
mingo@...e.hu
Subject: [tip:perf/urgent] perf python scripting: Improve the syscalls-by-pid script
Commit-ID: a64fa198ba1cd232871710c37476e006ed5516ed
Gitweb: http://git.kernel.org/tip/a64fa198ba1cd232871710c37476e006ed5516ed
Author: Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Mon, 25 Oct 2010 18:44:09 -0200
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 25 Oct 2010 18:48:15 -0200
perf python scripting: Improve the syscalls-by-pid script
. Print message at script start telling how to get te summary
. Print the syscall names
. Accept both pid (if numeric) or COMM name
Now it looks like this:
[root@...lia tmp]# perf trace syscall-counts-by-pid
Press control+C to stop and show the summary
^C
syscall events by comm/pid:
comm [pid]/syscalls count
---------------------------------------- ----------
automount [1670]
futex 2
sshd [2322]
rt_sigprocmask 4
select 2
write 1
read 1
perf [15178]
read 2506
open 794
close 769
write 240
getdents 112
lseek 16
stat 9
perf_counter_open 5
fcntl 5
mmap 5
statfs 2
perf [15179]
read 56701
open 499
stat 176
fstat 149
close 109
mmap 98
brk 75
rt_sigaction 66
munmap 42
mprotect 24
lstat 7
lseek 5
getdents 4
ioctl 3
readlink 2
futex 1
statfs 1
getegid 1
geteuid 1
getgid 1
getuid 1
getrlimit 1
fcntl 1
uname 1
write 1
[root@...lia tmp]# fg
-bash: fg: current: no such job
[root@...lia tmp]# perf trace syscall-counts-by-pid 2322
Press control+C to stop and show the summary
^C
syscall events by comm/pid:
comm [pid]/syscalls count
---------------------------------------- ----------
sshd [2322]
rt_sigprocmask 4
select 2
write 1
read 1
[root@...lia tmp]# perf trace syscall-counts-by-pid sshd
Press control+C to stop and show the summary
^C
syscall events for sshd:
comm [pid]/syscalls count
---------------------------------------- ----------
sshd [2322]
rt_sigprocmask 4
select 2
write 1
read 1
[root@...lia tmp]#
Cc: David S. Miller <davem@...emloft.net>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Mike Galbraith <efault@....de>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Cc: Tom Zanussi <tzanussi@...il.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
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 af722d6..d1ee3ec 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 @@
# Displays system-wide system call totals, broken down by syscall.
# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
-import os
-import sys
+import os, sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
+from Util import syscall_name
usage = "perf trace -s syscall-counts-by-pid.py [comm]\n";
for_comm = None
+for_pid = None
if len(sys.argv) > 2:
sys.exit(usage)
if len(sys.argv) > 1:
- for_comm = sys.argv[1]
+ try:
+ for_pid = int(sys.argv[1])
+ except:
+ for_comm = sys.argv[1]
syscalls = autodict()
def trace_begin():
- pass
+ print "Press control+C to stop and show the summary"
def trace_end():
print_syscall_totals()
@@ -35,9 +39,10 @@ def trace_end():
def raw_syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
id, args):
- if for_comm is not None:
- if common_comm != for_comm:
- return
+
+ if (for_comm and common_comm != for_comm) or \
+ (for_pid and common_pid != for_pid ):
+ return
try:
syscalls[common_comm][common_pid][id] += 1
except TypeError:
@@ -61,4 +66,4 @@ def print_syscall_totals():
id_keys = syscalls[comm][pid].keys()
for id, val in sorted(syscalls[comm][pid].iteritems(), \
key = lambda(k, v): (v, k), reverse = True):
- print " %-38d %10d\n" % (id, val),
+ print " %-38s %10d\n" % (syscall_name(id), val),
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists