events.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Event Tracing
  2. Documentation written by Theodore Ts'o
  3. Updated by Li Zefan
  4. 1. Introduction
  5. ===============
  6. Tracepoints (see Documentation/trace/tracepoints.txt) can be used
  7. without creating custom kernel modules to register probe functions
  8. using the event tracing infrastructure.
  9. Not all tracepoints can be traced using the event tracing system;
  10. the kernel developer must provide code snippets which define how the
  11. tracing information is saved into the tracing buffer, and how the
  12. tracing information should be printed.
  13. 2. Using Event Tracing
  14. ======================
  15. 2.1 Via the 'set_event' interface
  16. ---------------------------------
  17. The events which are available for tracing can be found in the file
  18. /debug/tracing/available_events.
  19. To enable a particular event, such as 'sched_wakeup', simply echo it
  20. to /debug/tracing/set_event. For example:
  21. # echo sched_wakeup >> /debug/tracing/set_event
  22. [ Note: '>>' is necessary, otherwise it will firstly disable
  23. all the events. ]
  24. To disable an event, echo the event name to the set_event file prefixed
  25. with an exclamation point:
  26. # echo '!sched_wakeup' >> /debug/tracing/set_event
  27. To disable all events, echo an empty line to the set_event file:
  28. # echo > /debug/tracing/set_event
  29. To enable all events, echo '*:*' or '*:' to the set_event file:
  30. # echo *:* > /debug/tracing/set_event
  31. The events are organized into subsystems, such as ext4, irq, sched,
  32. etc., and a full event name looks like this: <subsystem>:<event>. The
  33. subsystem name is optional, but it is displayed in the available_events
  34. file. All of the events in a subsystem can be specified via the syntax
  35. "<subsystem>:*"; for example, to enable all irq events, you can use the
  36. command:
  37. # echo 'irq:*' > /debug/tracing/set_event
  38. 2.2 Via the 'enable' toggle
  39. ---------------------------
  40. The events available are also listed in /debug/tracing/events/ hierarchy
  41. of directories.
  42. To enable event 'sched_wakeup':
  43. # echo 1 > /debug/tracing/events/sched/sched_wakeup/enable
  44. To disable it:
  45. # echo 0 > /debug/tracing/events/sched/sched_wakeup/enable
  46. To enable all events in sched subsystem:
  47. # echo 1 > /debug/tracing/events/sched/enable
  48. To eanble all events:
  49. # echo 1 > /debug/tracing/events/enable
  50. When reading one of these enable files, there are four results:
  51. 0 - all events this file affects are disabled
  52. 1 - all events this file affects are enabled
  53. X - there is a mixture of events enabled and disabled
  54. ? - this file does not affect any event
  55. 3. Defining an event-enabled tracepoint
  56. =======================================
  57. See The example provided in samples/trace_events