Skip to content

Commit 0a1c49d

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: use macros to create internal ftrace entry ring buffer structures
The entries used by ftrace internal code (plugins) currently have their formats manually exported to userspace. That is, the format files in debugfs/tracing/events/ftrace/*/format are currently created by hand. This is a maintenance nightmare, and can easily become out of sync with what is actually shown. This patch uses the methodology of the TRACE_EVENT macros to build the structures so that their formats can be automated and this will keep the structures in sync with what users can see. This patch only changes the way the structures are created. Further patches will build off of this to automate the format files. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 16bb8eb commit 0a1c49d

2 files changed

Lines changed: 369 additions & 133 deletions

File tree

‎kernel/trace/trace.h‎

Lines changed: 27 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -42,150 +42,45 @@ enum trace_type {
4242
__TRACE_LAST_TYPE,
4343
};
4444

45-
/*
46-
* Function trace entry - function address and parent function addres:
47-
*/
48-
struct ftrace_entry {
49-
struct trace_entry ent;
50-
unsigned long ip;
51-
unsigned long parent_ip;
52-
};
53-
54-
/* Function call entry */
55-
struct ftrace_graph_ent_entry {
56-
struct trace_entry ent;
57-
struct ftrace_graph_ent graph_ent;
45+
enum kmemtrace_type_id {
46+
KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
47+
KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
48+
KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
5849
};
5950

60-
/* Function return entry */
61-
struct ftrace_graph_ret_entry {
62-
struct trace_entry ent;
63-
struct ftrace_graph_ret ret;
64-
};
6551
extern struct tracer boot_tracer;
6652

67-
/*
68-
* Context switch trace entry - which task (and prio) we switched from/to:
69-
*/
70-
struct ctx_switch_entry {
71-
struct trace_entry ent;
72-
unsigned int prev_pid;
73-
unsigned char prev_prio;
74-
unsigned char prev_state;
75-
unsigned int next_pid;
76-
unsigned char next_prio;
77-
unsigned char next_state;
78-
unsigned int next_cpu;
79-
};
80-
81-
/*
82-
* Special (free-form) trace entry:
83-
*/
84-
struct special_entry {
85-
struct trace_entry ent;
86-
unsigned long arg1;
87-
unsigned long arg2;
88-
unsigned long arg3;
89-
};
90-
91-
/*
92-
* Stack-trace entry:
93-
*/
53+
#undef __field
54+
#define __field(type, item) type item;
9455

95-
#define FTRACE_STACK_ENTRIES 8
56+
#undef __array
57+
#define __array(type, item, size) type item[size];
9658

97-
struct stack_entry {
98-
struct trace_entry ent;
99-
unsigned long caller[FTRACE_STACK_ENTRIES];
100-
};
59+
#undef __dynamic_array
60+
#define __dynamic_array(type, item) type item[];
10161

102-
struct userstack_entry {
103-
struct trace_entry ent;
104-
unsigned int tgid;
105-
unsigned long caller[FTRACE_STACK_ENTRIES];
106-
};
107-
108-
/*
109-
* trace_printk entry:
110-
*/
111-
struct bprint_entry {
112-
struct trace_entry ent;
113-
unsigned long ip;
114-
const char *fmt;
115-
u32 buf[];
116-
};
117-
118-
struct print_entry {
119-
struct trace_entry ent;
120-
unsigned long ip;
121-
char buf[];
122-
};
62+
#undef F_STRUCT
63+
#define F_STRUCT(args...) args
12364

124-
struct trace_mmiotrace_rw {
125-
struct trace_entry ent;
126-
struct mmiotrace_rw rw;
127-
};
128-
129-
struct trace_mmiotrace_map {
130-
struct trace_entry ent;
131-
struct mmiotrace_map map;
132-
};
133-
134-
struct trace_boot_call {
135-
struct trace_entry ent;
136-
struct boot_trace_call boot_call;
137-
};
138-
139-
struct trace_boot_ret {
140-
struct trace_entry ent;
141-
struct boot_trace_ret boot_ret;
142-
};
143-
144-
#define TRACE_FUNC_SIZE 30
145-
#define TRACE_FILE_SIZE 20
146-
struct trace_branch {
147-
struct trace_entry ent;
148-
unsigned line;
149-
char func[TRACE_FUNC_SIZE+1];
150-
char file[TRACE_FILE_SIZE+1];
151-
char correct;
152-
};
153-
154-
struct hw_branch_entry {
155-
struct trace_entry ent;
156-
u64 from;
157-
u64 to;
158-
};
159-
160-
struct trace_power {
161-
struct trace_entry ent;
162-
struct power_trace state_data;
163-
};
65+
#undef FTRACE_ENTRY
66+
#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
67+
struct struct_name { \
68+
struct trace_entry ent; \
69+
tstruct \
70+
}
16471

165-
enum kmemtrace_type_id {
166-
KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
167-
KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
168-
KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
169-
};
72+
#undef TP_ARGS
73+
#define TP_ARGS(args...) args
17074

171-
struct kmemtrace_alloc_entry {
172-
struct trace_entry ent;
173-
enum kmemtrace_type_id type_id;
174-
unsigned long call_site;
175-
const void *ptr;
176-
size_t bytes_req;
177-
size_t bytes_alloc;
178-
gfp_t gfp_flags;
179-
int node;
180-
};
75+
#undef FTRACE_ENTRY_DUP
76+
#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
18177

182-
struct kmemtrace_free_entry {
183-
struct trace_entry ent;
184-
enum kmemtrace_type_id type_id;
185-
unsigned long call_site;
186-
const void *ptr;
187-
};
78+
#include "trace_entries.h"
18879

80+
/*
81+
* syscalls are special, and need special handling, this is why
82+
* they are not included in trace_entries.h
83+
*/
18984
struct syscall_trace_enter {
19085
struct trace_entry ent;
19186
int nr;
@@ -198,7 +93,6 @@ struct syscall_trace_exit {
19893
unsigned long ret;
19994
};
20095

201-
20296
/*
20397
* trace_flag_type is an enumeration that holds different
20498
* states when a trace occurs. These are:

0 commit comments

Comments
 (0)