events.txt 2.9 KB
Newer Older
1 2 3
			     Event Tracing

		Documentation written by Theodore Ts'o
L
Li Zefan 已提交
4
			Updated by Li Zefan
5

L
Li Zefan 已提交
6 7
1. Introduction
===============
8 9 10 11 12 13 14 15

Tracepoints (see Documentation/trace/tracepoints.txt) can be used
without creating custom kernel modules to register probe functions
using the event tracing infrastructure.

Not all tracepoints can be traced using the event tracing system;
the kernel developer must provide code snippets which define how the
tracing information is saved into the tracing buffer, and how the
L
Li Zefan 已提交
16
tracing information should be printed.
17

L
Li Zefan 已提交
18 19 20 21 22
2. Using Event Tracing
======================

2.1 Via the 'set_event' interface
---------------------------------
23 24

The events which are available for tracing can be found in the file
25
/sys/kernel/debug/tracing/available_events.
26 27

To enable a particular event, such as 'sched_wakeup', simply echo it
28
to /sys/kernel/debug/tracing/set_event. For example:
29

30
	# echo sched_wakeup >> /sys/kernel/debug/tracing/set_event
31

L
Li Zefan 已提交
32 33
[ Note: '>>' is necessary, otherwise it will firstly disable
  all the events. ]
34 35 36 37

To disable an event, echo the event name to the set_event file prefixed
with an exclamation point:

38
	# echo '!sched_wakeup' >> /sys/kernel/debug/tracing/set_event
L
Li Zefan 已提交
39 40 41

To disable all events, echo an empty line to the set_event file:

42
	# echo > /sys/kernel/debug/tracing/set_event
43

L
Li Zefan 已提交
44
To enable all events, echo '*:*' or '*:' to the set_event file:
45

46
	# echo *:* > /sys/kernel/debug/tracing/set_event
47 48 49 50 51 52 53 54

The events are organized into subsystems, such as ext4, irq, sched,
etc., and a full event name looks like this: <subsystem>:<event>.  The
subsystem name is optional, but it is displayed in the available_events
file.  All of the events in a subsystem can be specified via the syntax
"<subsystem>:*"; for example, to enable all irq events, you can use the
command:

55
	# echo 'irq:*' > /sys/kernel/debug/tracing/set_event
L
Li Zefan 已提交
56 57 58 59

2.2 Via the 'enable' toggle
---------------------------

60
The events available are also listed in /sys/kernel/debug/tracing/events/ hierarchy
L
Li Zefan 已提交
61 62 63 64
of directories.

To enable event 'sched_wakeup':

65
	# echo 1 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
L
Li Zefan 已提交
66 67 68

To disable it:

69
	# echo 0 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
L
Li Zefan 已提交
70 71 72

To enable all events in sched subsystem:

73
	# echo 1 > /sys/kernel/debug/tracing/events/sched/enable
L
Li Zefan 已提交
74 75 76

To eanble all events:

77
	# echo 1 > /sys/kernel/debug/tracing/events/enable
L
Li Zefan 已提交
78 79 80 81 82 83 84 85

When reading one of these enable files, there are four results:

 0 - all events this file affects are disabled
 1 - all events this file affects are enabled
 X - there is a mixture of events enabled and disabled
 ? - this file does not affect any event

86 87 88 89 90 91 92 93 94
2.3 Boot option
---------------

In order to facilitate early boot debugging, use boot option:

	trace_event=[event-list]

The format of this boot option is the same as described in section 2.1.

L
Li Zefan 已提交
95 96 97 98 99
3. Defining an event-enabled tracepoint
=======================================

See The example provided in samples/trace_events