diff options
| -rw-r--r-- | kernel/events/core.c | 21 | ||||
| -rw-r--r-- | tools/perf/Documentation/perf-probe.txt | 8 | ||||
| -rw-r--r-- | tools/perf/Documentation/perf-script-perl.txt | 2 | ||||
| -rw-r--r-- | tools/perf/Documentation/perf-script-python.txt | 23 | ||||
| -rw-r--r-- | tools/perf/arch/common.c | 1 | ||||
| -rw-r--r-- | tools/perf/builtin-stat.c | 5 | ||||
| -rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
| -rw-r--r-- | tools/perf/tests/bp_signal.c | 14 | ||||
| -rw-r--r-- | tools/perf/tests/builtin-test.c | 7 | ||||
| -rw-r--r-- | tools/perf/tests/code-reading.c | 20 | ||||
| -rw-r--r-- | tools/perf/tests/tests.h | 3 | ||||
| -rw-r--r-- | tools/perf/util/annotate.c | 72 | ||||
| -rw-r--r-- | tools/perf/util/build-id.c | 45 | ||||
| -rw-r--r-- | tools/perf/util/build-id.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/dso.c | 100 | ||||
| -rw-r--r-- | tools/perf/util/dso.h | 9 | ||||
| -rw-r--r-- | tools/perf/util/header.c | 12 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/symbol-elf.c | 41 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/unwind-libdw.c | 10 |
22 files changed, 259 insertions, 156 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 6e75a5c9412d..6c4e523dc1e2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -7316,6 +7316,21 @@ int perf_event_account_interrupt(struct perf_event *event) | |||
| 7316 | return __perf_event_account_interrupt(event, 1); | 7316 | return __perf_event_account_interrupt(event, 1); |
| 7317 | } | 7317 | } |
| 7318 | 7318 | ||
| 7319 | static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs) | ||
| 7320 | { | ||
| 7321 | /* | ||
| 7322 | * Due to interrupt latency (AKA "skid"), we may enter the | ||
| 7323 | * kernel before taking an overflow, even if the PMU is only | ||
| 7324 | * counting user events. | ||
| 7325 | * To avoid leaking information to userspace, we must always | ||
| 7326 | * reject kernel samples when exclude_kernel is set. | ||
| 7327 | */ | ||
| 7328 | if (event->attr.exclude_kernel && !user_mode(regs)) | ||
| 7329 | return false; | ||
| 7330 | |||
| 7331 | return true; | ||
| 7332 | } | ||
| 7333 | |||
| 7319 | /* | 7334 | /* |
| 7320 | * Generic event overflow handling, sampling. | 7335 | * Generic event overflow handling, sampling. |
| 7321 | */ | 7336 | */ |
| @@ -7337,6 +7352,12 @@ static int __perf_event_overflow(struct perf_event *event, | |||
| 7337 | ret = __perf_event_account_interrupt(event, throttle); | 7352 | ret = __perf_event_account_interrupt(event, throttle); |
| 7338 | 7353 | ||
| 7339 | /* | 7354 | /* |
| 7355 | * For security, drop the skid kernel samples if necessary. | ||
| 7356 | */ | ||
| 7357 | if (!sample_is_allowed(event, regs)) | ||
| 7358 | return ret; | ||
| 7359 | |||
| 7360 | /* | ||
| 7340 | * XXX event_limit might not quite work as expected on inherited | 7361 | * XXX event_limit might not quite work as expected on inherited |
| 7341 | * events | 7362 | * events |
| 7342 | */ | 7363 | */ |
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt index e6c9902c6d82..165c2b1d4317 100644 --- a/tools/perf/Documentation/perf-probe.txt +++ b/tools/perf/Documentation/perf-probe.txt | |||
| @@ -240,9 +240,13 @@ Add a probe on schedule() function 12th line with recording cpu local variable: | |||
| 240 | or | 240 | or |
| 241 | ./perf probe --add='schedule:12 cpu' | 241 | ./perf probe --add='schedule:12 cpu' |
| 242 | 242 | ||
| 243 | this will add one or more probes which has the name start with "schedule". | 243 | Add one or more probes which has the name start with "schedule". |
| 244 | 244 | ||
| 245 | Add probes on lines in schedule() function which calls update_rq_clock(). | 245 | ./perf probe schedule* |
| 246 | or | ||
| 247 | ./perf probe --add='schedule*' | ||
| 248 | |||
| 249 | Add probes on lines in schedule() function which calls update_rq_clock(). | ||
| 246 | 250 | ||
| 247 | ./perf probe 'schedule;update_rq_clock*' | 251 | ./perf probe 'schedule;update_rq_clock*' |
| 248 | or | 252 | or |
diff --git a/tools/perf/Documentation/perf-script-perl.txt b/tools/perf/Documentation/perf-script-perl.txt index dfbb506d2c34..142606c0ec9c 100644 --- a/tools/perf/Documentation/perf-script-perl.txt +++ b/tools/perf/Documentation/perf-script-perl.txt | |||
| @@ -39,7 +39,7 @@ EVENT HANDLERS | |||
| 39 | When perf script is invoked using a trace script, a user-defined | 39 | When perf script is invoked using a trace script, a user-defined |
| 40 | 'handler function' is called for each event in the trace. If there's | 40 | 'handler function' is called for each event in the trace. If there's |
| 41 | no handler function defined for a given event type, the event is | 41 | no handler function defined for a given event type, the event is |
| 42 | ignored (or passed to a 'trace_handled' function, see below) and the | 42 | ignored (or passed to a 'trace_unhandled' function, see below) and the |
| 43 | next event is processed. | 43 | next event is processed. |
| 44 | 44 | ||
| 45 | Most of the event's field values are passed as arguments to the | 45 | Most of the event's field values are passed as arguments to the |
diff --git a/tools/perf/Documentation/perf-script-python.txt b/tools/perf/Documentation/perf-script-python.txt index 54acba221558..51ec2d20068a 100644 --- a/tools/perf/Documentation/perf-script-python.txt +++ b/tools/perf/Documentation/perf-script-python.txt | |||
| @@ -149,10 +149,8 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, | |||
| 149 | print "id=%d, args=%s\n" % \ | 149 | print "id=%d, args=%s\n" % \ |
| 150 | (id, args), | 150 | (id, args), |
| 151 | 151 | ||
| 152 | def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs, | 152 | def trace_unhandled(event_name, context, event_fields_dict): |
| 153 | common_pid, common_comm): | 153 | print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) |
| 154 | print_header(event_name, common_cpu, common_secs, common_nsecs, | ||
| 155 | common_pid, common_comm) | ||
| 156 | 154 | ||
| 157 | def print_header(event_name, cpu, secs, nsecs, pid, comm): | 155 | def print_header(event_name, cpu, secs, nsecs, pid, comm): |
| 158 | print "%-20s %5u %05u.%09u %8u %-20s " % \ | 156 | print "%-20s %5u %05u.%09u %8u %-20s " % \ |
| @@ -321,7 +319,7 @@ So those are the essential steps in writing and running a script. The | |||
| 321 | process can be generalized to any tracepoint or set of tracepoints | 319 | process can be generalized to any tracepoint or set of tracepoints |
| 322 | you're interested in - basically find the tracepoint(s) you're | 320 | you're interested in - basically find the tracepoint(s) you're |
| 323 | interested in by looking at the list of available events shown by | 321 | interested in by looking at the list of available events shown by |
| 324 | 'perf list' and/or look in /sys/kernel/debug/tracing events for | 322 | 'perf list' and/or look in /sys/kernel/debug/tracing/events/ for |
| 325 | detailed event and field info, record the corresponding trace data | 323 | detailed event and field info, record the corresponding trace data |
| 326 | using 'perf record', passing it the list of interesting events, | 324 | using 'perf record', passing it the list of interesting events, |
| 327 | generate a skeleton script using 'perf script -g python' and modify the | 325 | generate a skeleton script using 'perf script -g python' and modify the |
| @@ -334,7 +332,7 @@ right place, you can have your script listed alongside the other | |||
| 334 | scripts listed by the 'perf script -l' command e.g.: | 332 | scripts listed by the 'perf script -l' command e.g.: |
| 335 | 333 | ||
| 336 | ---- | 334 | ---- |
| 337 | root@tropicana:~# perf script -l | 335 | # perf script -l |
| 338 | List of available trace scripts: | 336 | List of available trace scripts: |
| 339 | wakeup-latency system-wide min/max/avg wakeup latency | 337 | wakeup-latency system-wide min/max/avg wakeup latency |
| 340 | rw-by-file <comm> r/w activity for a program, by file | 338 | rw-by-file <comm> r/w activity for a program, by file |
| @@ -383,8 +381,6 @@ source tree: | |||
| 383 | 381 | ||
| 384 | ---- | 382 | ---- |
| 385 | # ls -al kernel-source/tools/perf/scripts/python | 383 | # ls -al kernel-source/tools/perf/scripts/python |
| 386 | |||
| 387 | root@tropicana:/home/trz/src/tip# ls -al tools/perf/scripts/python | ||
| 388 | total 32 | 384 | total 32 |
| 389 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . | 385 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . |
| 390 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. | 386 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. |
| @@ -399,7 +395,7 @@ otherwise your script won't show up at run-time), 'perf script -l' | |||
| 399 | should show a new entry for your script: | 395 | should show a new entry for your script: |
| 400 | 396 | ||
| 401 | ---- | 397 | ---- |
| 402 | root@tropicana:~# perf script -l | 398 | # perf script -l |
| 403 | List of available trace scripts: | 399 | List of available trace scripts: |
| 404 | wakeup-latency system-wide min/max/avg wakeup latency | 400 | wakeup-latency system-wide min/max/avg wakeup latency |
| 405 | rw-by-file <comm> r/w activity for a program, by file | 401 | rw-by-file <comm> r/w activity for a program, by file |
| @@ -437,7 +433,7 @@ EVENT HANDLERS | |||
| 437 | When perf script is invoked using a trace script, a user-defined | 433 | When perf script is invoked using a trace script, a user-defined |
| 438 | 'handler function' is called for each event in the trace. If there's | 434 | 'handler function' is called for each event in the trace. If there's |
| 439 | no handler function defined for a given event type, the event is | 435 | no handler function defined for a given event type, the event is |
| 440 | ignored (or passed to a 'trace_handled' function, see below) and the | 436 | ignored (or passed to a 'trace_unhandled' function, see below) and the |
| 441 | next event is processed. | 437 | next event is processed. |
| 442 | 438 | ||
| 443 | Most of the event's field values are passed as arguments to the | 439 | Most of the event's field values are passed as arguments to the |
| @@ -532,7 +528,7 @@ can implement a set of optional functions: | |||
| 532 | gives scripts a chance to do setup tasks: | 528 | gives scripts a chance to do setup tasks: |
| 533 | 529 | ||
| 534 | ---- | 530 | ---- |
| 535 | def trace_begin: | 531 | def trace_begin(): |
| 536 | pass | 532 | pass |
| 537 | ---- | 533 | ---- |
| 538 | 534 | ||
| @@ -541,7 +537,7 @@ def trace_begin: | |||
| 541 | as display results: | 537 | as display results: |
| 542 | 538 | ||
| 543 | ---- | 539 | ---- |
| 544 | def trace_end: | 540 | def trace_end(): |
