Skip to contentSkip to conversation

ftrace: trace markers

PATCH In review Lai Jiangshan 1 participant 1 message Dec 31, 2008 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 ftrace: trace markers

Impact: enable ftrace to trace markers

create <debugfs-dir>/tracing/tracing_markers.

Use binary printk for trace markers.

Active a tracing marker:
echo -n '<marker name>' > tracing_markers echo -n '<marker name>:<format>' > tracing_markers
Deactive a tracing marker:
echo -n '!<marker name>' > tracing_markers
Show all active and dead tracing markers:
cat tracing_markers

A dead tracing markers is a tracing marker which have been deactived, but tracing buffer may still have log information about this tracing marker, so we must keep this tracing marker which we call it "(dead)".

example:
echo events > current_tracer

# active a marker in kernel/marker.c:add_marker():
echo -n 'core_marker_format:name %s format %s' > tracing_markers
# trigger marker "core_marker_format":
echo -n "test_name:test_fmt" > tracing_markers # will call add_marker()
echo -n "XXXXXXX:YYYYYYYY" > tracing_markers   # will call add_marker()

cat trace
...
<...>-24693 [001] 4154504421.945769: 0: core_marker_format:name test_name format test_fmt
...
<...>-24693 [001] 4154504567.229737: 0: core_marker_format:name XXXXXXX format YYYYYYYY
...

---
 trace.c         |    7 +
 trace.h         |    3
 trace_bprintk.c |  239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
kernel/trace/trace.c +7 -0
index 085cc8a..d0b9fa1 100644
@@ -2950,6 +2950,13 @@ static __init int tracer_init_debugfs(void)
 	if (!entry)
 		pr_warning("Could not create debugfs "
 			   "'trace_bprintk_formats' entry\n");
+#if CONFIG_MARKERS
+	entry = debugfs_create_file("tracing_markers", 0644, d_tracer,
+				    NULL, &trace_markers_fops);
+	if (!entry)
+		pr_warning("Could not create debugfs "
+			   "'tracing_markers' entry\n");
+#endif
 #endif
 
 #ifdef CONFIG_DYNAMIC_FTRACE
kernel/trace/trace.h +3 -0
index c50826d..f04ae8b 100644
@@ -130,6 +130,9 @@ struct bprintk_entry {
 #ifdef CONFIG_TRACE_BPRINTK
 extern struct file_operations trace_bprintk_fmt_fops;
 extern int trace_bprintk_enable;
+#ifdef CONFIG_MARKERS
+extern struct file_operations trace_markers_fops;
+#endif
 #endif
 
 #define TRACE_OLD_SIZE		88
kernel/trace/trace_bprintk.c +239 -0

257 lines not on this page · raw message