aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tracepoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tracepoint.h')
-rw-r--r--include/linux/tracepoint.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 2e2a5f7717e5..b1293f15f592 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -249,6 +249,50 @@ extern void syscall_unregfunc(void);
249 249
250#endif /* CONFIG_TRACEPOINTS */ 250#endif /* CONFIG_TRACEPOINTS */
251 251
252#ifdef CONFIG_TRACING
253/**
254 * tracepoint_string - register constant persistent string to trace system
255 * @str - a constant persistent string that will be referenced in tracepoints
256 *
257 * If constant strings are being used in tracepoints, it is faster and
258 * more efficient to just save the pointer to the string and reference
259 * that with a printf "%s" instead of saving the string in the ring buffer
260 * and wasting space and time.
261 *
262 * The problem with the above approach is that userspace tools that read
263 * the binary output of the trace buffers do not have access to the string.
264 * Instead they just show the address of the string which is not very
265 * useful to users.
266 *
267 * With tracepoint_string(), the string will be registered to the tracing
268 * system and exported to userspace via the debugfs/tracing/printk_formats
269 * file that maps the string address to the string text. This way userspace
270 * tools that read the binary buffers have a way to map the pointers to
271 * the ASCII strings they represent.
272 *
273 * The @str used must be a constant string and persistent as it would not
274 * make sense to show a string that no longer exists. But it is still fine
275 * to be used with modules, because when modules are unloaded, if they
276 * had tracepoints, the ring buffers are cleared too. As long as the string
277 * does not change during the life of the module, it is fine to use
278 * tracepoint_string() within a module.
279 */
280#define tracepoint_string(str) \
281 ({ \
282 static const char *___tp_str __tracepoint_string = str; \
283 ___tp_str; \
284 })
285#define __tracepoint_string __attribute__((section("__tracepoint_str")))
286#else
287/*
288 * tracepoint_string() is used to save the string address for userspace
289 * tracing tools. When tracing isn't configured, there's no need to save
290 * anything.
291 */
292# define tracepoint_string(str) str
293# define __tracepoint_string
294#endif
295
252/* 296/*
253 * The need for the DECLARE_TRACE_NOARGS() is to handle the prototype 297 * The need for the DECLARE_TRACE_NOARGS() is to handle the prototype
254 * (void). "void" is a special value in a function prototype and can 298 * (void). "void" is a special value in a function prototype and can