summaryrefstree
path: root/kernel/include/trace/events/marker.h
blob: 2347eed0c889396a38825be7490ac223be403d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM marker

#if !defined(_TRACE_MARKER_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_MARKER_H

#include <linux/types.h>
#include <linux/tracepoint.h>

DECLARE_EVENT_CLASS(mark_begin_end,

	TP_PROTO(char event_type,
		const char *category,
		const char *title,
		const char *name,
		unsigned long value,
		char ignore_pid),

	TP_ARGS(event_type, category, title, name, value, ignore_pid),

	TP_STRUCT__entry(
		__field(char,	event_type)
		__field(unsigned long, pid)
		__field(const char*, category)
		__field(const char*, title)
		__field(const char*, name)
		__field(unsigned long, value)
	),

	TP_fast_assign(
		__entry->event_type = event_type;
		__entry->pid = (ignore_pid) ? 0:current->tgid;
		__entry->category = category;
		__entry->title = title;
		__entry->name = name;
		__entry->value = value;
	),

	TP_printk("%c|%lu|%s:%s|%s=%lu;",
		__entry->event_type,
		__entry->pid,
		__entry->category,
		__entry->title,
		__entry->name,
		__entry->value
	)
);

DEFINE_EVENT(mark_begin_end, mark_begin_end,

	TP_PROTO(char event_type,
		const char *category,
		const char *title,
		const char *name,
		unsigned long value,
		char ignore_pid),

	TP_ARGS(event_type, category, title, name, value, ignore_pid)
);

DECLARE_EVENT_CLASS(mark_start_finish,

	TP_PROTO(char event_type,
		const char *category,
		const char *title,
		unsigned long cookie,
		const char *name,
		unsigned long value,
		char ignore_pid),

	TP_ARGS(event_type, category, title, cookie, name, value, ignore_pid),

	TP_STRUCT__entry(
		__field(char, event_type)
		__field(unsigned long, pid)
		__field(const char*, category)
		__field(const char*, title)
		__field(unsigned long, cookie)
		__field(const char*, name)
		__field(unsigned long, value)
	),

	TP_fast_assign(
		__entry->event_type = event_type;
		__entry->pid = (ignore_pid) ? 0:current->tgid;
		__entry->category = category;
		__entry->title = title;
		__entry->cookie = cookie;
		__entry->name = name;
		__entry->value = value;
	),

	TP_printk("%c|%lu|%s:%s|%lu|%s=%lu;",
		__entry->event_type,
		__entry->pid,
		__entry->category,
		__entry->title,
		__entry->cookie,
		__entry->name,
		__entry->value
	)
);

DEFINE_EVENT(mark_start_finish, mark_start_finish,

	TP_PROTO(char event_type,
		const char *category,
		const char *title,
		unsigned long cookie,
		const char *name,
		unsigned long value,
		char ignore_pid),

	TP_ARGS(event_type, category, title, cookie, name, value, ignore_pid)
);

DECLARE_EVENT_CLASS(mark_count,

	TP_PROTO(char event_type,
		const char *category,
		const char *name,
		unsigned long value,
		unsigned long ref_01,
		unsigned long ref_02,
		unsigned long ref_03,
		char ignore_pid),

	TP_ARGS(event_type, category, name, value, ref_01, ref_02, ref_03, ignore_pid),

	TP_STRUCT__entry(
		__field(char, event_type)
		__field(unsigned long, pid)
		__field(const char*, category)
		__field(const char*, name)
		__field(unsigned long, value)
		__field(unsigned long, ref_01)
		__field(unsigned long, ref_02)
		__field(unsigned long, ref_03)
	),

	TP_fast_assign(
		__entry->event_type = 'C';
		__entry->pid = (ignore_pid) ? 0:current->tgid;
		__entry->category = category;
		__entry->name = name;
		__entry->value = value;
		__entry->ref_01 = ref_01;
		__entry->ref_02 = ref_02;
		__entry->ref_03 = ref_03;
	),

	TP_printk("%c|%lu|%s:%s|%lu|%lu|%lu|%lu",
		__entry->event_type,
		__entry->pid,
		__entry->category,
		__entry->name,
		__entry->value,
		__entry->ref_01,
		__entry->ref_02,
		__entry->ref_03
	)
);

DEFINE_EVENT(mark_count, mark_count,

	TP_PROTO(char event_type,
		const char *category,
		const char *name,
		unsigned long value,
		unsigned long ref_01,
		unsigned long ref_02,
		unsigned long ref_03,
		char ignore_pid),

	TP_ARGS(event_type, category, name, value, ref_01, ref_02, ref_03, ignore_pid)
);

#endif /* _TRACE_MARKER_H */

/* This part must be outside protection */
#include <trace/define_trace.h>




/*
 * Usage
 *

#define CREATE_TRACE_POINTS
#include <trace/events/marker.h>

trace_mark_begin_end('B', "category", "title", "arg_name", arg_value, 0);
trace_mark_begin_end('E', "category", "title", "arg_name", arg_value, 0);

trace_mark_start_finish('S', "category", "title", cookie, "arg_name", arg_value, 0);
trace_mark_start_finish('F', "category", "title", cookie, "arg_name", arg_value, 0);

trace_mark_count('C', "category", "name", value, ref_01, ref_02, ref_03, 1);

 */