aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/sched_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/sched_plugin.c')
-rw-r--r--litmus/sched_plugin.c167
1 files changed, 163 insertions, 4 deletions
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index 00a1900d6457..76ff892122aa 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -13,6 +13,10 @@
13#include <litmus/preempt.h> 13#include <litmus/preempt.h>
14#include <litmus/jobs.h> 14#include <litmus/jobs.h>
15 15
16#ifdef CONFIG_LITMUS_NVIDIA
17#include <litmus/nvidia_info.h>
18#endif
19
16/* 20/*
17 * Generic function to trigger preemption on either local or remote cpu 21 * Generic function to trigger preemption on either local or remote cpu
18 * from scheduler plugins. The key feature is that this function is 22 * from scheduler plugins. The key feature is that this function is
@@ -27,11 +31,19 @@ void preempt_if_preemptable(struct task_struct* t, int cpu)
27 31
28 int reschedule = 0; 32 int reschedule = 0;
29 33
30 if (!t) 34 TRACE_CUR("preempt_if_preemptable: %s/%d\n",
35 (t) ? t->comm : "(nil)",
36 (t) ? t->pid : 0);
37
38 if (!t) {
39 TRACE_CUR("unconditionally reshcedule\n");
31 /* move non-real-time task out of the way */ 40 /* move non-real-time task out of the way */
32 reschedule = 1; 41 reschedule = 1;
42 }
33 else { 43 else {
34 if (smp_processor_id() == cpu) { 44 if (smp_processor_id() == cpu) {
45 TRACE_CUR("preempt local cpu.\n");
46
35 /* local CPU case */ 47 /* local CPU case */
36 /* check if we need to poke userspace */ 48 /* check if we need to poke userspace */
37 if (is_user_np(t)) 49 if (is_user_np(t))
@@ -43,14 +55,22 @@ void preempt_if_preemptable(struct task_struct* t, int cpu)
43 * currently-executing task */ 55 * currently-executing task */
44 reschedule = 1; 56 reschedule = 1;
45 } else { 57 } else {
58 int is_knp = is_kernel_np(t);
59 int reqexit = request_exit_np_atomic(t);
60 TRACE_CUR("preempt remote cpu: isknp = %d reqexit = %d\n", is_knp, reqexit);
61
46 /* Remote CPU case. Only notify if it's not a kernel 62 /* Remote CPU case. Only notify if it's not a kernel
47 * NP section and if we didn't set the userspace 63 * NP section and if we didn't set the userspace
48 * flag. */ 64 * flag. */
49 reschedule = !(is_kernel_np(t) || request_exit_np_atomic(t)); 65 //reschedule = !(is_kernel_np(t) || request_exit_np_atomic(t));
66 reschedule = !(is_knp || reqexit);
50 } 67 }
51 } 68 }
52 if (likely(reschedule)) 69
70 if (likely(reschedule)) {
71 TRACE_CUR("calling litmus_reschedule()\n");
53 litmus_reschedule(cpu); 72 litmus_reschedule(cpu);
73 }
54} 74}
55 75
56 76
@@ -102,6 +122,9 @@ static long litmus_dummy_complete_job(void)
102 122
103static long litmus_dummy_activate_plugin(void) 123static long litmus_dummy_activate_plugin(void)
104{ 124{
125#ifdef CONFIG_LITMUS_NVIDIA
126 shutdown_nvidia_info();
127#endif
105 return 0; 128 return 0;
106} 129}
107 130
@@ -110,14 +133,100 @@ static long litmus_dummy_deactivate_plugin(void)
110 return 0; 133 return 0;
111} 134}
112 135
113#ifdef CONFIG_LITMUS_LOCKING 136static int litmus_dummy_compare(struct task_struct* a, struct task_struct* b)
137{
138 TRACE_CUR("WARNING: Dummy compare function called!\n");
139 return 0;
140}
114 141
142#ifdef CONFIG_LITMUS_LOCKING
115static long litmus_dummy_allocate_lock(struct litmus_lock **lock, int type, 143static long litmus_dummy_allocate_lock(struct litmus_lock **lock, int type,
116 void* __user config) 144 void* __user config)
117{ 145{
118 return -ENXIO; 146 return -ENXIO;
119} 147}
120 148
149static void litmus_dummy_increase_prio(struct task_struct* t, struct task_struct* prio_inh)
150{
151}
152
153static void litmus_dummy_decrease_prio(struct task_struct* t, struct task_struct* prio_inh)
154{
155}
156
157static int litmus_dummy___increase_prio(struct task_struct* t, struct task_struct* prio_inh)
158{
159 TRACE_CUR("WARNING: Dummy litmus_dummy___increase_prio called!\n");
160 return 0;
161}
162
163static int litmus_dummy___decrease_prio(struct task_struct* t, struct task_struct* prio_inh)
164{
165 TRACE_CUR("WARNING: Dummy litmus_dummy___decrease_prio called!\n");
166 return 0;
167}
168#endif
169
170
171#ifdef CONFIG_LITMUS_PAI_SOFTIRQD
172static int litmus_dummy_enqueue_pai_tasklet(struct tasklet_struct* t)
173{
174 TRACE("%s: PAI Tasklet unsupported in this plugin!!!!!!\n", __FUNCTION__);
175 return(0); // failure.
176}
177
178static void litmus_dummy_change_prio_pai_tasklet(struct task_struct *old_prio,
179 struct task_struct *new_prio)
180{
181 TRACE("%s: PAI Tasklet unsupported in this plugin!!!!!!\n", __FUNCTION__);
182}
183
184static void litmus_dummy_run_tasklets(struct task_struct* t)
185{
186 //TRACE("%s: PAI Tasklet unsupported in this plugin!!!!!!\n", __FUNCTION__);
187}
188#endif
189
190#ifdef CONFIG_LITMUS_NESTED_LOCKING
191static void litmus_dummy_nested_increase_prio(struct task_struct* t, struct task_struct* prio_inh,
192 raw_spinlock_t *to_unlock, unsigned long irqflags)
193{
194}
195
196static void litmus_dummy_nested_decrease_prio(struct task_struct* t, struct task_struct* prio_inh,
197 raw_spinlock_t *to_unlock, unsigned long irqflags)
198{
199}
200
201static int litmus_dummy___compare(struct task_struct* a, comparison_mode_t a_mod,
202 struct task_struct* b, comparison_mode_t b_mode)
203{
204 TRACE_CUR("WARNING: Dummy compare function called!\n");
205 return 0;
206}
207#endif
208
209#ifdef CONFIG_LITMUS_DGL_SUPPORT
210static raw_spinlock_t* litmus_dummy_get_dgl_spinlock(struct task_struct *t)
211{
212 return NULL;
213}
214#endif
215
216#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
217static long litmus_dummy_allocate_aff_obs(struct affinity_observer **aff_obs,
218 int type,
219 void* __user config)
220{
221 return -ENXIO;
222}
223#endif
224
225#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
226static int litmus_dummy_map_gpu_to_cpu(int gpu)
227{
228 return 0;
229}
121#endif 230#endif
122 231
123 232
@@ -136,9 +245,34 @@ struct sched_plugin linux_sched_plugin = {
136 .finish_switch = litmus_dummy_finish_switch, 245 .finish_switch = litmus_dummy_finish_switch,
137 .activate_plugin = litmus_dummy_activate_plugin, 246 .activate_plugin = litmus_dummy_activate_plugin,
138 .deactivate_plugin = litmus_dummy_deactivate_plugin, 247 .deactivate_plugin = litmus_dummy_deactivate_plugin,
248 .compare = litmus_dummy_compare,
139#ifdef CONFIG_LITMUS_LOCKING 249#ifdef CONFIG_LITMUS_LOCKING
140 .allocate_lock = litmus_dummy_allocate_lock, 250 .allocate_lock = litmus_dummy_allocate_lock,
251 .increase_prio = litmus_dummy_increase_prio,
252 .decrease_prio = litmus_dummy_decrease_prio,
253 .__increase_prio = litmus_dummy___increase_prio,
254 .__decrease_prio = litmus_dummy___decrease_prio,
255#endif
256#ifdef CONFIG_LITMUS_NESTED_LOCKING
257 .nested_increase_prio = litmus_dummy_nested_increase_prio,
258 .nested_decrease_prio = litmus_dummy_nested_decrease_prio,
259 .__compare = litmus_dummy___compare,
260#endif
261#ifdef CONFIG_LITMUS_PAI_SOFTIRQD
262 .enqueue_pai_tasklet = litmus_dummy_enqueue_pai_tasklet,
263 .change_prio_pai_tasklet = litmus_dummy_change_prio_pai_tasklet,
264 .run_tasklets = litmus_dummy_run_tasklets,
265#endif
266#ifdef CONFIG_LITMUS_DGL_SUPPORT
267 .get_dgl_spinlock = litmus_dummy_get_dgl_spinlock,
141#endif 268#endif
269#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
270 .allocate_aff_obs = litmus_dummy_allocate_aff_obs,
271#endif
272#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
273 .map_gpu_to_cpu = litmus_dummy_map_gpu_to_cpu,
274#endif
275
142 .admit_task = litmus_dummy_admit_task 276 .admit_task = litmus_dummy_admit_task
143}; 277};
144 278
@@ -174,9 +308,34 @@ int register_sched_plugin(struct sched_plugin* plugin)
174 CHECK(complete_job); 308 CHECK(complete_job);
175 CHECK(activate_plugin); 309 CHECK(activate_plugin);
176 CHECK(deactivate_plugin); 310 CHECK(deactivate_plugin);
311 CHECK(compare);
177#ifdef CONFIG_LITMUS_LOCKING 312#ifdef CONFIG_LITMUS_LOCKING
178 CHECK(allocate_lock); 313 CHECK(allocate_lock);
314 CHECK(increase_prio);
315 CHECK(decrease_prio);
316 CHECK(__increase_prio);
317 CHECK(__decrease_prio);
318#endif
319#ifdef CONFIG_LITMUS_NESTED_LOCKING
320 CHECK(nested_increase_prio);
321 CHECK(nested_decrease_prio);
322 CHECK(__compare);
323#endif
324#ifdef CONFIG_LITMUS_PAI_SOFTIRQD
325 CHECK(enqueue_pai_tasklet);
326 CHECK(change_prio_pai_tasklet);
327 CHECK(run_tasklets);
179#endif 328#endif
329#ifdef CONFIG_LITMUS_DGL_SUPPORT
330 CHECK(get_dgl_spinlock);
331#endif
332#ifdef CONFIG_LITMUS_AFFINITY_LOCKING
333 CHECK(allocate_aff_obs);
334#endif
335#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
336 CHECK(map_gpu_to_cpu);
337#endif
338
180 CHECK(admit_task); 339 CHECK(admit_task);
181 340
182 if (!plugin->release_at) 341 if (!plugin->release_at)