1#ifndef _LINUX_MARKER_H
2#define _LINUX_MARKER_H
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/types.h>
16
17struct module;
18struct marker;
19
20
21
22
23
24
25
26
27
28
29
30
31
32typedef void marker_probe_func(void *probe_private, void *call_private,
33 const char *fmt, va_list *args);
34
35struct marker_probe_closure {
36 marker_probe_func *func;
37 void *probe_private;
38};
39
40struct marker {
41 const char *name;
42 const char *format;
43
44
45 char state;
46 char ptype;
47
48 void (*call)(const struct marker *mdata, void *call_private, ...);
49 struct marker_probe_closure single;
50 struct marker_probe_closure *multi;
51} __attribute__((aligned(8)));
52
53#ifdef CONFIG_MARKERS
54
55
56
57
58
59
60
61
62
63
64
65
66#define __trace_mark(generic, name, call_private, format, args...) \
67 do { \
68 static const char __mstrtab_##name[] \
69 __attribute__((section("__markers_strings"))) \
70 = #name "\0" format; \
71 static struct marker __mark_##name \
72 __attribute__((section("__markers"), aligned(8))) = \
73 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
74 0, 0, marker_probe_cb, \
75 { __mark_empty_function, NULL}, NULL }; \
76 __mark_check_format(format, ## args); \
77 if (unlikely(__mark_##name.state)) { \
78 (*__mark_##name.call) \
79 (&__mark_##name, call_private, ## args);\
80 } \
81 } while (0)
82
83extern void marker_update_probe_range(struct marker *begin,
84 struct marker *end);
85#else
86#define __trace_mark(generic, name, call_private, format, args...) \
87 __mark_check_format(format, ## args)
88static inline void marker_update_probe_range(struct marker *begin,
89 struct marker *end)
90{ }
91#endif
92
93
94
95
96
97
98
99
100
101
102#define trace_mark(name, format, args...) \
103 __trace_mark(0, name, NULL, format, ## args)
104
105
106
107
108
109
110
111
112
113
114
115
116#define _trace_mark(name, format, args...) \
117 __trace_mark(1, name, NULL, format, ## args)
118
119
120
121
122#define MARK_NOARGS " "
123
124
125static inline void __printf(1, 2) ___mark_check_format(const char *fmt, ...)
126{
127}
128
129#define __mark_check_format(format, args...) \
130 do { \
131 if (0) \
132 ___mark_check_format(format, ## args); \
133 } while (0)
134
135extern marker_probe_func __mark_empty_function;
136
137extern void marker_probe_cb(const struct marker *mdata,
138 void *call_private, ...);
139extern void marker_probe_cb_noarg(const struct marker *mdata,
140 void *call_private, ...);
141
142
143
144
145
146extern int marker_probe_register(const char *name, const char *format,
147 marker_probe_func *probe, void *probe_private);
148
149
150
151
152extern int marker_probe_unregister(const char *name,
153 marker_probe_func *probe, void *probe_private);
154
155
156
157extern int marker_probe_unregister_private_data(marker_probe_func *probe,
158 void *probe_private);
159
160extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
161 int num);
162
163#endif
164