blob: 90e8b3383ba247c67cfd5040f7a7874182d2ee60 [file] [log] [blame]
Theodore Ts'oabd41442009-04-11 15:51:18 -04001 Event Tracing
2
3 Documentation written by Theodore Ts'o
Li Zefan143c1452009-05-19 14:43:15 +08004 Updated by Li Zefan
Theodore Ts'oabd41442009-04-11 15:51:18 -04005
Li Zefan143c1452009-05-19 14:43:15 +080061. Introduction
7===============
Theodore Ts'oabd41442009-04-11 15:51:18 -04008
9Tracepoints (see Documentation/trace/tracepoints.txt) can be used
10without creating custom kernel modules to register probe functions
11using the event tracing infrastructure.
12
13Not all tracepoints can be traced using the event tracing system;
14the kernel developer must provide code snippets which define how the
15tracing information is saved into the tracing buffer, and how the
Li Zefan143c1452009-05-19 14:43:15 +080016tracing information should be printed.
Theodore Ts'oabd41442009-04-11 15:51:18 -040017
Li Zefan143c1452009-05-19 14:43:15 +0800182. Using Event Tracing
19======================
20
212.1 Via the 'set_event' interface
22---------------------------------
Theodore Ts'oabd41442009-04-11 15:51:18 -040023
24The events which are available for tracing can be found in the file
GeunSik Lim52ad51e2009-09-07 21:37:17 +090025/sys/kernel/debug/tracing/available_events.
Theodore Ts'oabd41442009-04-11 15:51:18 -040026
27To enable a particular event, such as 'sched_wakeup', simply echo it
GeunSik Lim52ad51e2009-09-07 21:37:17 +090028to /sys/kernel/debug/tracing/set_event. For example:
Theodore Ts'oabd41442009-04-11 15:51:18 -040029
GeunSik Lim52ad51e2009-09-07 21:37:17 +090030 # echo sched_wakeup >> /sys/kernel/debug/tracing/set_event
Theodore Ts'oabd41442009-04-11 15:51:18 -040031
Li Zefan143c1452009-05-19 14:43:15 +080032[ Note: '>>' is necessary, otherwise it will firstly disable
33 all the events. ]
Theodore Ts'oabd41442009-04-11 15:51:18 -040034
35To disable an event, echo the event name to the set_event file prefixed
36with an exclamation point:
37
GeunSik Lim52ad51e2009-09-07 21:37:17 +090038 # echo '!sched_wakeup' >> /sys/kernel/debug/tracing/set_event
Theodore Ts'oabd41442009-04-11 15:51:18 -040039
Li Zefan143c1452009-05-19 14:43:15 +080040To disable all events, echo an empty line to the set_event file:
Theodore Ts'oabd41442009-04-11 15:51:18 -040041
GeunSik Lim52ad51e2009-09-07 21:37:17 +090042 # echo > /sys/kernel/debug/tracing/set_event
Li Zefan143c1452009-05-19 14:43:15 +080043
44To enable all events, echo '*:*' or '*:' to the set_event file:
45
GeunSik Lim52ad51e2009-09-07 21:37:17 +090046 # echo *:* > /sys/kernel/debug/tracing/set_event
Theodore Ts'oabd41442009-04-11 15:51:18 -040047
48The events are organized into subsystems, such as ext4, irq, sched,
49etc., and a full event name looks like this: <subsystem>:<event>. The
50subsystem name is optional, but it is displayed in the available_events
51file. All of the events in a subsystem can be specified via the syntax
52"<subsystem>:*"; for example, to enable all irq events, you can use the
53command:
54
GeunSik Lim52ad51e2009-09-07 21:37:17 +090055 # echo 'irq:*' > /sys/kernel/debug/tracing/set_event
Theodore Ts'oabd41442009-04-11 15:51:18 -040056
Li Zefan143c1452009-05-19 14:43:15 +0800572.2 Via the 'enable' toggle
58---------------------------
Theodore Ts'oabd41442009-04-11 15:51:18 -040059
GeunSik Lim52ad51e2009-09-07 21:37:17 +090060The events available are also listed in /sys/kernel/debug/tracing/events/ hierarchy
Li Zefan143c1452009-05-19 14:43:15 +080061of directories.
Theodore Ts'oabd41442009-04-11 15:51:18 -040062
Li Zefan143c1452009-05-19 14:43:15 +080063To enable event 'sched_wakeup':
Theodore Ts'oabd41442009-04-11 15:51:18 -040064
GeunSik Lim52ad51e2009-09-07 21:37:17 +090065 # echo 1 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
Theodore Ts'oabd41442009-04-11 15:51:18 -040066
Li Zefan143c1452009-05-19 14:43:15 +080067To disable it:
Theodore Ts'oabd41442009-04-11 15:51:18 -040068
GeunSik Lim52ad51e2009-09-07 21:37:17 +090069 # echo 0 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
Theodore Ts'oabd41442009-04-11 15:51:18 -040070
Li Zefan143c1452009-05-19 14:43:15 +080071To enable all events in sched subsystem:
Theodore Ts'oabd41442009-04-11 15:51:18 -040072
GeunSik Lim52ad51e2009-09-07 21:37:17 +090073 # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
Theodore Ts'oabd41442009-04-11 15:51:18 -040074
Li Zefan143c1452009-05-19 14:43:15 +080075To eanble all events:
Theodore Ts'oabd41442009-04-11 15:51:18 -040076
GeunSik Lim52ad51e2009-09-07 21:37:17 +090077 # echo 1 > /sys/kernel/debug/tracing/events/enable
Theodore Ts'oabd41442009-04-11 15:51:18 -040078
Li Zefan143c1452009-05-19 14:43:15 +080079When reading one of these enable files, there are four results:
Theodore Ts'oabd41442009-04-11 15:51:18 -040080
Li Zefan143c1452009-05-19 14:43:15 +080081 0 - all events this file affects are disabled
82 1 - all events this file affects are enabled
83 X - there is a mixture of events enabled and disabled
84 ? - this file does not affect any event
Theodore Ts'oabd41442009-04-11 15:51:18 -040085
Li Zefan020e5f82009-07-01 10:47:05 +0800862.3 Boot option
87---------------
88
89In order to facilitate early boot debugging, use boot option:
90
91 trace_event=[event-list]
92
93The format of this boot option is the same as described in section 2.1.
94
Li Zefan143c1452009-05-19 14:43:15 +0800953. Defining an event-enabled tracepoint
96=======================================
Theodore Ts'oabd41442009-04-11 15:51:18 -040097
Li Zefan143c1452009-05-19 14:43:15 +080098See The example provided in samples/trace_events
Theodore Ts'oabd41442009-04-11 15:51:18 -040099