Skip to content

Commit 2e26ca7

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Fix tracepoint.h DECLARE_TRACE() to allow more than one header
When more than one header is included under CREATE_TRACE_POINTS the DECLARE_TRACE() macro is not defined back to its original meaning and the second include will fail to initialize the TRACE_EVENT() and DECLARE_TRACE() correctly. To fix this the tracepoint.h file moves the define of DECLARE_TRACE() out of the #ifdef _LINUX_TRACEPOINT_H protection (just like the define of the TRACE_EVENT()). This way the define_trace.h will undef the DECLARE_TRACE() at the end and allow new headers to start from scratch. This patch also requires fixing the include/events/napi.h It currently uses DECLARE_TRACE() and should be converted to a TRACE_EVENT() format. But I'll leave that change to the authors of that file. But since the napi.h file depends on using the CREATE_TRACE_POINTS and does not define its own DEFINE_TRACE() it must use the define_trace.h method instead. Cc: Neil Horman <[email protected]> Cc: David S. Miller <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 03d646e commit 2e26ca7

File tree

3 files changed

+72
-57
lines changed

3 files changed

+72
-57
lines changed

include/linux/tracepoint.h

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,65 @@ struct tracepoint {
3333
* Keep in sync with vmlinux.lds.h.
3434
*/
3535

36+
/*
37+
* Connect a probe to a tracepoint.
38+
* Internal API, should not be used directly.
39+
*/
40+
extern int tracepoint_probe_register(const char *name, void *probe);
41+
42+
/*
43+
* Disconnect a probe from a tracepoint.
44+
* Internal API, should not be used directly.
45+
*/
46+
extern int tracepoint_probe_unregister(const char *name, void *probe);
47+
48+
extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
49+
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
50+
extern void tracepoint_probe_update_all(void);
51+
52+
struct tracepoint_iter {
53+
struct module *module;
54+
struct tracepoint *tracepoint;
55+
};
56+
57+
extern void tracepoint_iter_start(struct tracepoint_iter *iter);
58+
extern void tracepoint_iter_next(struct tracepoint_iter *iter);
59+
extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
60+
extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
61+
extern int tracepoint_get_iter_range(struct tracepoint **tracepoint,
62+
struct tracepoint *begin, struct tracepoint *end);
63+
64+
/*
65+
* tracepoint_synchronize_unregister must be called between the last tracepoint
66+
* probe unregistration and the end of module exit to make sure there is no
67+
* caller executing a probe when it is freed.
68+
*/
69+
static inline void tracepoint_synchronize_unregister(void)
70+
{
71+
synchronize_sched();
72+
}
73+
74+
#define PARAMS(args...) args
75+
76+
#ifdef CONFIG_TRACEPOINTS
77+
extern void tracepoint_update_probe_range(struct tracepoint *begin,
78+
struct tracepoint *end);
79+
#else
80+
static inline void tracepoint_update_probe_range(struct tracepoint *begin,
81+
struct tracepoint *end)
82+
{ }
83+
#endif /* CONFIG_TRACEPOINTS */
84+
85+
#endif /* _LINUX_TRACEPOINT_H */
86+
87+
/*
88+
* Note: we keep the TRACE_EVENT and DECLARE_TRACE outside the include
89+
* file ifdef protection.
90+
* This is due to the way trace events work. If a file includes two
91+
* trace event headers under one "CREATE_TRACE_POINTS" the first include
92+
* will override the TRACE_EVENT and break the second include.
93+
*/
94+
3695
#ifndef DECLARE_TRACE
3796

3897
#define TP_PROTO(args...) args
@@ -96,9 +155,6 @@ struct tracepoint {
96155
#define EXPORT_TRACEPOINT_SYMBOL(name) \
97156
EXPORT_SYMBOL(__tracepoint_##name)
98157

99-
extern void tracepoint_update_probe_range(struct tracepoint *begin,
100-
struct tracepoint *end);
101-
102158
#else /* !CONFIG_TRACEPOINTS */
103159
#define DECLARE_TRACE(name, proto, args) \
104160
static inline void _do_trace_##name(struct tracepoint *tp, proto) \
@@ -119,61 +175,9 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
119175
#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
120176
#define EXPORT_TRACEPOINT_SYMBOL(name)
121177

122-
static inline void tracepoint_update_probe_range(struct tracepoint *begin,
123-
struct tracepoint *end)
124-
{ }
125178
#endif /* CONFIG_TRACEPOINTS */
126179
#endif /* DECLARE_TRACE */
127180

128-
/*
129-
* Connect a probe to a tracepoint.
130-
* Internal API, should not be used directly.
131-
*/
132-
extern int tracepoint_probe_register(const char *name, void *probe);
133-
134-
/*
135-
* Disconnect a probe from a tracepoint.
136-
* Internal API, should not be used directly.
137-
*/
138-
extern int tracepoint_probe_unregister(const char *name, void *probe);
139-
140-
extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
141-
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
142-
extern void tracepoint_probe_update_all(void);
143-
144-
struct tracepoint_iter {
145-
struct module *module;
146-
struct tracepoint *tracepoint;
147-
};
148-
149-
extern void tracepoint_iter_start(struct tracepoint_iter *iter);
150-
extern void tracepoint_iter_next(struct tracepoint_iter *iter);
151-
extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
152-
extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
153-
extern int tracepoint_get_iter_range(struct tracepoint **tracepoint,
154-
struct tracepoint *begin, struct tracepoint *end);
155-
156-
/*
157-
* tracepoint_synchronize_unregister must be called between the last tracepoint
158-
* probe unregistration and the end of module exit to make sure there is no
159-
* caller executing a probe when it is freed.
160-
*/
161-
static inline void tracepoint_synchronize_unregister(void)
162-
{
163-
synchronize_sched();
164-
}
165-
166-
#define PARAMS(args...) args
167-
168-
#endif /* _LINUX_TRACEPOINT_H */
169-
170-
/*
171-
* Note: we keep the TRACE_EVENT outside the include file ifdef protection.
172-
* This is due to the way trace events work. If a file includes two
173-
* trace event headers under one "CREATE_TRACE_POINTS" the first include
174-
* will override the TRACE_EVENT and break the second include.
175-
*/
176-
177181
#ifndef TRACE_EVENT
178182
/*
179183
* For use with the TRACE_EVENT macro:

include/trace/define_trace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565

6666
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
6767

68+
/* Make all open coded DECLARE_TRACE nops */
69+
#undef DECLARE_TRACE
70+
#define DECLARE_TRACE(name, proto, args)
71+
6872
#ifdef CONFIG_EVENT_TRACING
6973
#include <trace/ftrace.h>
7074
#endif
@@ -75,6 +79,7 @@
7579
#undef DEFINE_EVENT
7680
#undef DEFINE_EVENT_PRINT
7781
#undef TRACE_HEADER_MULTI_READ
82+
#undef DECLARE_TRACE
7883

7984
/* Only undef what we defined in this file */
8085
#ifdef UNDEF_TRACE_INCLUDE_FILE

include/trace/events/napi.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#ifndef _TRACE_NAPI_H_
1+
#undef TRACE_SYSTEM
2+
#define TRACE_SYSTEM napi
3+
4+
#if !defined(_TRACE_NAPI_H) || defined(TRACE_HEADER_MULTI_READ)
25
#define _TRACE_NAPI_H_
36

47
#include <linux/netdevice.h>
@@ -8,4 +11,7 @@ DECLARE_TRACE(napi_poll,
811
TP_PROTO(struct napi_struct *napi),
912
TP_ARGS(napi));
1013

11-
#endif
14+
#endif /* _TRACE_NAPI_H_ */
15+
16+
/* This part must be outside protection */
17+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)