aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/sched_trace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/litmus/sched_trace.h')
-rw-r--r--include/litmus/sched_trace.h191
1 files changed, 191 insertions, 0 deletions
diff --git a/include/litmus/sched_trace.h b/include/litmus/sched_trace.h
new file mode 100644
index 000000000000..afd0391d127b
--- /dev/null
+++ b/include/litmus/sched_trace.h
@@ -0,0 +1,191 @@
1/* sched_trace.h -- record scheduler events to a byte stream for offline analysis.
2 */
3#ifndef _LINUX_SCHED_TRACE_H_
4#define _LINUX_SCHED_TRACE_H_
5
6/* all times in nanoseconds */
7
8struct st_trace_header {
9 u8 type; /* Of what type is this record? */
10 u8 cpu; /* On which CPU was it recorded? */
11 u16 pid; /* PID of the task. */
12 u32 job; /* The job sequence number. */
13};
14
15#define ST_NAME_LEN 16
16struct st_name_data {
17 char cmd[ST_NAME_LEN];/* The name of the executable of this process. */
18};
19
20struct st_param_data { /* regular params */
21 u32 wcet;
22 u32 period;
23 u32 phase;
24 u8 partition;
25 u8 __unused[3];
26};
27
28struct st_release_data { /* A job is was/is going to be released. */
29 u64 release; /* What's the release time? */
30 u64 deadline; /* By when must it finish? */
31};
32
33struct st_assigned_data { /* A job was asigned to a CPU. */
34 u64 when;
35 u8 target; /* Where should it execute? */
36 u8 __unused[3];
37};
38
39struct st_switch_to_data { /* A process was switched to on a given CPU. */
40 u64 when; /* When did this occur? */
41 u32 exec_time; /* Time the current job has executed. */
42
43};
44
45struct st_switch_away_data { /* A process was switched away from on a given CPU. */
46 u64 when;
47 u64 exec_time;
48};
49
50struct st_completion_data { /* A job completed. */
51 u64 when;
52 u8 forced:1; /* Set to 1 if job overran and kernel advanced to the
53 * next task automatically; set to 0 otherwise.
54 */
55 u8 __uflags:7;
56 u8 __unused[3];
57};
58
59struct st_block_data { /* A task blocks. */
60 u64 when;
61 u64 __unused;
62};
63
64struct st_resume_data { /* A task resumes. */
65 u64 when;
66 u64 __unused;
67};
68
69struct st_sys_release_data {
70 u64 when;
71 u64 release;
72};
73
74#define DATA(x) struct st_ ## x ## _data x;
75
76typedef enum {
77 ST_NAME = 1, /* Start at one, so that we can spot
78 * uninitialized records. */
79 ST_PARAM,
80 ST_RELEASE,
81 ST_ASSIGNED,
82 ST_SWITCH_TO,
83 ST_SWITCH_AWAY,
84 ST_COMPLETION,
85 ST_BLOCK,
86 ST_RESUME,
87 ST_SYS_RELEASE,
88} st_event_record_type_t;
89
90struct st_event_record {
91 struct st_trace_header hdr;
92 union {
93 u64 raw[2];
94
95 DATA(name);
96 DATA(param);
97 DATA(release);
98 DATA(assigned);
99 DATA(switch_to);
100 DATA(switch_away);
101 DATA(completion);
102 DATA(block);
103 DATA(resume);
104 DATA(sys_release);
105
106 } data;
107};
108
109#undef DATA
110
111#ifdef __KERNEL__
112
113#include <linux/sched.h>
114#include <litmus/feather_trace.h>
115
116#ifdef CONFIG_SCHED_TASK_TRACE
117
118#define SCHED_TRACE(id, callback, task) \
119 ft_event1(id, callback, task)
120#define SCHED_TRACE2(id, callback, task, xtra) \
121 ft_event2(id, callback, task, xtra)
122
123/* provide prototypes; needed on sparc64 */
124#ifndef NO_TASK_TRACE_DECLS
125feather_callback void do_sched_trace_task_name(unsigned long id,
126 struct task_struct* task);
127feather_callback void do_sched_trace_task_param(unsigned long id,
128 struct task_struct* task);
129feather_callback void do_sched_trace_task_release(unsigned long id,
130 struct task_struct* task);
131feather_callback void do_sched_trace_task_switch_to(unsigned long id,
132 struct task_struct* task);
133feather_callback void do_sched_trace_task_switch_away(unsigned long id,
134 struct task_struct* task);
135feather_callback void do_sched_trace_task_completion(unsigned long id,
136 struct task_struct* task,
137 unsigned long forced);
138feather_callback void do_sched_trace_task_block(unsigned long id,
139 struct task_struct* task);
140feather_callback void do_sched_trace_task_resume(unsigned long id,
141 struct task_struct* task);
142feather_callback void do_sched_trace_sys_release(unsigned long id,
143 lt_t* start);
144#endif
145
146#else
147
148#define SCHED_TRACE(id, callback, task) /* no tracing */
149#define SCHED_TRACE2(id, callback, task, xtra) /* no tracing */
150
151#endif
152
153
154#define SCHED_TRACE_BASE_ID 500
155
156
157#define sched_trace_task_name(t) \
158 SCHED_TRACE(SCHED_TRACE_BASE_ID + 1, do_sched_trace_task_name, t)
159#define sched_trace_task_param(t) \
160 SCHED_TRACE(SCHED_TRACE_BASE_ID + 2, do_sched_trace_task_param, t)
161#define sched_trace_task_release(t) \
162 SCHED_TRACE(SCHED_TRACE_BASE_ID + 3, do_sched_trace_task_release, t)
163#define sched_trace_task_switch_to(t) \
164 SCHED_TRACE(SCHED_TRACE_BASE_ID + 4, do_sched_trace_task_switch_to, t)
165#define sched_trace_task_switch_away(t) \
166 SCHED_TRACE(SCHED_TRACE_BASE_ID + 5, do_sched_trace_task_switch_away, t)
167#define sched_trace_task_completion(t, forced) \
168 SCHED_TRACE2(SCHED_TRACE_BASE_ID + 6, do_sched_trace_task_completion, t, \
169 forced)
170#define sched_trace_task_block(t) \
171 SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, do_sched_trace_task_block, t)
172#define sched_trace_task_resume(t) \
173 SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, do_sched_trace_task_resume, t)
174
175#define sched_trace_sys_release(when) \
176 SCHED_TRACE(SCHED_TRACE_BASE_ID + 9, do_sched_trace_sys_release, when)
177
178#define sched_trace_quantum_boundary() /* NOT IMPLEMENTED */
179
180#ifdef CONFIG_SCHED_DEBUG_TRACE
181void sched_trace_log_message(const char* fmt, ...);
182void dump_trace_buffer(int max);
183#else
184
185#define sched_trace_log_message(fmt, ...)
186
187#endif
188
189#endif /* __KERNEL__ */
190
191#endif