1 #ifndef _LINUX_MARKER_H
2 #define _LINUX_MARKER_H
5 * Code markup for dynamic and static tracing.
7 * See Documentation/marker.txt.
9 * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
11 * This file is released under the GPLv2.
12 * See the file COPYING for more details.
15 #include <linux/types.h>
21 * marker_probe_func - Type of a marker probe function
22 * @probe_private: probe private data
23 * @call_private: call site private data
25 * @args: variable argument list pointer. Use a pointer to overcome C's
26 * inability to pass this around as a pointer in a portable manner in
27 * the callee otherwise.
29 * Type of marker probe functions. They receive the mdata and need to parse the
30 * format string to recover the variable argument list.
32 typedef void marker_probe_func(void *probe_private, void *call_private,
33 const char *fmt, va_list *args);
35 struct marker_probe_closure {
36 marker_probe_func *func; /* Callback */
37 void *probe_private; /* Private probe data */
41 const char *name; /* Marker name */
42 const char *format; /* Marker format string, describing the
43 * variable argument list.
45 char state; /* Marker state. */
46 char ptype; /* probe type : 0 : single, 1 : multi */
47 void (*call)(const struct marker *mdata, /* Probe wrapper */
48 void *call_private, const char *fmt, ...);
49 struct marker_probe_closure single;
50 struct marker_probe_closure *multi;
51 } __attribute__((aligned(8)));
56 * Note : the empty asm volatile with read constraint is used here instead of a
57 * "used" attribute to fix a gcc 4.1.x bug.
58 * Make sure the alignment of the structure in the __markers section will
59 * not add unwanted padding between the beginning of the section and the
60 * structure. Force alignment to the same alignment as the section start.
62 #define __trace_mark(name, call_private, format, args...) \
64 static const char __mstrtab_name_##name[] \
65 __attribute__((section("__markers_strings"))) \
67 static const char __mstrtab_format_##name[] \
68 __attribute__((section("__markers_strings"))) \
70 static struct marker __mark_##name \
71 __attribute__((section("__markers"), aligned(8))) = \
72 { __mstrtab_name_##name, __mstrtab_format_##name, \
73 0, 0, marker_probe_cb, \
74 { __mark_empty_function, NULL}, NULL }; \
75 __mark_check_format(format, ## args); \
76 if (unlikely(__mark_##name.state)) { \
77 (*__mark_##name.call) \
78 (&__mark_##name, call_private, \
83 extern void marker_update_probe_range(struct marker *begin,
85 #else /* !CONFIG_MARKERS */
86 #define __trace_mark(name, call_private, format, args...) \
87 __mark_check_format(format, ## args)
88 static inline void marker_update_probe_range(struct marker *begin,
91 #endif /* CONFIG_MARKERS */
95 * @name: marker name, not quoted.
96 * @format: format string
97 * @args...: variable argument list
101 #define trace_mark(name, format, args...) \
102 __trace_mark(name, NULL, format, ## args)
105 * MARK_NOARGS - Format string for a marker with no argument.
107 #define MARK_NOARGS " "
109 /* To be used for string format validity checking with gcc */
110 static inline void __printf(1, 2) __mark_check_format(const char *fmt, ...)
114 extern marker_probe_func __mark_empty_function;
116 extern void marker_probe_cb(const struct marker *mdata,
117 void *call_private, const char *fmt, ...);
118 extern void marker_probe_cb_noarg(const struct marker *mdata,
119 void *call_private, const char *fmt, ...);
122 * Connect a probe to a marker.
123 * private data pointer must be a valid allocated memory address, or NULL.
125 extern int marker_probe_register(const char *name, const char *format,
126 marker_probe_func *probe, void *probe_private);
129 * Returns the private data given to marker_probe_register.
131 extern int marker_probe_unregister(const char *name,
132 marker_probe_func *probe, void *probe_private);
134 * Unregister a marker by providing the registered private data.
136 extern int marker_probe_unregister_private_data(marker_probe_func *probe,
137 void *probe_private);
139 extern void *marker_get_private_data(const char *name, marker_probe_func *probe,