Skip to content

Commit

Permalink
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/acme/linux-2.6 into perf/urgent
  • Loading branch information
Ingo Molnar committed Oct 26, 2010
2 parents 0b849ee + 7f6c1bd commit 5df414c
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 40 deletions.
17 changes: 17 additions & 0 deletions tools/perf/Documentation/perf-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ DESCRIPTION
This command displays the symbolic event types which can be selected in the
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
-----------------------------
Even when an event is not available in a symbolic form within perf right now,
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ static struct scripting_ops *scripting_ops;

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_python_scripting();

Expand Down Expand Up @@ -285,7 +282,7 @@ static int parse_scriptname(const struct option *opt __used,
script++;
} else {
script = str;
ext = strchr(script, '.');
ext = strrchr(script, '.');
if (!ext) {
fprintf(stderr, "invalid script extension");
return -1;
Expand Down Expand Up @@ -593,6 +590,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
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) {
char *record_script_path, *report_script_path;
int live_pipe[2];
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/failed-syscalls-report
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
shift
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
2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/rw-by-file-report
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then
fi
comm=$1
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



2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/rw-by-pid-report
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# 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



2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/rwtop-report
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then
interval=$1
shift
fi
perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval
perf trace $@ -s "$PERF_EXEC_PATH"/scripts/perl/rwtop.pl $interval



2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/wakeup-latency-report
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# 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



2 changes: 1 addition & 1 deletion tools/perf/scripts/perl/bin/workqueue-stats-report
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# 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



Expand Down
40 changes: 40 additions & 0 deletions tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.

import errno, os

NSECS_PER_SEC = 1000000000

def avg(total, n):
Expand All @@ -26,3 +28,41 @@ def nsecs_str(nsecs):

def clear_term():
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
shift
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
2 changes: 1 addition & 1 deletion tools/perf/scripts/python/bin/netdev-times-report
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# description: display a process of packet and processing time
# 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 $@
2 changes: 1 addition & 1 deletion tools/perf/scripts/python/bin/sched-migration-report
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
# 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
2 changes: 1 addition & 1 deletion tools/perf/scripts/python/bin/sctop-report
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then
interval=$1
shift
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
2 changes: 1 addition & 1 deletion tools/perf/scripts/python/bin/syscall-counts-by-pid-report
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
shift
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
2 changes: 1 addition & 1 deletion tools/perf/scripts/python/bin/syscall-counts-report
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
shift
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
21 changes: 13 additions & 8 deletions tools/perf/scripts/python/failed-syscalls-by-pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,36 @@

from perf_trace_context 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_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_error_totals()

def raw_syscalls__sys_exit(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
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:
try:
Expand All @@ -62,7 +67,7 @@ def print_error_totals():
print "\n%s [%d]\n" % (comm, pid),
id_keys = syscalls[comm][pid].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()
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),
7 changes: 2 additions & 5 deletions tools/perf/scripts/python/sctop.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
# will be refreshed every [interval] seconds. The default interval is
# 3 seconds.

import thread
import time
import os
import sys
import os, sys, thread, time

sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
Expand Down Expand Up @@ -71,7 +68,7 @@ def print_syscall_totals(interval):
for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
reverse = True):
try:
print "%-40d %10d\n" % (id, val),
print "%-40s %10d\n" % (syscall_name(id), val),
except TypeError:
pass
syscalls.clear()
Expand Down
21 changes: 13 additions & 8 deletions tools/perf/scripts/python/syscall-counts-by-pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@
# 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()

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:
Expand All @@ -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),
5 changes: 3 additions & 2 deletions tools/perf/scripts/python/syscall-counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from perf_trace_context import *
from Core import *
from Util import syscall_name

usage = "perf trace -s syscall-counts.py [comm]\n";

Expand All @@ -27,7 +28,7 @@
syscalls = autodict()

def trace_begin():
pass
print "Press control+C to stop and show the summary"

def trace_end():
print_syscall_totals()
Expand Down Expand Up @@ -55,4 +56,4 @@ def print_syscall_totals():

for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
reverse = True):
print "%-40d %10d\n" % (id, val),
print "%-40s %10d\n" % (syscall_name(id), val),
3 changes: 2 additions & 1 deletion tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,8 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
struct line_finder *lf = param->data;
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));
if (dwarf_tag(sp_die) == DW_TAG_subprogram &&
die_compare_name(sp_die, lr->function)) {
Expand Down

0 comments on commit 5df414c

Please sign in to comment.