diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-22 19:35:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-22 19:35:21 -0500 |
commit | 60eaa0190f6b39dce18eb1975d9773ed8bc9a534 (patch) | |
tree | aef5a45a59af0f493fe44a267fc6333fb245dc2e /Documentation | |
parent | df32e43a54d04eda35d2859beaf90e3864d53288 (diff) | |
parent | 92fdd98cf8bdec4d6b0c510e2f073ac4fd059be8 (diff) |
Merge tag 'trace-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt:
"This pull request has a new feature to ftrace, namely the trace event
triggers by Tom Zanussi. A trigger is a way to enable an action when
an event is hit. The actions are:
o trace on/off - enable or disable tracing
o snapshot - save the current trace buffer in the snapshot
o stacktrace - dump the current stack trace to the ringbuffer
o enable/disable events - enable or disable another event
Namhyung Kim added updates to the tracing uprobes code. Having the
uprobes add support for fetch methods.
The rest are various bug fixes with the new code, and minor ones for
the old code"
* tag 'trace-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (38 commits)
tracing: Fix buggered tee(2) on tracing_pipe
tracing: Have trace buffer point back to trace_array
ftrace: Fix synchronization location disabling and freeing ftrace_ops
ftrace: Have function graph only trace based on global_ops filters
ftrace: Synchronize setting function_trace_op with ftrace_trace_function
tracing: Show available event triggers when no trigger is set
tracing: Consolidate event trigger code
tracing: Fix counter for traceon/off event triggers
tracing: Remove double-underscore naming in syscall trigger invocations
tracing/kprobes: Add trace event trigger invocations
tracing/probes: Fix build break on !CONFIG_KPROBE_EVENT
tracing/uprobes: Add @+file_offset fetch method
uprobes: Allocate ->utask before handler_chain() for tracing handlers
tracing/uprobes: Add support for full argument access methods
tracing/uprobes: Fetch args before reserving a ring buffer
tracing/uprobes: Pass 'is_return' to traceprobe_parse_probe_arg()
tracing/probes: Implement 'memory' fetch method for uprobes
tracing/probes: Add fetch{,_size} member into deref fetch method
tracing/probes: Move 'symbol' fetch method to kprobes
tracing/probes: Implement 'stack' fetch method for uprobes
...
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/trace/events.txt | 207 | ||||
-rw-r--r-- | Documentation/trace/uprobetracer.txt | 36 |
2 files changed, 238 insertions, 5 deletions
diff --git a/Documentation/trace/events.txt b/Documentation/trace/events.txt index 37732a220d33..c94435df2037 100644 --- a/Documentation/trace/events.txt +++ b/Documentation/trace/events.txt | |||
@@ -287,3 +287,210 @@ their old filters): | |||
287 | prev_pid == 0 | 287 | prev_pid == 0 |
288 | # cat sched_wakeup/filter | 288 | # cat sched_wakeup/filter |
289 | common_pid == 0 | 289 | common_pid == 0 |
290 | |||
291 | 6. Event triggers | ||
292 | ================= | ||
293 | |||
294 | Trace events can be made to conditionally invoke trigger 'commands' | ||
295 | which can take various forms and are described in detail below; | ||
296 | examples would be enabling or disabling other trace events or invoking | ||
297 | a stack trace whenever the trace event is hit. Whenever a trace event | ||
298 | with attached triggers is invoked, the set of trigger commands | ||
299 | associated with that event is invoked. Any given trigger can | ||
300 | additionally have an event filter of the same form as described in | ||
301 | section 5 (Event filtering) associated with it - the command will only | ||
302 | be invoked if the event being invoked passes the associated filter. | ||
303 | If no filter is associated with the trigger, it always passes. | ||
304 | |||
305 | Triggers are added to and removed from a particular event by writing | ||
306 | trigger expressions to the 'trigger' file for the given event. | ||
307 | |||
308 | A given event can have any number of triggers associated with it, | ||
309 | subject to any restrictions that individual commands may have in that | ||
310 | regard. | ||
311 | |||
312 | Event triggers are implemented on top of "soft" mode, which means that | ||
313 | whenever a trace event has one or more triggers associated with it, | ||
314 | the event is activated even if it isn't actually enabled, but is | ||
315 | disabled in a "soft" mode. That is, the tracepoint will be called, | ||
316 | but just will not be traced, unless of course it's actually enabled. | ||
317 | This scheme allows triggers to be invoked even for events that aren't | ||
318 | enabled, and also allows the current event filter implementation to be | ||
319 | used for conditionally invoking triggers. | ||
320 | |||
321 | The syntax for event triggers is roughly based on the syntax for | ||
322 | set_ftrace_filter 'ftrace filter commands' (see the 'Filter commands' | ||
323 | section of Documentation/trace/ftrace.txt), but there are major | ||
324 | differences and the implementation isn't currently tied to it in any | ||
325 | way, so beware about making generalizations between the two. | ||
326 | |||
327 | 6.1 Expression syntax | ||
328 | --------------------- | ||
329 | |||
330 | Triggers are added by echoing the command to the 'trigger' file: | ||
331 | |||
332 | # echo 'command[:count] [if filter]' > trigger | ||
333 | |||
334 | Triggers are removed by echoing the same command but starting with '!' | ||
335 | to the 'trigger' file: | ||
336 | |||
337 | # echo '!command[:count] [if filter]' > trigger | ||
338 | |||
339 | The [if filter] part isn't used in matching commands when removing, so | ||
340 | leaving that off in a '!' command will accomplish the same thing as | ||
341 | having it in. | ||
342 | |||
343 | The filter syntax is the same as that described in the 'Event | ||
344 | filtering' section above. | ||
345 | |||
346 | For ease of use, writing to the trigger file using '>' currently just | ||
347 | adds or removes a single trigger and there's no explicit '>>' support | ||
348 | ('>' actually behaves like '>>') or truncation support to remove all | ||
349 | triggers (you have to use '!' for each one added.) | ||
350 | |||
351 | 6.2 Supported trigger commands | ||
352 | ------------------------------ | ||
353 | |||
354 | The following commands are supported: | ||
355 | |||
356 | - enable_event/disable_event | ||
357 | |||
358 | These commands can enable or disable another trace event whenever | ||
359 | the triggering event is hit. When these commands are registered, | ||
360 | the other trace event is activated, but disabled in a "soft" mode. | ||
361 | That is, the tracepoint will be called, but just will not be traced. | ||
362 | The event tracepoint stays in this mode as long as there's a trigger | ||
363 | in effect that can trigger it. | ||
364 | |||
365 | For example, the following trigger causes kmalloc events to be | ||
366 | traced when a read system call is entered, and the :1 at the end | ||
367 | specifies that this enablement happens only once: | ||
368 | |||
369 | # echo 'enable_event:kmem:kmalloc:1' > \ | ||
370 | /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/trigger | ||
371 | |||
372 | The following trigger causes kmalloc events to stop being traced | ||
373 | when a read system call exits. This disablement happens on every | ||
374 | read system call exit: | ||
375 | |||
376 | # echo 'disable_event:kmem:kmalloc' > \ | ||
377 | /sys/kernel/debug/tracing/events/syscalls/sys_exit_read/trigger | ||
378 | |||
379 | The format is: | ||
380 | |||
381 | enable_event:<system>:<event>[:count] | ||
382 | disable_event:<system>:<event>[:count] | ||
383 | |||
384 | To remove the above commands: | ||
385 | |||
386 | # echo '!enable_event:kmem:kmalloc:1' > \ | ||
387 | /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/trigger | ||
388 | |||
389 | # echo '!disable_event:kmem:kmalloc' > \ | ||
390 | /sys/kernel/debug/tracing/events/syscalls/sys_exit_read/trigger | ||
391 | |||
392 | Note that there can be any number of enable/disable_event triggers | ||
393 | per triggering event, but there can only be one trigger per | ||
394 | triggered event. e.g. sys_enter_read can have triggers enabling both | ||
395 | kmem:kmalloc and sched:sched_switch, but can't have two kmem:kmalloc | ||
396 | versions such as kmem:kmalloc and kmem:kmalloc:1 or 'kmem:kmalloc if | ||
397 | bytes_req == 256' and 'kmem:kmalloc if bytes_alloc == 256' (they | ||
398 | could be combined into a single filter on kmem:kmalloc though). | ||
399 | |||
400 | - stacktrace | ||
401 | |||
402 | This command dumps a stacktrace in the trace buffer whenever the | ||
403 | triggering event occurs. | ||
404 | |||
405 | For example, the following trigger dumps a stacktrace every time the | ||
406 | kmalloc tracepoint is hit: | ||
407 | |||
408 | # echo 'stacktrace' > \ | ||
409 | /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger | ||
410 | |||
411 | The following trigger dumps a stacktrace the first 5 times a kmalloc | ||
412 | request happens with a size >= 64K | ||
413 | |||
414 | # echo 'stacktrace:5 if bytes_req >= 65536' > \ | ||
415 | /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger | ||
416 | |||
417 | The format is: | ||
418 | |||
419 | stacktrace[:count] | ||
420 | |||
421 | To remove the above commands: | ||
422 | |||
423 | # echo '!stacktrace' > \ | ||
424 | /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger | ||
425 | |||
426 | # echo '!stacktrace:5 if bytes_req >= 65536' > \ | ||
427 | /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger | ||
428 | |||
429 | The latter can also be removed more simply by the following (without | ||
430 | the filter): | ||
431 | |||
432 | # echo '!stacktrace:5' > \ | ||
433 | /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger | ||
434 | |||
435 | Note that there can be only one stacktrace trigger per triggering | ||
436 | event. | ||
437 | |||
438 | - snapshot | ||
439 | |||
440 | This command causes a snapshot to be triggered whenever the | ||
441 | triggering event occurs. | ||
442 | |||
443 | The following command creates a snapshot every time a block request | ||
444 | queue is unplugged with a depth > 1. If you were tracing a set of | ||
445 | events or functions at the time, the snapshot trace buffer would | ||
446 | capture those events when the trigger event occured: | ||
447 | |||
448 | # echo 'snapshot if nr_rq > 1' > \ | ||
449 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
450 | |||
451 | To only snapshot once: | ||
452 | |||
453 | # echo 'snapshot:1 if nr_rq > 1' > \ | ||
454 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
455 | |||
456 | To remove the above commands: | ||
457 | |||
458 | # echo '!snapshot if nr_rq > 1' > \ | ||
459 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
460 | |||
461 | # echo '!snapshot:1 if nr_rq > 1' > \ | ||
462 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
463 | |||
464 | Note that there can be only one snapshot trigger per triggering | ||
465 | event. | ||
466 | |||
467 | - traceon/traceoff | ||
468 | |||
469 | These commands turn tracing on and off when the specified events are | ||
470 | hit. The parameter determines how many times the tracing system is | ||
471 | turned on and off. If unspecified, there is no limit. | ||
472 | |||
473 | The following command turns tracing off the first time a block | ||
474 | request queue is unplugged with a depth > 1. If you were tracing a | ||
475 | set of events or functions at the time, you could then examine the | ||
476 | trace buffer to see the sequence of events that led up to the | ||
477 | trigger event: | ||
478 | |||
479 | # echo 'traceoff:1 if nr_rq > 1' > \ | ||
480 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
481 | |||
482 | To always disable tracing when nr_rq > 1 : | ||
483 | |||
484 | # echo 'traceoff if nr_rq > 1' > \ | ||
485 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
486 | |||
487 | To remove the above commands: | ||
488 | |||
489 | # echo '!traceoff:1 if nr_rq > 1' > \ | ||
490 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
491 | |||
492 | # echo '!traceoff if nr_rq > 1' > \ | ||
493 | /sys/kernel/debug/tracing/events/block/block_unplug/trigger | ||
494 | |||
495 | Note that there can be only one traceon or traceoff trigger per | ||
496 | triggering event. | ||
diff --git a/Documentation/trace/uprobetracer.txt b/Documentation/trace/uprobetracer.txt index d9c3e682312c..f1cf9a34ad9d 100644 --- a/Documentation/trace/uprobetracer.txt +++ b/Documentation/trace/uprobetracer.txt | |||
@@ -19,18 +19,44 @@ user to calculate the offset of the probepoint in the object. | |||
19 | 19 | ||
20 | Synopsis of uprobe_tracer | 20 | Synopsis of uprobe_tracer |
21 | ------------------------- | 21 | ------------------------- |
22 | p[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS] : Set a uprobe | 22 | p[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a uprobe |
23 | r[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS] : Set a return uprobe (uretprobe) | 23 | r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe) |
24 | -:[GRP/]EVENT : Clear uprobe or uretprobe event | 24 | -:[GRP/]EVENT : Clear uprobe or uretprobe event |
25 | 25 | ||
26 | GRP : Group name. If omitted, "uprobes" is the default value. | 26 | GRP : Group name. If omitted, "uprobes" is the default value. |
27 | EVENT : Event name. If omitted, the event name is generated based | 27 | EVENT : Event name. If omitted, the event name is generated based |
28 | on SYMBOL+offs. | 28 | on PATH+OFFSET. |
29 | PATH : Path to an executable or a library. | 29 | PATH : Path to an executable or a library. |
30 | SYMBOL[+offs] : Symbol+offset where the probe is inserted. | 30 | OFFSET : Offset where the probe is inserted. |
31 | 31 | ||
32 | FETCHARGS : Arguments. Each probe can have up to 128 args. | 32 | FETCHARGS : Arguments. Each probe can have up to 128 args. |
33 | %REG : Fetch register REG | 33 | %REG : Fetch register REG |
34 | @ADDR : Fetch memory at ADDR (ADDR should be in userspace) | ||
35 | @+OFFSET : Fetch memory at OFFSET (OFFSET from same file as PATH) | ||
36 | $stackN : Fetch Nth entry of stack (N >= 0) | ||
37 | $stack : Fetch stack address. | ||
38 | $retval : Fetch return value.(*) | ||
39 | +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**) | ||
40 | NAME=FETCHARG : Set NAME as the argument name of FETCHARG. | ||
41 | FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types | ||
42 | (u8/u16/u32/u64/s8/s16/s32/s64), "string" and bitfield | ||
43 | are supported. | ||
44 | |||
45 | (*) only for return probe. | ||
46 | (**) this is useful for fetching a field of data structures. | ||
47 | |||
48 | Types | ||
49 | ----- | ||
50 | Several types are supported for fetch-args. Uprobe tracer will access memory | ||
51 | by given type. Prefix 's' and 'u' means those types are signed and unsigned | ||
52 | respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). | ||
53 | String type is a special type, which fetches a "null-terminated" string from | ||
54 | user space. | ||
55 | Bitfield is another special type, which takes 3 parameters, bit-width, bit- | ||
56 | offset, and container-size (usually 32). The syntax is; | ||
57 | |||
58 | b<bit-width>@<bit-offset>/<container-size> | ||
59 | |||
34 | 60 | ||
35 | Event Profiling | 61 | Event Profiling |
36 | --------------- | 62 | --------------- |