aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2014-07-25 16:05:29 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-08-07 20:39:36 -0400
commit3c49b52b155d0f723792377e1a4480a0e7ca0ba2 (patch)
tree651052ab8141bb7b0a28d23ea02624727632f311
parent19583ca584d6f574384e17fe7613dfaeadcdc4a6 (diff)
tracing: Do not do anything special with tracepoint_string when tracing is disabled
When CONFIG_TRACING is not enabled, there's no reason to save the trace strings either by the linker or as a static variable that can be referenced later. Simply pass back the string that is given to tracepoint_string(). Had to move the define to include/linux/tracepoint.h so that it is still visible when CONFIG_TRACING is not set. Link: http://lkml.kernel.org/p/1406318733-26754-2-git-send-email-nicolas.pitre@linaro.org Suggested-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--include/linux/ftrace_event.h34
-rw-r--r--include/linux/tracepoint.h44
2 files changed, 44 insertions, 34 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index cff3106ffe2c..c9f619a2070f 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -574,40 +574,6 @@ do { \
574 __trace_printk(ip, fmt, ##args); \ 574 __trace_printk(ip, fmt, ##args); \
575} while (0) 575} while (0)
576 576
577/**
578 * tracepoint_string - register constant persistent string to trace system
579 * @str - a constant persistent string that will be referenced in tracepoints
580 *
581 * If constant strings are being used in tracepoints, it is faster and
582 * more efficient to just save the pointer to the string and reference
583 * that with a printf "%s" instead of saving the string in the ring buffer
584 * and wasting space and time.
585 *
586 * The problem with the above approach is that userspace tools that read
587 * the binary output of the trace buffers do not have access to the string.
588 * Instead they just show the address of the string which is not very
589 * useful to users.
590 *
591 * With tracepoint_string(), the string will be registered to the tracing
592 * system and exported to userspace via the debugfs/tracing/printk_formats
593 * file that maps the string address to the string text. This way userspace
594 * tools that read the binary buffers have a way to map the pointers to
595 * the ASCII strings they represent.
596 *
597 * The @str used must be a constant string and persistent as it would not
598 * make sense to show a string that no longer exists. But it is still fine
599 * to be used with modules, because when modules are unloaded, if they
600 * had tracepoints, the ring buffers are cleared too. As long as the string
601 * does not change during the life of the module, it is fine to use
602 * tracepoint_string() within a module.
603 */
604#define tracepoint_string(str) \
605 ({ \
606 static const char *___tp_str __tracepoint_string = str; \
607 ___tp_str; \
608 })
609#define __tracepoint_string __attribute__((section("__tracepoint_str")))
610
611#ifdef CONFIG_PERF_EVENTS 577#ifdef CONFIG_PERF_EVENTS
612struct perf_event; 578struct perf_event;
613 579
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