diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-09 07:18:48 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-09 06:21:18 -0400 |
commit | ec72e576dfcb1cb0ce0141801f3ee829f6e35137 (patch) | |
tree | 74cec0bfcea8dafbd2c4e4fe318045f27ca3e14e /include | |
parent | 1921674066c4ccb534e357c69629e365be626e0e (diff) |
Add tracepoint support
This patch integrates LITMUS^RT's sched_trace_XXX() macros with
Linux's notion of tracepoints. This is useful to visualize schedules
in kernel shark and similar tools. Historically, LITMUS^RT's
sched_trace predates Linux's tracepoint infrastructure.
Diffstat (limited to 'include')
-rw-r--r-- | include/litmus/sched_trace.h | 8 | ||||
-rw-r--r-- | include/trace/events/litmus.h | 231 |
2 files changed, 239 insertions, 0 deletions
diff --git a/include/litmus/sched_trace.h b/include/litmus/sched_trace.h index 6044d9f0a05a..82bde8241298 100644 --- a/include/litmus/sched_trace.h +++ b/include/litmus/sched_trace.h | |||
@@ -194,24 +194,28 @@ feather_callback void do_sched_trace_sys_release(unsigned long id, | |||
194 | do { \ | 194 | do { \ |
195 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 2, \ | 195 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 2, \ |
196 | do_sched_trace_task_param, t); \ | 196 | do_sched_trace_task_param, t); \ |
197 | trace_litmus_task_param(t); \ | ||
197 | } while (0) | 198 | } while (0) |
198 | 199 | ||
199 | #define sched_trace_task_release(t) \ | 200 | #define sched_trace_task_release(t) \ |
200 | do { \ | 201 | do { \ |
201 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 3, \ | 202 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 3, \ |
202 | do_sched_trace_task_release, t); \ | 203 | do_sched_trace_task_release, t); \ |
204 | trace_litmus_task_release(t); \ | ||
203 | } while (0) | 205 | } while (0) |
204 | 206 | ||
205 | #define sched_trace_task_switch_to(t) \ | 207 | #define sched_trace_task_switch_to(t) \ |
206 | do { \ | 208 | do { \ |
207 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 4, \ | 209 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 4, \ |
208 | do_sched_trace_task_switch_to, t); \ | 210 | do_sched_trace_task_switch_to, t); \ |
211 | trace_litmus_switch_to(t); \ | ||
209 | } while (0) | 212 | } while (0) |
210 | 213 | ||
211 | #define sched_trace_task_switch_away(t) \ | 214 | #define sched_trace_task_switch_away(t) \ |
212 | do { \ | 215 | do { \ |
213 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 5, \ | 216 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 5, \ |
214 | do_sched_trace_task_switch_away, t); \ | 217 | do_sched_trace_task_switch_away, t); \ |
218 | trace_litmus_switch_away(t); \ | ||
215 | } while (0) | 219 | } while (0) |
216 | 220 | ||
217 | #define sched_trace_task_completion(t, forced) \ | 221 | #define sched_trace_task_completion(t, forced) \ |
@@ -219,18 +223,21 @@ feather_callback void do_sched_trace_sys_release(unsigned long id, | |||
219 | SCHED_TRACE2(SCHED_TRACE_BASE_ID + 6, \ | 223 | SCHED_TRACE2(SCHED_TRACE_BASE_ID + 6, \ |
220 | do_sched_trace_task_completion, t, \ | 224 | do_sched_trace_task_completion, t, \ |
221 | (unsigned long) forced); \ | 225 | (unsigned long) forced); \ |
226 | trace_litmus_task_completion(t, forced); \ | ||
222 | } while (0) | 227 | } while (0) |
223 | 228 | ||
224 | #define sched_trace_task_block(t) \ | 229 | #define sched_trace_task_block(t) \ |
225 | do { \ | 230 | do { \ |
226 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \ | 231 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \ |
227 | do_sched_trace_task_block, t); \ | 232 | do_sched_trace_task_block, t); \ |
233 | trace_litmus_task_block(t); \ | ||
228 | } while (0) | 234 | } while (0) |
229 | 235 | ||
230 | #define sched_trace_task_resume(t) \ | 236 | #define sched_trace_task_resume(t) \ |
231 | do { \ | 237 | do { \ |
232 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \ | 238 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \ |
233 | do_sched_trace_task_resume, t); \ | 239 | do_sched_trace_task_resume, t); \ |
240 | trace_litmus_task_resume(t); \ | ||
234 | } while (0) | 241 | } while (0) |
235 | 242 | ||
236 | #define sched_trace_action(t, action) \ | 243 | #define sched_trace_action(t, action) \ |
@@ -242,6 +249,7 @@ feather_callback void do_sched_trace_sys_release(unsigned long id, | |||
242 | do { \ | 249 | do { \ |
243 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 10, \ | 250 | SCHED_TRACE(SCHED_TRACE_BASE_ID + 10, \ |
244 | do_sched_trace_sys_release, when); \ | 251 | do_sched_trace_sys_release, when); \ |
252 | trace_litmus_sys_release(when); \ | ||
245 | } while (0) | 253 | } while (0) |
246 | 254 | ||
247 | #define sched_trace_quantum_boundary() /* NOT IMPLEMENTED */ | 255 | #define sched_trace_quantum_boundary() /* NOT IMPLEMENTED */ |
diff --git a/include/trace/events/litmus.h b/include/trace/events/litmus.h new file mode 100644 index 000000000000..0fffcee02be0 --- /dev/null +++ b/include/trace/events/litmus.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * LITMUS^RT kernel style scheduling tracepoints | ||
3 | */ | ||
4 | #undef TRACE_SYSTEM | ||
5 | #define TRACE_SYSTEM litmus | ||
6 | |||
7 | #if !defined(_SCHED_TASK_TRACEPOINT_H) || defined(TRACE_HEADER_MULTI_READ) | ||
8 | #define _SCHED_TASK_TRACEPOINT_H | ||
9 | |||
10 | #include <linux/tracepoint.h> | ||
11 | |||
12 | #include <litmus/litmus.h> | ||
13 | #include <litmus/rt_param.h> | ||
14 | |||
15 | /* | ||
16 | * Tracing task admission | ||
17 | */ | ||
18 | TRACE_EVENT(litmus_task_param, | ||
19 | |||
20 | TP_PROTO(struct task_struct *t), | ||
21 | |||
22 | TP_ARGS(t), | ||
23 | |||
24 | TP_STRUCT__entry( | ||
25 | __field( pid_t, pid ) | ||
26 | __field( unsigned int, job ) | ||
27 | __field( lt_t, wcet ) | ||
28 | __field( lt_t, period ) | ||
29 | __field( lt_t, phase ) | ||
30 | __field( int, partition ) | ||
31 | ), | ||
32 | |||
33 | TP_fast_assign( | ||
34 | __entry->pid = t ? t->pid : 0; | ||
35 | __entry->job = t ? t->rt_param.job_params.job_no : 0; | ||
36 | __entry->wcet = get_exec_cost(t); | ||
37 | __entry->period = get_rt_period(t); | ||
38 | __entry->phase = get_rt_phase(t); | ||
39 | __entry->partition = get_partition(t); | ||
40 | ), | ||
41 | |||
42 | TP_printk("period(%d, %Lu).\nwcet(%d, %Lu).\n", | ||
43 | __entry->pid, __entry->period, | ||
44 | __entry->pid, __entry->wcet) | ||
45 | ); | ||
46 | |||
47 | /* | ||
48 | * Tracing jobs release | ||
49 | */ | ||
50 | TRACE_EVENT(litmus_task_release, | ||
51 | |||
52 | TP_PROTO(struct task_struct *t), | ||
53 | |||
54 | TP_ARGS(t), | ||
55 | |||
56 | TP_STRUCT__entry( | ||
57 | __field( pid_t, pid ) | ||
58 | __field( unsigned int, job ) | ||
59 | __field( lt_t, release ) | ||
60 | __field( lt_t, deadline ) | ||
61 | ), | ||
62 | |||
63 | TP_fast_assign( | ||
64 | __entry->pid = t ? t->pid : 0; | ||
65 | __entry->job = t ? t->rt_param.job_params.job_no : 0; | ||
66 | __entry->release = get_release(t); | ||
67 | __entry->deadline = get_deadline(t); | ||
68 | ), | ||
69 | |||
70 | TP_printk("release(job(%u, %u)): %Lu\ndeadline(job(%u, %u)): %Lu\n", | ||
71 | __entry->pid, __entry->job, __entry->release, | ||
72 | __entry->pid, __entry->job, __entry->deadline) | ||
73 | ); | ||
74 | |||
75 | /* | ||
76 | * Tracepoint for switching to new task | ||
77 | */ | ||
78 | TRACE_EVENT(litmus_switch_to, | ||
79 | |||
80 | TP_PROTO(struct task_struct *t), | ||
81 | |||
82 | TP_ARGS(t), | ||
83 | |||
84 | TP_STRUCT__entry( | ||
85 | __field( pid_t, pid ) | ||
86 | __field( unsigned int, job ) | ||
87 | __field( lt_t, when ) | ||
88 | __field( lt_t, exec_time ) | ||
89 | ), | ||
90 | |||
91 | TP_fast_assign( | ||
92 | __entry->pid = is_realtime(t) ? t->pid : 0; | ||
93 | __entry->job = is_realtime(t) ? t->rt_param.job_params.job_no : 0; | ||
94 | __entry->when = litmus_clock(); | ||
95 | __entry->exec_time = get_exec_time(t); | ||
96 | ), | ||
97 | |||
98 | TP_printk("switch_to(job(%u, %u)): %Lu (exec: %Lu)\n", | ||
99 | __entry->pid, __entry->job, | ||
100 | __entry->when, __entry->exec_time) | ||
101 | ); | ||
102 | |||
103 | /* | ||
104 | * Tracepoint for switching away previous task | ||
105 | */ | ||
106 | TRACE_EVENT(litmus_switch_away, | ||
107 | |||
108 | TP_PROTO(struct task_struct *t), | ||
109 | |||
110 | TP_ARGS(t), | ||
111 | |||
112 | TP_STRUCT__entry( | ||
113 | __field( pid_t, pid ) | ||
114 | __field( unsigned int, job ) | ||
115 | __field( lt_t, when ) | ||
116 | __field( lt_t, exec_time ) | ||
117 | ), | ||
118 | |||
119 | TP_fast_assign( | ||
120 | __entry->pid = is_realtime(t) ? t->pid : 0; | ||
121 | __entry->job = is_realtime(t) ? t->rt_param.job_params.job_no : 0; | ||
122 | __entry->when = litmus_clock(); | ||
123 | __entry->exec_time = get_exec_time(t); | ||
124 | ), | ||
125 | |||
126 | TP_printk("switch_away(job(%u, %u)): %Lu (exec: %Lu)\n", | ||
127 | __entry->pid, __entry->job, | ||
128 | __entry->when, __entry->exec_time) | ||
129 | ); | ||
130 | |||
131 | /* | ||
132 | * Tracing jobs completion | ||
133 | */ | ||
134 | TRACE_EVENT(litmus_task_completion, | ||
135 | |||
136 | TP_PROTO(struct task_struct *t, unsigned long forced), | ||
137 | |||
138 | TP_ARGS(t, forced), | ||
139 | |||
140 | TP_STRUCT__entry( | ||
141 | __field( pid_t, pid ) | ||
142 | __field( unsigned int, job ) | ||
143 | __field( lt_t, when ) | ||
144 | __field( unsigned long, forced ) | ||
145 | ), | ||
146 | |||
147 | TP_fast_assign( | ||
148 | __entry->pid = t ? t->pid : 0; | ||
149 | __entry->job = t ? t->rt_param.job_params.job_no : 0; | ||
150 | __entry->when = litmus_clock(); | ||
151 | __entry->forced = forced; | ||
152 | ), | ||
153 | |||
154 | TP_printk("completed(job(%u, %u)): %Lu (forced: %lu)\n", | ||
155 | __entry->pid, __entry->job, | ||
156 | __entry->when, __entry->forced) | ||
157 | ); | ||
158 | |||
159 | /* | ||
160 | * Trace blocking tasks. | ||
161 | */ | ||
162 | TRACE_EVENT(litmus_task_block, | ||
163 | |||
164 | TP_PROTO(struct task_struct *t), | ||
165 | |||
166 | TP_ARGS(t), | ||
167 | |||
168 | TP_STRUCT__entry( | ||
169 | __field( pid_t, pid ) | ||
170 | __field( lt_t, when ) | ||
171 | ), | ||
172 | |||
173 | TP_fast_assign( | ||
174 | __entry->pid = t ? t->pid : 0; | ||
175 | __entry->when = litmus_clock(); | ||
176 | ), | ||
177 | |||
178 | TP_printk("(%u) blocks: %Lu\n", __entry->pid, __entry->when) | ||
179 | ); | ||
180 | |||
181 | /* | ||
182 | * Tracing jobs resume | ||
183 | */ | ||
184 | TRACE_EVENT(litmus_task_resume, | ||
185 | |||
186 | TP_PROTO(struct task_struct *t), | ||
187 | |||
188 | TP_ARGS(t), | ||
189 | |||
190 | TP_STRUCT__entry( | ||
191 | __field( pid_t, pid ) | ||
192 | __field( unsigned int, job ) | ||
193 | __field( lt_t, when ) | ||
194 | ), | ||
195 | |||
196 | TP_fast_assign( | ||
197 | __entry->pid = t ? t->pid : 0; | ||
198 | __entry->job = t ? t->rt_param.job_params.job_no : 0; | ||
199 | __entry->when = litmus_clock(); | ||
200 | ), | ||
201 | |||
202 | TP_printk("resume(job(%u, %u)): %Lu\n", | ||
203 | __entry->pid, __entry->job, __entry->when) | ||
204 | ); | ||
205 | |||
206 | /* | ||
207 | * Trace synchronous release | ||
208 | */ | ||
209 | TRACE_EVENT(litmus_sys_release, | ||
210 | |||
211 | TP_PROTO(lt_t *start), | ||
212 | |||
213 | TP_ARGS(start), | ||
214 | |||
215 | TP_STRUCT__entry( | ||
216 | __field( lt_t, rel ) | ||
217 | __field( lt_t, when ) | ||
218 | ), | ||
219 | |||
220 | TP_fast_assign( | ||
221 | __entry->rel = *start; | ||
222 | __entry->when = litmus_clock(); | ||
223 | ), | ||
224 | |||
225 | TP_printk("SynRelease(%Lu) at %Lu\n", __entry->rel, __entry->when) | ||
226 | ); | ||
227 | |||
228 | #endif /* _SCHED_TASK_TRACEPOINT_H */ | ||
229 | |||
230 | /* Must stay outside the protection */ | ||
231 | #include <trace/define_trace.h> | ||