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/immediate.h>
16 //#include <linux/types.h>
18 #include "kernel-api.h"
26 * marker_probe_func - Type of a marker probe function
27 * @probe_private: probe private data
28 * @call_private: call site private data
30 * @args: variable argument list pointer. Use a pointer to overcome C's
31 * inability to pass this around as a pointer in a portable manner in
32 * the callee otherwise.
34 * Type of marker probe functions. They receive the mdata and need to parse the
35 * format string to recover the variable argument list.
37 typedef void marker_probe_func(void *probe_private
, void *call_private
,
38 const char *fmt
, va_list *args
);
40 struct marker_probe_closure
{
41 marker_probe_func
*func
; /* Callback */
42 void *probe_private
; /* Private probe data */
46 const char *name
; /* Marker name */
47 const char *format
; /* Marker format string, describing the
48 * variable argument list.
50 DEFINE_IMV(char, state
);/* Immediate value state. */
51 char ptype
; /* probe type : 0 : single, 1 : multi */
52 void (*call
)(const struct marker
*mdata
, /* Probe wrapper */
53 void *call_private
, const char *fmt
, ...);
54 struct marker_probe_closure single
;
55 struct marker_probe_closure
*multi
;
56 } __attribute__((aligned(8)));
61 * Generic marker flavor always available.
62 * Note : the empty asm volatile with read constraint is used here instead of a
63 * "used" attribute to fix a gcc 4.1.x bug.
64 * Make sure the alignment of the structure in the __markers section will
65 * not add unwanted padding between the beginning of the section and the
66 * structure. Force alignment to the same alignment as the section start.
68 #define __trace_mark(generic, name, call_private, format, args...) \
70 static const char __mstrtab_##name[] \
71 __attribute__((section("__markers_strings"))) \
72 = #name "\0" format; \
73 static struct marker __mark_##name \
74 __attribute__((section("__markers"), aligned(8))) = \
75 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
76 0, 0, marker_probe_cb, \
77 { __mark_empty_function, NULL}, NULL }; \
78 __mark_check_format(format, ## args); \
80 if (unlikely(imv_read(__mark_##name.state))) \
81 (*__mark_##name.call) \
82 (&__mark_##name, call_private, \
85 if (unlikely(_imv_read(__mark_##name.state))) \
86 (*__mark_##name.call) \
87 (&__mark_##name, call_private, \
92 extern void marker_update_probe_range(struct marker
*begin
,
94 #else /* !CONFIG_MARKERS */
95 #define __trace_mark(generic, name, call_private, format, args...) \
96 __mark_check_format(format, ## args)
97 static inline void marker_update_probe_range(struct marker
*begin
,
100 #endif /* CONFIG_MARKERS */
103 * trace_mark - Marker using code patching
104 * @name: marker name, not quoted.
105 * @format: format string
106 * @args...: variable argument list
108 * Places a marker using optimized code patching technique (imv_read())
111 #define trace_mark(name, format, args...) \
112 __trace_mark(0, name, NULL, format, ## args)
115 * _trace_mark - Marker using variable read
116 * @name: marker name, not quoted.
117 * @format: format string
118 * @args...: variable argument list
120 * Places a marker using a standard memory read (_imv_read()) to be
121 * enabled. Should be used for markers in __init and __exit functions and in
124 #define _trace_mark(name, format, args...) \
125 __trace_mark(1, name, NULL, format, ## args)
128 * MARK_NOARGS - Format string for a marker with no argument.
130 #define MARK_NOARGS " "
132 /* To be used for string format validity checking with gcc */
133 static inline void __attribute__((format (printf
, 1, 2)))
134 __mark_check_format(const char *fmt
, ...)
138 extern marker_probe_func __mark_empty_function
;
140 extern void marker_probe_cb(const struct marker
*mdata
,
141 void *call_private
, const char *fmt
, ...);
142 extern void marker_probe_cb_noarg(const struct marker
*mdata
,
143 void *call_private
, const char *fmt
, ...);
146 * Connect a probe to a marker.
147 * private data pointer must be a valid allocated memory address, or NULL.
149 extern int marker_probe_register(const char *name
, const char *format
,
150 marker_probe_func
*probe
, void *probe_private
);
153 * Returns the private data given to marker_probe_register.
155 extern int marker_probe_unregister(const char *name
,
156 marker_probe_func
*probe
, void *probe_private
);
158 * Unregister a marker by providing the registered private data.
160 extern int marker_probe_unregister_private_data(marker_probe_func
*probe
,
161 void *probe_private
);
163 extern void *marker_get_private_data(const char *name
, marker_probe_func
*probe
,
167 struct module
*module
;
168 struct marker
*marker
;
171 extern void marker_iter_start(struct marker_iter
*iter
);
172 extern void marker_iter_next(struct marker_iter
*iter
);
173 extern void marker_iter_stop(struct marker_iter
*iter
);
174 extern void marker_iter_reset(struct marker_iter
*iter
);
175 extern int marker_get_iter_range(struct marker
**marker
, struct marker
*begin
,