aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-12 16:06:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-12 16:06:10 -0400
commit0a7418f5f569512e98789c439198eed4b507cce3 (patch)
tree83b2b341b4818848b6bd1351f0b078f546c1300a /include/linux
parent0b747172dce6e0905ab173afbaffebb7a11d89bd (diff)
parent17a280ea8111c66791c18c0353b7986aafcb24fe (diff)
Merge tag 'trace-3.15-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull more tracing updates from Steven Rostedt: "This includes the final patch to clean up and fix the issue with the design of tracepoints and how a user could register a tracepoint and have that tracepoint not be activated but no error was shown. The design was for an out of tree module but broke in tree users. The clean up was to remove the saving of the hash table of tracepoint names such that they can be enabled before they exist (enabling a module tracepoint before that module is loaded). This added more complexity than needed. The clean up was to remove that code and just enable tracepoints that exist or fail if they do not. This removed a lot of code as well as the complexity that it brought. As a side effect, instead of registering a tracepoint by its name, the tracepoint needs to be registered with the tracepoint descriptor. This removes having to duplicate the tracepoint names that are enabled. The second patch was added that simplified the way modules were searched for. This cleanup required changes that were in the 3.15 queue as well as some changes that were added late in the 3.14-rc cycle. This final change waited till the two were merged in upstream and then the change was added and full tests were run. Unfortunately, the test found some errors, but after it was already submitted to the for-next branch and not to be rebased. Sparse errors were detected by Fengguang Wu's bot tests, and my internal tests discovered that the anonymous union initialization triggered a bug in older gcc compilers. Luckily, there was a bugzilla for the gcc bug which gave a work around to the problem. The third and fourth patch handled the sparse error and the gcc bug respectively. A final patch was tagged along to fix a missing documentation for the README file" * tag 'trace-3.15-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Add missing function triggers dump and cpudump to README tracing: Fix anonymous unions in struct ftrace_event_call tracepoint: Fix sparse warnings in tracepoint.c tracepoint: Simplify tracepoint module search tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ftrace_event.h22
-rw-r--r--include/linux/syscalls.h8
-rw-r--r--include/linux/tracepoint.h49
3 files changed, 57 insertions, 22 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/syscalls.h b/include/linux/syscalls.h
index 697ceb70a9a9..a4a0588c5397 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -119,8 +119,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
119 static struct syscall_metadata __syscall_meta_##sname; \ 119 static struct syscall_metadata __syscall_meta_##sname; \
120 static struct ftrace_event_call __used \ 120 static struct ftrace_event_call __used \
121 event_enter_##sname = { \ 121 event_enter_##sname = { \
122 .name = "sys_enter"#sname, \
123 .class = &event_class_syscall_enter, \ 122 .class = &event_class_syscall_enter, \
123 { \
124 .name = "sys_enter"#sname, \
125 }, \
124 .event.funcs = &enter_syscall_print_funcs, \ 126 .event.funcs = &enter_syscall_print_funcs, \
125 .data = (void *)&__syscall_meta_##sname,\ 127 .data = (void *)&__syscall_meta_##sname,\
126 .flags = TRACE_EVENT_FL_CAP_ANY, \ 128 .flags = TRACE_EVENT_FL_CAP_ANY, \
@@ -133,8 +135,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
133 static struct syscall_metadata __syscall_meta_##sname; \ 135 static struct syscall_metadata __syscall_meta_##sname; \
134 static struct ftrace_event_call __used \ 136 static struct ftrace_event_call __used \
135 event_exit_##sname = { \ 137 event_exit_##sname = { \
136 .name = "sys_exit"#sname, \
137 .class = &event_class_syscall_exit, \ 138 .class = &event_class_syscall_exit, \
139 { \
140 .name = "sys_exit"#sname, \
141 }, \
138 .event.funcs = &exit_syscall_print_funcs, \ 142 .event.funcs = &exit_syscall_print_funcs, \
139 .data = (void *)&__syscall_meta_##sname,\ 143 .data = (void *)&__syscall_meta_##sname,\
140 .flags = TRACE_EVENT_FL_CAP_ANY, \ 144 .flags = TRACE_EVENT_FL_CAP_ANY, \
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 812b2553dfd8..9d30ee469c2a 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,31 +36,38 @@ 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 {
53 struct list_head list; 49 struct list_head list;
54 unsigned int num_tracepoints; 50 struct module *mod;
55 struct tracepoint * const *tracepoints_ptrs;
56}; 51};
52
57bool trace_module_has_bad_taint(struct module *mod); 53bool trace_module_has_bad_taint(struct module *mod);
54extern int register_tracepoint_module_notifier(struct notifier_block *nb);
55extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
58#else 56#else
59static inline bool trace_module_has_bad_taint(struct module *mod) 57static inline bool trace_module_has_bad_taint(struct module *mod)
60{ 58{
61 return false; 59 return false;
62} 60}
61static inline
62int register_tracepoint_module_notifier(struct notifier_block *nb)
63{
64 return 0;
65}
66static inline
67int unregister_tracepoint_module_notifier(struct notifier_block *nb)
68{
69 return 0;
70}
63#endif /* CONFIG_MODULES */ 71#endif /* CONFIG_MODULES */
64 72
65/* 73/*
@@ -72,6 +80,11 @@ static inline void tracepoint_synchronize_unregister(void)
72 synchronize_sched(); 80 synchronize_sched();
73} 81}
74 82
83#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
84extern void syscall_regfunc(void);
85extern void syscall_unregfunc(void);
86#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
87
75#define PARAMS(args...) args 88#define PARAMS(args...) args
76 89
77#endif /* _LINUX_TRACEPOINT_H */ 90#endif /* _LINUX_TRACEPOINT_H */
@@ -160,14 +173,14 @@ static inline void tracepoint_synchronize_unregister(void)
160 static inline int \ 173 static inline int \
161 register_trace_##name(void (*probe)(data_proto), void *data) \ 174 register_trace_##name(void (*probe)(data_proto), void *data) \
162 { \ 175 { \
163 return tracepoint_probe_register(#name, (void *)probe, \ 176 return tracepoint_probe_register(&__tracepoint_##name, \
164 data); \ 177 (void *)probe, data); \
165 } \ 178 } \
166 static inline int \ 179 static inline int \
167 unregister_trace_##name(void (*probe)(data_proto), void *data) \ 180 unregister_trace_##name(void (*probe)(data_proto), void *data) \
168 { \ 181 { \
169 return tracepoint_probe_unregister(#name, (void *)probe, \ 182 return tracepoint_probe_unregister(&__tracepoint_##name,\
170 data); \ 183 (void *)probe, data); \
171 } \ 184 } \
172 static inline void \ 185 static inline void \
173 check_trace_callback_type_##name(void (*cb)(data_proto)) \ 186 check_trace_callback_type_##name(void (*cb)(data_proto)) \