Skip to content

Commit ea20d92

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: consolidate trace and trace_event headers
Impact: clean up Neil Horman (et. al.) criticized the way the trace events were broken up into two files. The reason for that was that ftrace needed to separate out the declarations from where the #include <linux/tracepoint.h> was used. It then dawned on me that the tracepoint.h header only needs to define the TRACE_EVENT macro if it is not already defined. The solution is simply to test if TRACE_EVENT is defined, and if it is not then the linux/tracepoint.h header can define it. This change consolidates all the <traces>.h and <traces>_event_types.h into the <traces>.h file. Reported-by: Neil Horman <nhorman@tuxdriver.com> Reported-by: Theodore Tso <tytso@mit.edu> Reported-by: Jiaying Zhang <jiayingz@google.com> Cc: Zhaolei <zhaolei@cn.fujitsu.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Jason Baron <jbaron@redhat.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 0a19e53 commit ea20d92

15 files changed

Lines changed: 663 additions & 518 deletions

‎include/linux/tracepoint.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ struct tracepoint {
3131
* Keep in sync with vmlinux.lds.h.
3232
*/
3333

34+
#ifndef DECLARE_TRACE
35+
3436
#define TP_PROTO(args...) args
3537
#define TP_ARGS(args...) args
3638

@@ -114,6 +116,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
114116
struct tracepoint *end)
115117
{ }
116118
#endif /* CONFIG_TRACEPOINTS */
119+
#endif /* DECLARE_TRACE */
117120

118121
/*
119122
* Connect a probe to a tracepoint.
@@ -154,10 +157,13 @@ static inline void tracepoint_synchronize_unregister(void)
154157
}
155158

156159
#define PARAMS(args...) args
160+
161+
#ifndef TRACE_FORMAT
157162
#define TRACE_FORMAT(name, proto, args, fmt) \
158163
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
164+
#endif
159165

160-
166+
#ifndef TRACE_EVENT
161167
/*
162168
* For use with the TRACE_EVENT macro:
163169
*
@@ -262,5 +268,6 @@ static inline void tracepoint_synchronize_unregister(void)
262268

263269
#define TRACE_EVENT(name, proto, args, struct, assign, print) \
264270
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
271+
#endif
265272

266273
#endif

‎include/trace/irq.h‎

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1-
#ifndef _TRACE_IRQ_H
1+
#if !defined(_TRACE_IRQ_H) || defined(TRACE_HEADER_MULTI_READ)
22
#define _TRACE_IRQ_H
33

4-
#include <linux/interrupt.h>
54
#include <linux/tracepoint.h>
5+
#include <linux/interrupt.h>
6+
7+
#undef TRACE_SYSTEM
8+
#define TRACE_SYSTEM irq
9+
10+
/*
11+
* Tracepoint for entry of interrupt handler:
12+
*/
13+
TRACE_FORMAT(irq_handler_entry,
14+
TP_PROTO(int irq, struct irqaction *action),
15+
TP_ARGS(irq, action),
16+
TP_FMT("irq=%d handler=%s", irq, action->name)
17+
);
18+
19+
/*
20+
* Tracepoint for return of an interrupt handler:
21+
*/
22+
TRACE_EVENT(irq_handler_exit,
23+
24+
TP_PROTO(int irq, struct irqaction *action, int ret),
25+
26+
TP_ARGS(irq, action, ret),
27+
28+
TP_STRUCT__entry(
29+
__field( int, irq )
30+
__field( int, ret )
31+
),
32+
33+
TP_fast_assign(
34+
__entry->irq = irq;
35+
__entry->ret = ret;
36+
),
37+
38+
TP_printk("irq=%d return=%s",
39+
__entry->irq, __entry->ret ? "handled" : "unhandled")
40+
);
41+
42+
TRACE_FORMAT(softirq_entry,
43+
TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
44+
TP_ARGS(h, vec),
45+
TP_FMT("softirq=%d action=%s", (int)(h - vec), softirq_to_name[h-vec])
46+
);
647

7-
#include <trace/irq_event_types.h>
48+
TRACE_FORMAT(softirq_exit,
49+
TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
50+
TP_ARGS(h, vec),
51+
TP_FMT("softirq=%d action=%s", (int)(h - vec), softirq_to_name[h-vec])
52+
);
853

954
#endif

‎include/trace/irq_event_types.h‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎include/trace/kmem.h‎

Lines changed: 186 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,192 @@
1-
#ifndef _TRACE_KMEM_H
1+
#if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
22
#define _TRACE_KMEM_H
33

44
#include <linux/types.h>
55
#include <linux/tracepoint.h>
66

7-
#include <trace/kmem_event_types.h>
7+
#undef TRACE_SYSTEM
8+
#define TRACE_SYSTEM kmem
89

9-
#endif /* _TRACE_KMEM_H */
10+
TRACE_EVENT(kmalloc,
11+
12+
TP_PROTO(unsigned long call_site,
13+
const void *ptr,
14+
size_t bytes_req,
15+
size_t bytes_alloc,
16+
gfp_t gfp_flags),
17+
18+
TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
19+
20+
TP_STRUCT__entry(
21+
__field( unsigned long, call_site )
22+
__field( const void *, ptr )
23+
__field( size_t, bytes_req )
24+
__field( size_t, bytes_alloc )
25+
__field( gfp_t, gfp_flags )
26+
),
27+
28+
TP_fast_assign(
29+
__entry->call_site = call_site;
30+
__entry->ptr = ptr;
31+
__entry->bytes_req = bytes_req;
32+
__entry->bytes_alloc = bytes_alloc;
33+
__entry->gfp_flags = gfp_flags;
34+
),
35+
36+
TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x",
37+
__entry->call_site,
38+
__entry->ptr,
39+
__entry->bytes_req,
40+
__entry->bytes_alloc,
41+
__entry->gfp_flags)
42+
);
43+
44+
TRACE_EVENT(kmem_cache_alloc,
45+
46+
TP_PROTO(unsigned long call_site,
47+
const void *ptr,
48+
size_t bytes_req,
49+
size_t bytes_alloc,
50+
gfp_t gfp_flags),
51+
52+
TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
53+
54+
TP_STRUCT__entry(
55+
__field( unsigned long, call_site )
56+
__field( const void *, ptr )
57+
__field( size_t, bytes_req )
58+
__field( size_t, bytes_alloc )
59+
__field( gfp_t, gfp_flags )
60+
),
61+
62+
TP_fast_assign(
63+
__entry->call_site = call_site;
64+
__entry->ptr = ptr;
65+
__entry->bytes_req = bytes_req;
66+
__entry->bytes_alloc = bytes_alloc;
67+
__entry->gfp_flags = gfp_flags;
68+
),
69+
70+
TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x",
71+
__entry->call_site,
72+
__entry->ptr,
73+
__entry->bytes_req,
74+
__entry->bytes_alloc,
75+
__entry->gfp_flags)
76+
);
77+
78+
TRACE_EVENT(kmalloc_node,
79+
80+
TP_PROTO(unsigned long call_site,
81+
const void *ptr,
82+
size_t bytes_req,
83+
size_t bytes_alloc,
84+
gfp_t gfp_flags,
85+
int node),
86+
87+
TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
88+
89+
TP_STRUCT__entry(
90+
__field( unsigned long, call_site )
91+
__field( const void *, ptr )
92+
__field( size_t, bytes_req )
93+
__field( size_t, bytes_alloc )
94+
__field( gfp_t, gfp_flags )
95+
__field( int, node )
96+
),
97+
98+
TP_fast_assign(
99+
__entry->call_site = call_site;
100+
__entry->ptr = ptr;
101+
__entry->bytes_req = bytes_req;
102+
__entry->bytes_alloc = bytes_alloc;
103+
__entry->gfp_flags = gfp_flags;
104+
__entry->node = node;
105+
),
106+
107+
TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x node=%d",
108+
__entry->call_site,
109+
__entry->ptr,
110+
__entry->bytes_req,
111+
__entry->bytes_alloc,
112+
__entry->gfp_flags,
113+
__entry->node)
114+
);
115+
116+
TRACE_EVENT(kmem_cache_alloc_node,
117+
118+
TP_PROTO(unsigned long call_site,
119+
const void *ptr,
120+
size_t bytes_req,
121+
size_t bytes_alloc,
122+
gfp_t gfp_flags,
123+
int node),
124+
125+
TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
126+
127+
TP_STRUCT__entry(
128+
__field( unsigned long, call_site )
129+
__field( const void *, ptr )
130+
__field( size_t, bytes_req )
131+
__field( size_t, bytes_alloc )
132+
__field( gfp_t, gfp_flags )
133+
__field( int, node )
134+
),
135+
136+
TP_fast_assign(
137+
__entry->call_site = call_site;
138+
__entry->ptr = ptr;
139+
__entry->bytes_req = bytes_req;
140+
__entry->bytes_alloc = bytes_alloc;
141+
__entry->gfp_flags = gfp_flags;
142+
__entry->node = node;
143+
),
144+
145+
TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x node=%d",
146+
__entry->call_site,
147+
__entry->ptr,
148+
__entry->bytes_req,
149+
__entry->bytes_alloc,
150+
__entry->gfp_flags,
151+
__entry->node)
152+
);
153+
154+
TRACE_EVENT(kfree,
155+
156+
TP_PROTO(unsigned long call_site, const void *ptr),
157+
158+
TP_ARGS(call_site, ptr),
159+
160+
TP_STRUCT__entry(
161+
__field( unsigned long, call_site )
162+
__field( const void *, ptr )
163+
),
164+
165+
TP_fast_assign(
166+
__entry->call_site = call_site;
167+
__entry->ptr = ptr;
168+
),
169+
170+
TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
171+
);
172+
173+
TRACE_EVENT(kmem_cache_free,
174+
175+
TP_PROTO(unsigned long call_site, const void *ptr),
176+
177+
TP_ARGS(call_site, ptr),
178+
179+
TP_STRUCT__entry(
180+
__field( unsigned long, call_site )
181+
__field( const void *, ptr )
182+
),
183+
184+
TP_fast_assign(
185+
__entry->call_site = call_site;
186+
__entry->ptr = ptr;
187+
),
188+
189+
TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
190+
);
191+
192+
#endif

0 commit comments

Comments
 (0)