aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2015-08-09 07:18:47 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2015-08-09 06:21:18 -0400
commit1921674066c4ccb534e357c69629e365be626e0e (patch)
treed8d6bdf12b6b71223a3afdea5561adc26458f7fd /include/litmus
parent8bee6550e07cd89133cbae0c7a6f6097a2011d58 (diff)
Add schedule tracing support
This patch introduces the sched_trace infrastructure, which in principle allows tracing the generated schedule. However, this patch does not yet integrate the callbacks with the kernel.
Diffstat (limited to 'include/litmus')
-rw-r--r--include/litmus/sched_trace.h251
1 files changed, 251 insertions, 0 deletions
diff --git a/include/litmus/sched_trace.h b/include/litmus/sched_trace.h
new file mode 100644
index 000000000000..6044d9f0a05a
--- /dev/null
+++ b/include/litmus/sched_trace.h
@@ -0,0 +1,251 @@
1/*
2 * sched_trace.h -- record scheduler events to a byte stream for offline analysis.
3 */
4#ifndef _LINUX_SCHED_TRACE_H_
5#define _LINUX_SCHED_TRACE_H_
6
7/* all times in nanoseconds */
8
9struct st_trace_header {
10 u8 type; /* Of what type is this record? */
11 u8 cpu; /* On which CPU was it recorded? */
12 u16 pid; /* PID of the task. */
13 u32 job; /* The job sequence number. */
14};
15
16#define ST_NAME_LEN 16
17struct st_name_data {
18 char cmd[ST_NAME_LEN];/* The name of the executable of this process. */
19};
20
21struct st_param_data { /* regular params */
22 u32 wcet;
23 u32 period;
24 u32 phase;
25 u8 partition;
26 u8 class;
27 u8 __unused[2];
28};
29
30struct st_release_data { /* A job is was/is going to be released. */
31 u64 release; /* What's the release time? */
32 u64 deadline; /* By when must it finish? */
33};
34
35struct st_assigned_data { /* A job was asigned to a CPU. */
36 u64 when;
37 u8 target; /* Where should it execute? */
38 u8 __unused[7];
39};
40
41struct st_switch_to_data { /* A process was switched to on a given CPU. */
42 u64 when; /* When did this occur? */
43 u32 exec_time; /* Time the current job has executed. */
44 u8 __unused[4];
45
46};
47
48struct st_switch_away_data { /* A process was switched away from on a given CPU. */
49 u64 when;
50 u64 exec_time;
51};
52
53struct st_completion_data { /* A job completed. */
54 u64 when;
55 u8 forced:1; /* Set to 1 if job overran and kernel advanced to the
56 * next task automatically; set to 0 otherwise.
57 */
58 u8 __uflags:7;
59 u8 __unused[7];
60};
61
62struct st_block_data { /* A task blocks. */
63 u64 when;
64 u64 __unused;
65};
66
67struct st_resume_data { /* A task resumes. */
68 u64 when;
69 u64 __unused;
70};
71
72struct st_action_data {
73 u64 when;
74 u8 action;
75 u8 __unused[7];
76};
77
78struct st_sys_release_data {
79 u64 when;
80 u64 release;
81};
82
83#define DATA(x) struct st_ ## x ## _data x;
84
85typedef enum {
86 ST_NAME = 1, /* Start at one, so that we can spot
87 * uninitialized records. */
88 ST_PARAM,
89 ST_RELEASE,
90 ST_ASSIGNED,
91 ST_SWITCH_TO,
92 ST_SWITCH_AWAY,
93 ST_COMPLETION,
94 ST_BLOCK,
95 ST_RESUME,
96 ST_ACTION,
97 ST_SYS_RELEASE
98} st_event_record_type_t;
99
100struct st_event_record {
101 struct st_trace_header hdr;
102 union {
103 u64 raw[2];
104
105 DATA(name);
106 DATA(param);
107 DATA(release);
108 DATA(assigned);
109 DATA(switch_to);
110 DATA(switch_away);
111 DATA(completion);
112 DATA(block);
113 DATA(resume);
114 DATA(action);
115 DATA(sys_release);
116 } data;
117};
118
119#undef DATA
120
121#ifdef __KERNEL__
122
123#include <linux/sched.h>
124#include <litmus/feather_trace.h>
125
126#ifdef CONFIG_SCHED_TASK_TRACE
127
128#define SCHED_TRACE(id, callback, task) \
129 ft_event1(id, callback, task)
130#define SCHED_TRACE2(id, callback, task, xtra) \
131 ft_event2(id, callback, task, xtra)
132
133/* provide prototypes; needed on sparc64 */
134#ifndef NO_TASK_TRACE_DECLS
135feather_callback void do_sched_trace_task_name(unsigned long id,
136 struct task_struct* task);
137feather_callback void do_sched_trace_task_param(unsigned long id,
138 struct task_struct* task);
139feather_callback void do_sched_trace_task_release(unsigned long id,
140 struct task_struct* task);
141feather_callback void do_sched_trace_task_switch_to(unsigned long id,
142 struct task_struct* task);
143feather_callback void do_sched_trace_task_switch_away(unsigned long id,
144 struct task_struct* task);
145feather_callback void do_sched_trace_task_completion(unsigned long id,
146 struct task_struct* task,
147 unsigned long forced);
148feather_callback void do_sched_trace_task_block(unsigned long id,
149 struct task_struct* task);
150feather_callback void do_sched_trace_task_resume(unsigned long id,
151 struct task_struct* task);
152feather_callback void do_sched_trace_action(unsigned long id,
153 struct task_struct* task,
154 unsigned long action);
155feather_callback void do_sched_trace_sys_release(unsigned long id,
156 lt_t* start);
157
158#endif
159
160#else
161
162#define SCHED_TRACE(id, callback, task) /* no tracing */
163#define SCHED_TRACE2(id, callback, task, xtra) /* no tracing */
164
165#endif
166
167#ifdef CONFIG_SCHED_LITMUS_TRACEPOINT
168
169#include <trace/events/litmus.h>
170
171#else
172
173/* Override trace macros to actually do nothing */
174#define trace_litmus_task_param(t)
175#define trace_litmus_task_release(t)
176#define trace_litmus_switch_to(t)
177#define trace_litmus_switch_away(prev)
178#define trace_litmus_task_completion(t, forced)
179#define trace_litmus_task_block(t)
180#define trace_litmus_task_resume(t)
181#define trace_litmus_sys_release(start)
182
183#endif
184
185
186#define SCHED_TRACE_BASE_ID 500
187
188
189#define sched_trace_task_name(t) \
190 SCHED_TRACE(SCHED_TRACE_BASE_ID + 1, \
191 do_sched_trace_task_name, t)
192
193#define sched_trace_task_param(t) \
194 do { \
195 SCHED_TRACE(SCHED_TRACE_BASE_ID + 2, \
196 do_sched_trace_task_param, t); \
197 } while (0)
198
199#define sched_trace_task_release(t) \
200 do { \
201 SCHED_TRACE(SCHED_TRACE_BASE_ID + 3, \
202 do_sched_trace_task_release, t); \
203 } while (0)
204
205#define sched_trace_task_switch_to(t) \
206 do { \
207 SCHED_TRACE(SCHED_TRACE_BASE_ID + 4, \
208 do_sched_trace_task_switch_to, t); \
209 } while (0)
210
211#define sched_trace_task_switch_away(t) \
212 do { \
213 SCHED_TRACE(SCHED_TRACE_BASE_ID + 5, \
214 do_sched_trace_task_switch_away, t); \
215 } while (0)
216
217#define sched_trace_task_completion(t, forced) \
218 do { \
219 SCHED_TRACE2(SCHED_TRACE_BASE_ID + 6, \
220 do_sched_trace_task_completion, t, \
221 (unsigned long) forced); \
222 } while (0)
223
224#define sched_trace_task_block(t) \
225 do { \
226 SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \
227 do_sched_trace_task_block, t); \
228 } while (0)
229
230#define sched_trace_task_resume(t) \
231 do { \
232 SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \
233 do_sched_trace_task_resume, t); \
234 } while (0)
235
236#define sched_trace_action(t, action) \
237 SCHED_TRACE2(SCHED_TRACE_BASE_ID + 9, \
238 do_sched_trace_action, t, (unsigned long) action);
239
240/* when is a pointer, it does not need an explicit cast to unsigned long */
241#define sched_trace_sys_release(when) \
242 do { \
243 SCHED_TRACE(SCHED_TRACE_BASE_ID + 10, \
244 do_sched_trace_sys_release, when); \
245 } while (0)
246
247#define sched_trace_quantum_boundary() /* NOT IMPLEMENTED */
248
249#endif /* __KERNEL__ */
250
251#endif