aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-10-28 18:07:23 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2014-03-03 10:07:31 -0500
commit3962195280fa0694d04db975120c499adf5ea79d (patch)
treeb316e78a7c46aeb0e00f88a5c510d7a620f4ec02
parenta34cfefd7e22f2acfcd5a2f857f6a17f57b4e249 (diff)
Extend sched_plugin API for GPUSync.
Patch adds new interfaces to the sched_plugin struct/API. New interfaces expose task prioritization and inheritance routines of a scheduler to external components. For example, a single locking protocol implementation can support both FIFO and EDF prioritization via this API ("litmus->compare(a, b)").
-rw-r--r--include/litmus/sched_plugin.h84
-rw-r--r--litmus/sched_plugin.c113
2 files changed, 189 insertions, 8 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index d65ae5ad8f91..8f458ffc4134 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -19,7 +19,6 @@ typedef long (*deactivate_plugin_t) (void);
19struct domain_proc_info; 19struct domain_proc_info;
20typedef long (*get_domain_proc_info_t) (struct domain_proc_info **info); 20typedef long (*get_domain_proc_info_t) (struct domain_proc_info **info);
21 21
22
23/********************* scheduler invocation ******************/ 22/********************* scheduler invocation ******************/
24 23
25/* Plugin-specific realtime tick handler */ 24/* Plugin-specific realtime tick handler */
@@ -61,14 +60,60 @@ typedef void (*task_exit_t) (struct task_struct *);
61 */ 60 */
62typedef void (*task_cleanup_t) (struct task_struct *); 61typedef void (*task_cleanup_t) (struct task_struct *);
63 62
63/**************************** misc ***************************/
64
65/* Called to compare the scheduling priorities between two tasks */
66typedef int (*higher_prio_t)(struct task_struct* a, struct task_struct* b);
67
68
69/************** locking and inheritance routines *************/
64#ifdef CONFIG_LITMUS_LOCKING 70#ifdef CONFIG_LITMUS_LOCKING
65/* Called when the current task attempts to create a new lock of a given 71/* Called when the current task attempts to create a new lock of a given
66 * protocol type. */ 72 * protocol type. */
67typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type, 73typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type,
68 void* __user config); 74 void* __user config);
75
76typedef void (*increase_prio_t)(struct task_struct* t,
77 struct task_struct* prio_inh);
78typedef void (*decrease_prio_t)(struct task_struct* t,
79 struct task_struct* prio_inh, int budget_triggered);
80typedef int (*__increase_prio_t)(struct task_struct* t,
81 struct task_struct* prio_inh);
82typedef int (*__decrease_prio_t)(struct task_struct* t,
83 struct task_struct* prio_inh, int budget_triggered);
84
85#ifdef CONFIG_LITMUS_NESTED_LOCKING
86typedef enum
87{
88 BASE,
89 EFFECTIVE
90} comparison_mode_t;
91typedef void (*nested_increase_prio_t)(struct task_struct* t,
92 struct task_struct* prio_inh, raw_spinlock_t *to_unlock,
93 unsigned long irqflags);
94typedef void (*nested_decrease_prio_t)(struct task_struct* t,
95 struct task_struct* prio_inh, raw_spinlock_t *to_unlock,
96 unsigned long irqflags, int budget_triggered);
97typedef int (*__higher_prio_t)(struct task_struct* a, comparison_mode_t a_mod,
98 struct task_struct* b, comparison_mode_t b_mod);
99#endif /* end LITMUS_NESTED_LOCKING */
100
101#ifdef CONFIG_LITMUS_DGL_SUPPORT
102typedef raw_spinlock_t* (*get_dgl_spinlock_t) (struct task_struct *t);
103#endif /* end LITMUS_DGL_SUPPORT */
104
105#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
106struct affinity_observer;
107typedef long (*allocate_affinity_observer_t) (
108 struct affinity_observer **aff_obs, int type,
109 void* __user config);
110#endif /* end LITMUS_AFFINITY_LOCKING */
111#endif /* end LITMUS_LOCKING */
112
113#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
114typedef int (*default_cpu_for_gpu_t)(int gpu);
69#endif 115#endif
70 116
71
72/********************* sys call backends ********************/ 117/********************* sys call backends ********************/
73/* This function causes the caller to sleep until the next release */ 118/* This function causes the caller to sleep until the next release */
74typedef long (*complete_job_t) (void); 119typedef long (*complete_job_t) (void);
@@ -91,8 +136,8 @@ struct sched_plugin {
91 get_domain_proc_info_t get_domain_proc_info; 136 get_domain_proc_info_t get_domain_proc_info;
92 137
93 /* scheduler invocation */ 138 /* scheduler invocation */
94 scheduler_tick_t tick; 139 scheduler_tick_t tick;
95 schedule_t schedule; 140 schedule_t schedule;
96 finish_switch_t finish_switch; 141 finish_switch_t finish_switch;
97 142
98 /* syscall backend */ 143 /* syscall backend */
@@ -102,16 +147,42 @@ struct sched_plugin {
102 /* task state changes */ 147 /* task state changes */
103 admit_task_t admit_task; 148 admit_task_t admit_task;
104 149
105 task_new_t task_new; 150 task_new_t task_new;
106 task_wake_up_t task_wake_up; 151 task_wake_up_t task_wake_up;
107 task_block_t task_block; 152 task_block_t task_block;
108 153
109 task_exit_t task_exit; 154 task_exit_t task_exit;
110 task_cleanup_t task_cleanup; 155 task_cleanup_t task_cleanup;
111 156
157 /* misc */
158 higher_prio_t compare;
159
112#ifdef CONFIG_LITMUS_LOCKING 160#ifdef CONFIG_LITMUS_LOCKING
113 /* locking protocols */ 161 /* locking protocols */
114 allocate_lock_t allocate_lock; 162 allocate_lock_t allocate_lock;
163 increase_prio_t increase_prio;
164 decrease_prio_t decrease_prio;
165 /* varients that don't take scheduler locks */
166 __increase_prio_t __increase_prio;
167 __decrease_prio_t __decrease_prio;
168#ifdef CONFIG_LITMUS_NESTED_LOCKING
169 /* nested locking */
170 nested_increase_prio_t nested_increase_prio;
171 nested_decrease_prio_t nested_decrease_prio;
172 __higher_prio_t __compare;
173#endif /* end NESTED_LOCKING */
174
175#ifdef CONFIG_LITMUS_DGL_SUPPORT
176 get_dgl_spinlock_t get_dgl_spinlock;
177#endif /* end LITMUS_DGL_SUPPORT */
178
179#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
180 allocate_affinity_observer_t allocate_aff_obs;
181#endif /* end LITMUS_AFFINITY_LOCKING */
182#endif /* end LITMUS_LOCKING */
183
184#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
185 default_cpu_for_gpu_t map_gpu_to_cpu;
115#endif 186#endif
116} __attribute__ ((__aligned__(SMP_CACHE_BYTES))); 187} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
117 188
@@ -122,7 +193,6 @@ int register_sched_plugin(struct sched_plugin* plugin);
122struct sched_plugin* find_sched_plugin(const char* name); 193struct sched_plugin* find_sched_plugin(const char* name);
123void print_sched_plugins(struct seq_file *m); 194void print_sched_plugins(struct seq_file *m);
124 195
125
126extern struct sched_plugin linux_sched_plugin; 196extern struct sched_plugin linux_sched_plugin;
127 197
128#endif 198#endif
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index ab5b0c306a9a..c0b0bca23727 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -122,15 +122,88 @@ static long litmus_dummy_get_domain_proc_info(struct domain_proc_info **d)
122} 122}
123 123
124#ifdef CONFIG_LITMUS_LOCKING 124#ifdef CONFIG_LITMUS_LOCKING
125static int litmus_dummy_compare(struct task_struct* a, struct task_struct* b)
126{
127 TRACE_CUR("WARNING: Dummy compare function called!\n");
128 return 0;
129}
125 130
126static long litmus_dummy_allocate_lock(struct litmus_lock **lock, int type, 131static long litmus_dummy_allocate_lock(struct litmus_lock **lock, int type,
127 void* __user config) 132 void* __user config)
128{ 133{
129 return -ENXIO; 134 return -ENXIO;
130} 135}
131 136
137static void litmus_dummy_increase_prio(struct task_struct* t,
138 struct task_struct* prio_inh)
139{
140}
141
142static void litmus_dummy_decrease_prio(struct task_struct* t,
143 struct task_struct* prio_inh, int budget_triggered)
144{
145}
146
147static int litmus_dummy___increase_prio(struct task_struct* t,
148 struct task_struct* prio_inh)
149{
150 TRACE_CUR("WARNING: Dummy litmus_dummy___increase_prio called!\n");
151 return 0;
152}
153
154static int litmus_dummy___decrease_prio(struct task_struct* t,
155 struct task_struct* prio_inh, int budget_triggered)
156{
157 TRACE_CUR("WARNING: Dummy litmus_dummy___decrease_prio called!\n");
158 return 0;
159}
132#endif 160#endif
133 161
162#ifdef CONFIG_LITMUS_NESTED_LOCKING
163static void litmus_dummy_nested_increase_prio(struct task_struct* t,
164 struct task_struct* prio_inh,
165 raw_spinlock_t *to_unlock, unsigned long irqflags)
166{
167}
168
169static void litmus_dummy_nested_decrease_prio(struct task_struct* t,
170 struct task_struct* prio_inh,
171 raw_spinlock_t *to_unlock, unsigned long irqflags,
172 int budget_triggered)
173{
174}
175
176static int litmus_dummy___compare(
177 struct task_struct* a, comparison_mode_t a_mod,
178 struct task_struct* b, comparison_mode_t b_mode)
179{
180 TRACE_CUR("WARNING: Dummy compare function called!\n");
181 return 0;
182}
183#endif
184
185#ifdef CONFIG_LITMUS_DGL_SUPPORT
186static raw_spinlock_t* litmus_dummy_get_dgl_spinlock(struct task_struct *t)
187{
188 return NULL;
189}
190#endif
191
192#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
193static long litmus_dummy_allocate_aff_obs(struct affinity_observer **aff_obs,
194 int type,
195 void* __user config)
196{
197 return -ENXIO;
198}
199#endif
200
201#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
202static int litmus_dummy_map_gpu_to_cpu(int gpu)
203{
204 return 0;
205}
206#endif
134 207
135/* The default scheduler plugin. It doesn't do anything and lets Linux do its 208/* The default scheduler plugin. It doesn't do anything and lets Linux do its
136 * job. 209 * job.
@@ -149,7 +222,26 @@ struct sched_plugin linux_sched_plugin = {
149 .deactivate_plugin = litmus_dummy_deactivate_plugin, 222 .deactivate_plugin = litmus_dummy_deactivate_plugin,
150 .get_domain_proc_info = litmus_dummy_get_domain_proc_info, 223 .get_domain_proc_info = litmus_dummy_get_domain_proc_info,
151#ifdef CONFIG_LITMUS_LOCKING 224#ifdef CONFIG_LITMUS_LOCKING
225 .compare = litmus_dummy_compare,
152 .allocate_lock = litmus_dummy_allocate_lock, 226 .allocate_lock = litmus_dummy_allocate_lock,
227 .increase_prio = litmus_dummy_increase_prio,
228 .decrease_prio = litmus_dummy_decrease_prio,
229 .__increase_prio = litmus_dummy___increase_prio,
230 .__decrease_prio = litmus_dummy___decrease_prio,
231#endif
232#ifdef CONFIG_LITMUS_NESTED_LOCKING
233 .nested_increase_prio = litmus_dummy_nested_increase_prio,
234 .nested_decrease_prio = litmus_dummy_nested_decrease_prio,
235 .__compare = litmus_dummy___compare,
236#endif
237#ifdef CONFIG_LITMUS_DGL_SUPPORT
238 .get_dgl_spinlock = litmus_dummy_get_dgl_spinlock,
239#endif
240#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
241 .allocate_aff_obs = litmus_dummy_allocate_aff_obs,
242#endif
243#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
244 .map_gpu_to_cpu = litmus_dummy_map_gpu_to_cpu,
153#endif 245#endif
154 .admit_task = litmus_dummy_admit_task 246 .admit_task = litmus_dummy_admit_task
155}; 247};
@@ -189,7 +281,26 @@ int register_sched_plugin(struct sched_plugin* plugin)
189 CHECK(deactivate_plugin); 281 CHECK(deactivate_plugin);
190 CHECK(get_domain_proc_info); 282 CHECK(get_domain_proc_info);
191#ifdef CONFIG_LITMUS_LOCKING 283#ifdef CONFIG_LITMUS_LOCKING
284 CHECK(compare);
192 CHECK(allocate_lock); 285 CHECK(allocate_lock);
286 CHECK(increase_prio);
287 CHECK(decrease_prio);
288 CHECK(__increase_prio);
289 CHECK(__decrease_prio);
290#endif
291#ifdef CONFIG_LITMUS_NESTED_LOCKING
292 CHECK(nested_increase_prio);
293 CHECK(nested_decrease_prio);
294 CHECK(__compare);
295#endif
296#ifdef CONFIG_LITMUS_DGL_SUPPORT
297 CHECK(get_dgl_spinlock);
298#endif
299#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
300 CHECK(allocate_aff_obs);
301#endif
302#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
303 CHECK(map_gpu_to_cpu);
193#endif 304#endif
194 CHECK(admit_task); 305 CHECK(admit_task);
195 306