aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/marker.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/marker.h')
-rw-r--r--include/linux/marker.h68
1 files changed, 39 insertions, 29 deletions
diff --git a/include/linux/marker.h b/include/linux/marker.h
index 5f36cf946bcb..5df879dc3776 100644
--- a/include/linux/marker.h
+++ b/include/linux/marker.h
@@ -19,16 +19,23 @@ struct marker;
19 19
20/** 20/**
21 * marker_probe_func - Type of a marker probe function 21 * marker_probe_func - Type of a marker probe function
22 * @mdata: pointer of type struct marker 22 * @probe_private: probe private data
23 * @private_data: caller site private data 23 * @call_private: call site private data
24 * @fmt: format string 24 * @fmt: format string
25 * @...: variable argument list 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.
26 * 28 *
27 * Type of marker probe functions. They receive the mdata and need to parse the 29 * Type of marker probe functions. They receive the mdata and need to parse the
28 * format string to recover the variable argument list. 30 * format string to recover the variable argument list.
29 */ 31 */
30typedef void marker_probe_func(const struct marker *mdata, 32typedef void marker_probe_func(void *probe_private, void *call_private,
31 void *private_data, const char *fmt, ...); 33 const char *fmt, va_list *args);
34
35struct marker_probe_closure {
36 marker_probe_func *func; /* Callback */
37 void *probe_private; /* Private probe data */
38};
32 39
33struct marker { 40struct marker {
34 const char *name; /* Marker name */ 41 const char *name; /* Marker name */
@@ -36,8 +43,11 @@ struct marker {
36 * variable argument list. 43 * variable argument list.
37 */ 44 */
38 char state; /* Marker state. */ 45 char state; /* Marker state. */
39 marker_probe_func *call;/* Probe handler function pointer */ 46 char ptype; /* probe type : 0 : single, 1 : multi */
40 void *private; /* Private probe data */ 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;
41} __attribute__((aligned(8))); 51} __attribute__((aligned(8)));
42 52
43#ifdef CONFIG_MARKERS 53#ifdef CONFIG_MARKERS
@@ -49,35 +59,31 @@ struct marker {
49 * not add unwanted padding between the beginning of the section and the 59 * not add unwanted padding between the beginning of the section and the
50 * structure. Force alignment to the same alignment as the section start. 60 * structure. Force alignment to the same alignment as the section start.
51 */ 61 */
52#define __trace_mark(name, call_data, format, args...) \ 62#define __trace_mark(name, call_private, format, args...) \
53 do { \ 63 do { \
54 static const char __mstrtab_name_##name[] \ 64 static const char __mstrtab_##name[] \
55 __attribute__((section("__markers_strings"))) \
56 = #name; \
57 static const char __mstrtab_format_##name[] \
58 __attribute__((section("__markers_strings"))) \ 65 __attribute__((section("__markers_strings"))) \
59 = format; \ 66 = #name "\0" format; \
60 static struct marker __mark_##name \ 67 static struct marker __mark_##name \
61 __attribute__((section("__markers"), aligned(8))) = \ 68 __attribute__((section("__markers"), aligned(8))) = \
62 { __mstrtab_name_##name, __mstrtab_format_##name, \ 69 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
63 0, __mark_empty_function, NULL }; \ 70 0, 0, marker_probe_cb, \
71 { __mark_empty_function, NULL}, NULL }; \
64 __mark_check_format(format, ## args); \ 72 __mark_check_format(format, ## args); \
65 if (unlikely(__mark_##name.state)) { \ 73 if (unlikely(__mark_##name.state)) { \
66 preempt_disable(); \
67 (*__mark_##name.call) \ 74 (*__mark_##name.call) \
68 (&__mark_##name, call_data, \ 75 (&__mark_##name, call_private, \
69 format, ## args); \ 76 format, ## args); \
70 preempt_enable(); \
71 } \ 77 } \
72 } while (0) 78 } while (0)
73 79
74extern void marker_update_probe_range(struct marker *begin, 80extern void marker_update_probe_range(struct marker *begin,
75 struct marker *end, struct module *probe_module, int *refcount); 81 struct marker *end);
76#else /* !CONFIG_MARKERS */ 82#else /* !CONFIG_MARKERS */
77#define __trace_mark(name, call_data, format, args...) \ 83#define __trace_mark(name, call_private, format, args...) \
78 __mark_check_format(format, ## args) 84 __mark_check_format(format, ## args)
79static inline void marker_update_probe_range(struct marker *begin, 85static inline void marker_update_probe_range(struct marker *begin,
80 struct marker *end, struct module *probe_module, int *refcount) 86 struct marker *end)
81{ } 87{ }
82#endif /* CONFIG_MARKERS */ 88#endif /* CONFIG_MARKERS */
83 89
@@ -92,8 +98,6 @@ static inline void marker_update_probe_range(struct marker *begin,
92#define trace_mark(name, format, args...) \ 98#define trace_mark(name, format, args...) \
93 __trace_mark(name, NULL, format, ## args) 99 __trace_mark(name, NULL, format, ## args)
94 100
95#define MARK_MAX_FORMAT_LEN 1024
96
97/** 101/**
98 * MARK_NOARGS - Format string for a marker with no argument. 102 * MARK_NOARGS - Format string for a marker with no argument.
99 */ 103 */
@@ -106,24 +110,30 @@ static inline void __printf(1, 2) __mark_check_format(const char *fmt, ...)
106 110
107extern marker_probe_func __mark_empty_function; 111extern marker_probe_func __mark_empty_function;
108 112
113extern void marker_probe_cb(const struct marker *mdata,
114 void *call_private, const char *fmt, ...);
115extern void marker_probe_cb_noarg(const struct marker *mdata,
116 void *call_private, const char *fmt, ...);
117
109/* 118/*
110 * Connect a probe to a marker. 119 * Connect a probe to a marker.
111 * private data pointer must be a valid allocated memory address, or NULL. 120 * private data pointer must be a valid allocated memory address, or NULL.
112 */ 121 */
113extern int marker_probe_register(const char *name, const char *format, 122extern int marker_probe_register(const char *name, const char *format,
114 marker_probe_func *probe, void *private); 123 marker_probe_func *probe, void *probe_private);
115 124
116/* 125/*
117 * Returns the private data given to marker_probe_register. 126 * Returns the private data given to marker_probe_register.
118 */ 127 */
119extern void *marker_probe_unregister(const char *name); 128extern int marker_probe_unregister(const char *name,
129 marker_probe_func *probe, void *probe_private);
120/* 130/*
121 * Unregister a marker by providing the registered private data. 131 * Unregister a marker by providing the registered private data.
122 */ 132 */
123extern void *marker_probe_unregister_private_data(void *private); 133extern int marker_probe_unregister_private_data(marker_probe_func *probe,
134 void *probe_private);
124 135
125extern int marker_arm(const char *name); 136extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
126extern int marker_disarm(const char *name); 137 int num);
127extern void *marker_get_private_data(const char *name);
128 138
129#endif 139#endif