hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/Documentation/trace/tracepoints.rst
....@@ -146,3 +146,30 @@
146146 define tracepoints. Check http://lwn.net/Articles/379903,
147147 http://lwn.net/Articles/381064 and http://lwn.net/Articles/383362
148148 for a series of articles with more details.
149
+
150
+If you require calling a tracepoint from a header file, it is not
151
+recommended to call one directly or to use the trace_<tracepoint>_enabled()
152
+function call, as tracepoints in header files can have side effects if a
153
+header is included from a file that has CREATE_TRACE_POINTS set, as
154
+well as the trace_<tracepoint>() is not that small of an inline
155
+and can bloat the kernel if used by other inlined functions. Instead,
156
+include tracepoint-defs.h and use tracepoint_enabled().
157
+
158
+In a C file::
159
+
160
+ void do_trace_foo_bar_wrapper(args)
161
+ {
162
+ trace_foo_bar(args);
163
+ }
164
+
165
+In the header file::
166
+
167
+ DECLARE_TRACEPOINT(foo_bar);
168
+
169
+ static inline void some_inline_function()
170
+ {
171
+ [..]
172
+ if (tracepoint_enabled(foo_bar))
173
+ do_trace_foo_bar_wrapper(args);
174
+ [..]
175
+ }