blob: f157d7594ea7c2bdf991b25f84b5580acec505e3 [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
Li Zefan143c1452009-05-19 14:43:15 +080025/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
Li Zefan143c1452009-05-19 14:43:15 +080028to /debug/tracing/set_event. For example:
Theodore Ts'oabd41442009-04-11 15:51:18 -040029
Li Zefan143c1452009-05-19 14:43:15 +080030 # echo sched_wakeup >> /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
Li Zefan143c1452009-05-19 14:43:15 +080038 # echo '!sched_wakeup' >> /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
Li Zefan143c1452009-05-19 14:43:15 +080042 # echo > /debug/tracing/set_event
43
44To enable all events, echo '*:*' or '*:' to the set_event file:
45
46 # echo *:* > /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
Li Zefan143c1452009-05-19 14:43:15 +080055 # echo 'irq:*' > /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
Li Zefan143c1452009-05-19 14:43:15 +080060The events available are also listed in /debug/tracing/events/ hierarchy
61of 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
Li Zefan143c1452009-05-19 14:43:15 +080065 # echo 1 > /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
Li Zefan143c1452009-05-19 14:43:15 +080069 # echo 0 > /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
Li Zefan143c1452009-05-19 14:43:15 +080073 # echo 1 > /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
Li Zefan143c1452009-05-19 14:43:15 +080077 # echo 1 > /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 Zefan143c1452009-05-19 14:43:15 +0800863. Defining an event-enabled tracepoint
87=======================================
Theodore Ts'oabd41442009-04-11 15:51:18 -040088
Li Zefan143c1452009-05-19 14:43:15 +080089See The example provided in samples/trace_events
Theodore Ts'oabd41442009-04-11 15:51:18 -040090