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 void (*call)(const struct marker *mdata,
48 void *call_private, const char *fmt, ...);
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#define __trace_mark(name, call_private, format, args...) \
63 do { \
64 static const char __mstrtab_##name[] \
65 __attribute__((section("__markers_strings"))) \
66 = #name "\0" format; \
67 static struct marker __mark_##name \
68 __attribute__((section("__markers"), aligned(8))) = \
69 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
70 0, 0, marker_probe_cb, \
71 { __mark_empty_function, NULL}, NULL }; \
72 __mark_check_format(format, ## args); \
73 if (unlikely(__mark_##name.state)) { \
74 (*__mark_##name.call) \
75 (&__mark_##name, call_private, \
76 format, ## args); \
77 } \
78 } while (0)
79
80extern void marker_update_probe_range(struct marker *begin,
81 struct marker *end);
82#else
83#define __trace_mark(name, call_private, format, args...) \
84 __mark_check_format(format, ## args)
85static inline void marker_update_probe_range(struct marker *begin,
86 struct marker *end)
87{ }
88#endif
89
90
91
92
93
94
95
96
97
98#define trace_mark(name, format, args...) \
99 __trace_mark(name, NULL, format, ## args)
100
101
102
103
104#define MARK_NOARGS " "
105
106
107static inline void __printf(1, 2) ___mark_check_format(const char *fmt, ...)
108{
109}
110
111#define __mark_check_format(format, args...) \
112 do { \
113 if (0) \
114 ___mark_check_format(format, ## args); \
115 } while (0)
116
117extern marker_probe_func __mark_empty_function;
118
119extern void marker_probe_cb(const struct marker *mdata,
120 void *call_private, const char *fmt, ...);
121extern void marker_probe_cb_noarg(const struct marker *mdata,
122 void *call_private, const char *fmt, ...);
123
124
125
126
127
128extern int marker_probe_register(const char *name, const char *format,
129 marker_probe_func *probe, void *probe_private);
130
131
132
133
134extern int marker_probe_unregister(const char *name,
135 marker_probe_func *probe, void *probe_private);
136
137
138
139extern int marker_probe_unregister_private_data(marker_probe_func *probe,
140 void *probe_private);
141
142extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
143 int num);
144
145#endif
146