aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2014-04-08 17:26:21 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-04-08 20:43:28 -0400
commitde7b2973903c6cc50b31ee5682a69b2219b9919d (patch)
treea5b9d78102854b0073f5893cafb29920f8fb55e1 /include
parent68114e5eb862ad0a7a261b91497281b026102715 (diff)
tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints
Register/unregister tracepoint probes with struct tracepoint pointer rather than tracepoint name. This change, which vastly simplifies tracepoint.c, has been proposed by Steven Rostedt. It also removes 8.8kB (mostly of text) to the vmlinux size. From this point on, the tracers need to pass a struct tracepoint pointer to probe register/unregister. A probe can now only be connected to a tracepoint that exists. Moreover, tracers are responsible for unregistering the probe before the module containing its associated tracepoint is unloaded. text data bss dec hex filename 10443444 4282528 10391552 25117524 17f4354 vmlinux.orig 10434930 4282848 10391552 25109330 17f2352 vmlinux Link: http://lkml.kernel.org/r/1396992381-23785-2-git-send-email-mathieu.desnoyers@efficios.com CC: Ingo Molnar <mingo@kernel.org> CC: Frederic Weisbecker <fweisbec@gmail.com> CC: Andrew Morton <akpm@linux-foundation.org> CC: Frank Ch. Eigler <fche@redhat.com> CC: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> [ SDR - fixed return val in void func in tracepoint_module_going() ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ftrace_event.h22
-rw-r--r--include/linux/tracepoint.h41
-rw-r--r--include/trace/ftrace.h9
3 files changed, 51 insertions, 21 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index cdc30111d2f8..d16da3e53bc7 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -7,6 +7,7 @@
7#include <linux/percpu.h> 7#include <linux/percpu.h>
8#include <linux/hardirq.h> 8#include <linux/hardirq.h>
9#include <linux/perf_event.h> 9#include <linux/perf_event.h>
10#include <linux/tracepoint.h>
10 11
11struct trace_array; 12struct trace_array;
12struct trace_buffer; 13struct trace_buffer;
@@ -232,6 +233,7 @@ enum {
232 TRACE_EVENT_FL_IGNORE_ENABLE_BIT, 233 TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
233 TRACE_EVENT_FL_WAS_ENABLED_BIT, 234 TRACE_EVENT_FL_WAS_ENABLED_BIT,
234 TRACE_EVENT_FL_USE_CALL_FILTER_BIT, 235 TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
236 TRACE_EVENT_FL_TRACEPOINT_BIT,
235}; 237};
236 238
237/* 239/*
@@ -244,6 +246,7 @@ enum {
244 * (used for module unloading, if a module event is enabled, 246 * (used for module unloading, if a module event is enabled,
245 * it is best to clear the buffers that used it). 247 * it is best to clear the buffers that used it).
246 * USE_CALL_FILTER - For ftrace internal events, don't use file filter 248 * USE_CALL_FILTER - For ftrace internal events, don't use file filter
249 * TRACEPOINT - Event is a tracepoint
247 */ 250 */
248enum { 251enum {
249 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), 252 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
@@ -252,12 +255,17 @@ enum {
252 TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT), 255 TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
253 TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT), 256 TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT),
254 TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT), 257 TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
258 TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
255}; 259};
256 260
257struct ftrace_event_call { 261struct ftrace_event_call {
258 struct list_head list; 262 struct list_head list;
259 struct ftrace_event_class *class; 263 struct ftrace_event_class *class;
260 char *name; 264 union {
265 char *name;
266 /* Set TRACE_EVENT_FL_TRACEPOINT flag when using "tp" */
267 struct tracepoint *tp;
268 };
261 struct trace_event event; 269 struct trace_event event;
262 const char *print_fmt; 270 const char *print_fmt;
263 struct event_filter *filter; 271 struct event_filter *filter;
@@ -271,6 +279,7 @@ struct ftrace_event_call {
271 * bit 3: ftrace internal event (do not enable) 279 * bit 3: ftrace internal event (do not enable)
272 * bit 4: Event was enabled by module 280 * bit 4: Event was enabled by module
273 * bit 5: use call filter rather than file filter 281 * bit 5: use call filter rather than file filter
282 * bit 6: Event is a tracepoint
274 */ 283 */
275 int flags; /* static flags of different events */ 284 int flags; /* static flags of different events */
276 285
@@ -283,6 +292,15 @@ struct ftrace_event_call {
283#endif 292#endif
284}; 293};
285 294
295static inline const char *
296ftrace_event_name(struct ftrace_event_call *call)
297{
298 if (call->flags & TRACE_EVENT_FL_TRACEPOINT)
299 return call->tp ? call->tp->name : NULL;
300 else
301 return call->name;
302}
303
286struct trace_array; 304struct trace_array;
287struct ftrace_subsystem_dir; 305struct ftrace_subsystem_dir;
288 306
@@ -353,7 +371,7 @@ struct ftrace_event_file {
353#define __TRACE_EVENT_FLAGS(name, value) \ 371#define __TRACE_EVENT_FLAGS(name, value) \
354 static int __init trace_init_flags_##name(void) \ 372 static int __init trace_init_flags_##name(void) \
355 { \ 373 { \
356 event_##name.flags = value; \ 374 event_##name.flags |= value; \
357 return 0; \ 375 return 0; \
358 } \ 376 } \
359 early_initcall(trace_init_flags_##name); 377 early_initcall(trace_init_flags_##name);
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 812b2553dfd8..08150e265761 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -6,7 +6,7 @@
6 * 6 *
7 * See Documentation/trace/tracepoints.txt. 7 * See Documentation/trace/tracepoints.txt.
8 * 8 *
9 * (C) Copyright 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> 9 * Copyright (C) 2008-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * 10 *
11 * Heavily inspired from the Linux Kernel Markers. 11 * Heavily inspired from the Linux Kernel Markers.
12 * 12 *
@@ -21,6 +21,7 @@
21 21
22struct module; 22struct module;
23struct tracepoint; 23struct tracepoint;
24struct notifier_block;
24 25
25struct tracepoint_func { 26struct tracepoint_func {
26 void *func; 27 void *func;
@@ -35,18 +36,13 @@ struct tracepoint {
35 struct tracepoint_func __rcu *funcs; 36 struct tracepoint_func __rcu *funcs;
36}; 37};
37 38
38/*
39 * Connect a probe to a tracepoint.
40 * Internal API, should not be used directly.
41 */
42extern int tracepoint_probe_register(const char *name, void *probe, void *data);
43
44/*
45 * Disconnect a probe from a tracepoint.
46 * Internal API, should not be used directly.
47 */
48extern int 39extern int
49tracepoint_probe_unregister(const char *name, void *probe, void *data); 40tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data);
41extern int
42tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
43extern void
44for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
45 void *priv);
50 46
51#ifdef CONFIG_MODULES 47#ifdef CONFIG_MODULES
52struct tp_module { 48struct tp_module {
@@ -54,12 +50,25 @@ struct tp_module {
54 unsigned int num_tracepoints; 50 unsigned int num_tracepoints;
55 struct tracepoint * const *tracepoints_ptrs; 51 struct tracepoint * const *tracepoints_ptrs;
56}; 52};
53
57bool trace_module_has_bad_taint(struct module *mod); 54bool trace_module_has_bad_taint(struct module *mod);
55extern int register_tracepoint_module_notifier(struct notifier_block *nb);
56extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
58#else 57#else
59static inline bool trace_module_has_bad_taint(struct module *mod) 58static inline bool trace_module_has_bad_taint(struct module *mod)
60{ 59{
61 return false; 60 return false;
62} 61}
62static inline
63int register_tracepoint_module_notifier(struct notifier_block *nb)
64{
65 return 0;
66}
67static inline
68int unregister_tracepoint_module_notifier(struct notifier_block *nb)
69{
70 return 0;
71}
63#endif /* CONFIG_MODULES */ 72#endif /* CONFIG_MODULES */
64 73
65/* 74/*
@@ -160,14 +169,14 @@ static inline void tracepoint_synchronize_unregister(void)
160 static inline int \ 169 static inline int \
161 register_trace_##name(void (*probe)(data_proto), void *data) \ 170 register_trace_##name(void (*probe)(data_proto), void *data) \
162 { \ 171 { \
163 return tracepoint_probe_register(#name, (void *)probe, \ 172 return tracepoint_probe_register(&__tracepoint_##name, \
164 data); \ 173 (void *)probe, data); \
165 } \ 174 } \
166 static inline int \ 175 static inline int \
167 unregister_trace_##name(void (*probe)(data_proto), void *data) \ 176 unregister_trace_##name(void (*probe)(data_proto), void *data) \
168 { \ 177 { \
169 return tracepoint_probe_unregister(#name, (void *)probe, \ 178 return tracepoint_probe_unregister(&__tracepoint_##name,\
170 data); \ 179 (void *)probe, data); \
171 } \ 180 } \
172 static inline void \ 181 static inline void \
173 check_trace_callback_type_##name(void (*cb)(data_proto)) \ 182 check_trace_callback_type_##name(void (*cb)(data_proto)) \
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 8765126b328c..9c44c11cd9bb 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -470,10 +470,11 @@ static inline notrace int ftrace_get_offsets_##call( \
470 * }; 470 * };
471 * 471 *
472 * static struct ftrace_event_call event_<call> = { 472 * static struct ftrace_event_call event_<call> = {
473 * .name = "<call>", 473 * .tp = &__tracepoint_<call>,
474 * .class = event_class_<template>, 474 * .class = event_class_<template>,
475 * .event = &ftrace_event_type_<call>, 475 * .event = &ftrace_event_type_<call>,
476 * .print_fmt = print_fmt_<call>, 476 * .print_fmt = print_fmt_<call>,
477 * .flags = TRACE_EVENT_FL_TRACEPOINT,
477 * }; 478 * };
478 * // its only safe to use pointers when doing linker tricks to 479 * // its only safe to use pointers when doing linker tricks to
479 * // create an array. 480 * // create an array.
@@ -605,10 +606,11 @@ static struct ftrace_event_class __used __refdata event_class_##call = { \
605#define DEFINE_EVENT(template, call, proto, args) \ 606#define DEFINE_EVENT(template, call, proto, args) \
606 \ 607 \
607static struct ftrace_event_call __used event_##call = { \ 608static struct ftrace_event_call __used event_##call = { \
608 .name = #call, \ 609 .tp = &__tracepoint_##call, \
609 .class = &event_class_##template, \ 610 .class = &event_class_##template, \
610 .event.funcs = &ftrace_event_type_funcs_##template, \ 611 .event.funcs = &ftrace_event_type_funcs_##template, \
611 .print_fmt = print_fmt_##template, \ 612 .print_fmt = print_fmt_##template, \
613 .flags = TRACE_EVENT_FL_TRACEPOINT, \
612}; \ 614}; \
613static struct ftrace_event_call __used \ 615static struct ftrace_event_call __used \
614__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call 616__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
@@ -619,10 +621,11 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
619static const char print_fmt_##call[] = print; \ 621static const char print_fmt_##call[] = print; \
620 \ 622 \
621static struct ftrace_event_call __used event_##call = { \ 623static struct ftrace_event_call __used event_##call = { \
622 .name = #call, \ 624 .tp = &__tracepoint_##call, \
623 .class = &event_class_##template, \ 625 .class = &event_class_##template, \
624 .event.funcs = &ftrace_event_type_funcs_##call, \ 626 .event.funcs = &ftrace_event_type_funcs_##call, \
625 .print_fmt = print_fmt_##call, \ 627 .print_fmt = print_fmt_##call, \
628 .flags = TRACE_EVENT_FL_TRACEPOINT, \
626}; \ 629}; \
627static struct ftrace_event_call __used \ 630static struct ftrace_event_call __used \
628__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call 631__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call