浏览代码

Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/urgent

Ingo Molnar 14 年之前
父节点
当前提交
5df414c61e

+ 17 - 0
tools/perf/Documentation/perf-list.txt

@@ -15,6 +15,23 @@ DESCRIPTION
 This command displays the symbolic event types which can be selected in the
 This command displays the symbolic event types which can be selected in the
 various perf commands with the -e option.
 various perf commands with the -e option.
 
 
+EVENT MODIFIERS
+---------------
+
+Events can optionally have a modifer by appending a colon and one or
+more modifiers.  Modifiers allow the user to restrict when events are
+counted with 'u' for user-space, 'k' for kernel, 'h' for hypervisor.
+
+The 'p' modifier can be used for specifying how precise the instruction
+address should be. The 'p' modifier is currently only implemented for
+Intel PEBS and can be specified multiple times:
+  0 - SAMPLE_IP can have arbitrary skid
+  1 - SAMPLE_IP must have constant skid
+  2 - SAMPLE_IP requested to have 0 skid
+  3 - SAMPLE_IP must have 0 skid
+
+The PEBS implementation now supports up to 2.
+
 RAW HARDWARE EVENT DESCRIPTOR
 RAW HARDWARE EVENT DESCRIPTOR
 -----------------------------
 -----------------------------
 Even when an event is not available in a symbolic form within perf right now,
 Even when an event is not available in a symbolic form within perf right now,

+ 4 - 4
tools/perf/builtin-trace.c

@@ -46,9 +46,6 @@ static struct scripting_ops	*scripting_ops;
 
 
 static void setup_scripting(void)
 static void setup_scripting(void)
 {
 {
-	/* make sure PERF_EXEC_PATH is set for scripts */
-	perf_set_argv_exec_path(perf_exec_path());
-
 	setup_perl_scripting();
 	setup_perl_scripting();
 	setup_python_scripting();
 	setup_python_scripting();
 
 
@@ -285,7 +282,7 @@ static int parse_scriptname(const struct option *opt __used,
 		script++;
 		script++;
 	} else {
 	} else {
 		script = str;
 		script = str;
-		ext = strchr(script, '.');
+		ext = strrchr(script, '.');
 		if (!ext) {
 		if (!ext) {
 			fprintf(stderr, "invalid script extension");
 			fprintf(stderr, "invalid script extension");
 			return -1;
 			return -1;
@@ -593,6 +590,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 		suffix = REPORT_SUFFIX;
 		suffix = REPORT_SUFFIX;
 	}
 	}
 
 
+	/* make sure PERF_EXEC_PATH is set for scripts */
+	perf_set_argv_exec_path(perf_exec_path());
+
 	if (!suffix && argc >= 2 && strncmp(argv[1], "-", strlen("-")) != 0) {
 	if (!suffix && argc >= 2 && strncmp(argv[1], "-", strlen("-")) != 0) {
 		char *record_script_path, *report_script_path;
 		char *record_script_path, *report_script_path;
 		int live_pipe[2];
 		int live_pipe[2];

+ 1 - 1
tools/perf/scripts/perl/bin/failed-syscalls-report

@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
 	shift
     fi
     fi
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $comm
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/failed-syscalls.pl $comm

+ 1 - 1
tools/perf/scripts/perl/bin/rw-by-file-report

@@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then
 fi
 fi
 comm=$1
 comm=$1
 shift
 shift
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-file.pl $comm
 
 
 
 
 
 

+ 1 - 1
tools/perf/scripts/perl/bin/rw-by-pid-report

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # description: system-wide r/w activity
 # description: system-wide r/w activity
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-pid.pl
 
 
 
 
 
 

+ 1 - 1
tools/perf/scripts/perl/bin/rwtop-report

@@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then
     interval=$1
     interval=$1
     shift
     shift
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rwtop.pl $interval
 
 
 
 
 
 

+ 1 - 1
tools/perf/scripts/perl/bin/wakeup-latency-report

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # description: system-wide min/max/avg wakeup latency
 # description: system-wide min/max/avg wakeup latency
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/wakeup-latency.pl
 
 
 
 
 
 

+ 1 - 1
tools/perf/scripts/perl/bin/workqueue-stats-report

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # description: workqueue stats (ins/exe/create/destroy)
 # description: workqueue stats (ins/exe/create/destroy)
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/workqueue-stats.pl
 
 
 
 
 
 

+ 40 - 0
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py

@@ -6,6 +6,8 @@
 # Public License ("GPL") version 2 as published by the Free Software
 # Public License ("GPL") version 2 as published by the Free Software
 # Foundation.
 # Foundation.
 
 
+import errno, os
+
 NSECS_PER_SEC    = 1000000000
 NSECS_PER_SEC    = 1000000000
 
 
 def avg(total, n):
 def avg(total, n):
@@ -26,3 +28,41 @@ def nsecs_str(nsecs):
 
 
 def clear_term():
 def clear_term():
     print("\x1b[H\x1b[2J")
     print("\x1b[H\x1b[2J")
+
+audit_package_warned = False
+
+try:
+	import audit
+	machine_to_id = {
+		'x86_64': audit.MACH_86_64,
+		'alpha'	: audit.MACH_ALPHA,
+		'ia64'	: audit.MACH_IA64,
+		'ppc'	: audit.MACH_PPC,
+		'ppc64'	: audit.MACH_PPC64,
+		's390'	: audit.MACH_S390,
+		's390x'	: audit.MACH_S390X,
+		'i386'	: audit.MACH_X86,
+		'i586'	: audit.MACH_X86,
+		'i686'	: audit.MACH_X86,
+	}
+	try:
+		machine_to_id['armeb'] = audit.MACH_ARMEB
+	except:
+		pass
+	machine_id = machine_to_id[os.uname()[4]]
+except:
+	if not audit_package_warned:
+		audit_package_warned = True
+		print "Install the audit-libs-python package to get syscall names"
+
+def syscall_name(id):
+	try:
+		return audit.audit_syscall_to_name(id, machine_id)
+	except:
+		return str(id)
+
+def strerror(nr):
+	try:
+		return errno.errorcode[abs(nr)]
+	except:
+		return "Unknown %d errno" % nr

+ 1 - 1
tools/perf/scripts/python/bin/failed-syscalls-by-pid-report

@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
 	shift
     fi
     fi
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/failed-syscalls-by-pid.py $comm

+ 1 - 1
tools/perf/scripts/python/bin/netdev-times-report

@@ -2,4 +2,4 @@
 # description: display a process of packet and processing time
 # description: display a process of packet and processing time
 # args: [tx] [rx] [dev=] [debug]
 # args: [tx] [rx] [dev=] [debug]
 
 
-perf trace -s ~/libexec/perf-core/scripts/python/netdev-times.py $@
+perf trace -s "$PERF_EXEC_PATH"/scripts/python/netdev-times.py $@

+ 1 - 1
tools/perf/scripts/python/bin/sched-migration-report

@@ -1,3 +1,3 @@
 #!/bin/bash
 #!/bin/bash
 # description: sched migration overview
 # description: sched migration overview
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sched-migration.py
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/sched-migration.py

+ 1 - 1
tools/perf/scripts/python/bin/sctop-report

@@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then
     interval=$1
     interval=$1
     shift
     shift
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/sctop.py $comm $interval

+ 1 - 1
tools/perf/scripts/python/bin/syscall-counts-by-pid-report

@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
 	shift
     fi
     fi
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts-by-pid.py $comm

+ 1 - 1
tools/perf/scripts/python/bin/syscall-counts-report

@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
 	shift
     fi
     fi
 fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm
+perf trace $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts.py $comm

+ 13 - 8
tools/perf/scripts/python/failed-syscalls-by-pid.py

@@ -13,21 +13,26 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 
 
 from perf_trace_context import *
 from perf_trace_context import *
 from Core import *
 from Core import *
+from Util import *
 
 
-usage = "perf trace -s syscall-counts-by-pid.py [comm]\n";
+usage = "perf trace -s syscall-counts-by-pid.py [comm|pid]\n";
 
 
 for_comm = None
 for_comm = None
+for_pid = None
 
 
 if len(sys.argv) > 2:
 if len(sys.argv) > 2:
 	sys.exit(usage)
 	sys.exit(usage)
 
 
 if len(sys.argv) > 1:
 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()
 syscalls = autodict()
 
 
 def trace_begin():
 def trace_begin():
-	pass
+	print "Press control+C to stop and show the summary"
 
 
 def trace_end():
 def trace_end():
 	print_error_totals()
 	print_error_totals()
@@ -35,9 +40,9 @@ def trace_end():
 def raw_syscalls__sys_exit(event_name, context, common_cpu,
 def raw_syscalls__sys_exit(event_name, context, common_cpu,
 	common_secs, common_nsecs, common_pid, common_comm,
 	common_secs, common_nsecs, common_pid, common_comm,
 	id, ret):
 	id, ret):
-	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
 
 
 	if ret < 0:
 	if ret < 0:
 		try:
 		try:
@@ -62,7 +67,7 @@ def print_error_totals():
 		    print "\n%s [%d]\n" % (comm, pid),
 		    print "\n%s [%d]\n" % (comm, pid),
 		    id_keys = syscalls[comm][pid].keys()
 		    id_keys = syscalls[comm][pid].keys()
 		    for id in id_keys:
 		    for id in id_keys:
-			    print "  syscall: %-16d\n" % (id),
+			    print "  syscall: %-16s\n" % syscall_name(id),
 			    ret_keys = syscalls[comm][pid][id].keys()
 			    ret_keys = syscalls[comm][pid][id].keys()
 			    for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k),  reverse = True):
 			    for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k),  reverse = True):
-				    print "    err = %-20d  %10d\n" % (ret, val),
+				    print "    err = %-20s  %10d\n" % (strerror(ret), val),

+ 2 - 5
tools/perf/scripts/python/sctop.py

@@ -8,10 +8,7 @@
 # will be refreshed every [interval] seconds.  The default interval is
 # will be refreshed every [interval] seconds.  The default interval is
 # 3 seconds.
 # 3 seconds.
 
 
-import thread
-import time
-import os
-import sys
+import os, sys, thread, time
 
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -71,7 +68,7 @@ def print_syscall_totals(interval):
 		for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
 		for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
 					      reverse = True):
 					      reverse = True):
 			try:
 			try:
-				print "%-40d  %10d\n" % (id, val),
+				print "%-40s  %10d\n" % (syscall_name(id), val),
 			except TypeError:
 			except TypeError:
 				pass
 				pass
 		syscalls.clear()
 		syscalls.clear()

+ 13 - 8
tools/perf/scripts/python/syscall-counts-by-pid.py

@@ -5,29 +5,33 @@
 # Displays system-wide system call totals, broken down by syscall.
 # Displays system-wide system call totals, broken down by syscall.
 # If a [comm] arg is specified, only syscalls called by [comm] are displayed.
 # 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'] + \
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
 
 
 from perf_trace_context import *
 from perf_trace_context import *
 from Core import *
 from Core import *
+from Util import syscall_name
 
 
 usage = "perf trace -s syscall-counts-by-pid.py [comm]\n";
 usage = "perf trace -s syscall-counts-by-pid.py [comm]\n";
 
 
 for_comm = None
 for_comm = None
+for_pid = None
 
 
 if len(sys.argv) > 2:
 if len(sys.argv) > 2:
 	sys.exit(usage)
 	sys.exit(usage)
 
 
 if len(sys.argv) > 1:
 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()
 syscalls = autodict()
 
 
 def trace_begin():
 def trace_begin():
-	pass
+	print "Press control+C to stop and show the summary"
 
 
 def trace_end():
 def trace_end():
 	print_syscall_totals()
 	print_syscall_totals()
@@ -35,9 +39,10 @@ def trace_end():
 def raw_syscalls__sys_enter(event_name, context, common_cpu,
 def raw_syscalls__sys_enter(event_name, context, common_cpu,
 	common_secs, common_nsecs, common_pid, common_comm,
 	common_secs, common_nsecs, common_pid, common_comm,
 	id, args):
 	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:
 	try:
 		syscalls[common_comm][common_pid][id] += 1
 		syscalls[common_comm][common_pid][id] += 1
 	except TypeError:
 	except TypeError:
@@ -61,4 +66,4 @@ def print_syscall_totals():
 		    id_keys = syscalls[comm][pid].keys()
 		    id_keys = syscalls[comm][pid].keys()
 		    for id, val in sorted(syscalls[comm][pid].iteritems(), \
 		    for id, val in sorted(syscalls[comm][pid].iteritems(), \
 				  key = lambda(k, v): (v, k),  reverse = True):
 				  key = lambda(k, v): (v, k),  reverse = True):
-			    print "  %-38d  %10d\n" % (id, val),
+			    print "  %-38s  %10d\n" % (syscall_name(id), val),

+ 3 - 2
tools/perf/scripts/python/syscall-counts.py

@@ -13,6 +13,7 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 
 
 from perf_trace_context import *
 from perf_trace_context import *
 from Core import *
 from Core import *
+from Util import syscall_name
 
 
 usage = "perf trace -s syscall-counts.py [comm]\n";
 usage = "perf trace -s syscall-counts.py [comm]\n";
 
 
@@ -27,7 +28,7 @@ if len(sys.argv) > 1:
 syscalls = autodict()
 syscalls = autodict()
 
 
 def trace_begin():
 def trace_begin():
-	pass
+	print "Press control+C to stop and show the summary"
 
 
 def trace_end():
 def trace_end():
 	print_syscall_totals()
 	print_syscall_totals()
@@ -55,4 +56,4 @@ def print_syscall_totals():
 
 
     for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
     for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
 				  reverse = True):
 				  reverse = True):
-	    print "%-40d  %10d\n" % (id, val),
+	    print "%-40s  %10d\n" % (syscall_name(id), val),

+ 2 - 1
tools/perf/util/probe-finder.c

@@ -1731,7 +1731,8 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
 	struct line_finder *lf = param->data;
 	struct line_finder *lf = param->data;
 	struct line_range *lr = lf->lr;
 	struct line_range *lr = lf->lr;
 
 
-	pr_debug("find (%lx) %s\n", dwarf_dieoffset(sp_die),
+	pr_debug("find (%llx) %s\n",
+		 (unsigned long long)dwarf_dieoffset(sp_die),
 		 dwarf_diename(sp_die));
 		 dwarf_diename(sp_die));
 	if (dwarf_tag(sp_die) == DW_TAG_subprogram &&
 	if (dwarf_tag(sp_die) == DW_TAG_subprogram &&
 	    die_compare_name(sp_die, lr->function)) {
 	    die_compare_name(sp_die, lr->function)) {