aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-02-14 08:56:40 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-08 10:12:49 -0500
commita83a958e62cb903e14bc458a5ace4b9f380fc802 (patch)
treea8a0a2cea9d0cfd31f5f989b92da7202048ad187
parent5c3fc90c1f92c65f315166f8de9071615c08c088 (diff)
LITMUS^RT core: add should_wait_for_stack() callback
Allow plugins to give up when waiting for a stack to become available.
-rw-r--r--include/litmus/sched_plugin.h7
-rw-r--r--kernel/sched/litmus.c13
-rw-r--r--litmus/sched_plugin.c6
3 files changed, 26 insertions, 0 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index 0c2aabad40c9..1906a139e6e9 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -29,6 +29,12 @@ typedef struct task_struct* (*schedule_t)(struct task_struct * prev);
29typedef void (*finish_switch_t)(struct task_struct *prev); 29typedef void (*finish_switch_t)(struct task_struct *prev);
30 30
31 31
32/* When waiting for the stack of the task selected by the plugin
33 * to become available, this callback is invoked to give the
34 * plugin a chance to cancel the wait. If the plugin returns false,
35 * the scheduler is invoked again. */
36typedef bool (*should_wait_for_stack_t)(struct task_struct *next);
37
32/********************* task state changes ********************/ 38/********************* task state changes ********************/
33 39
34/* Called to setup a new real-time task. 40/* Called to setup a new real-time task.
@@ -103,6 +109,7 @@ struct sched_plugin {
103 /* scheduler invocation */ 109 /* scheduler invocation */
104 schedule_t schedule; 110 schedule_t schedule;
105 finish_switch_t finish_switch; 111 finish_switch_t finish_switch;
112 should_wait_for_stack_t should_wait_for_stack;
106 113
107 /* syscall backend */ 114 /* syscall backend */
108 complete_job_t complete_job; 115 complete_job_t complete_job;
diff --git a/kernel/sched/litmus.c b/kernel/sched/litmus.c
index 2cdba907f0a8..4fa5a941a284 100644
--- a/kernel/sched/litmus.c
+++ b/kernel/sched/litmus.c
@@ -78,6 +78,19 @@ litmus_schedule(struct rq *rq, struct task_struct *prev)
78 if (next->rt_param.stack_in_use == NO_CPU) 78 if (next->rt_param.stack_in_use == NO_CPU)
79 TRACE_TASK(next,"descheduled. Proceeding.\n"); 79 TRACE_TASK(next,"descheduled. Proceeding.\n");
80 80
81 if (!litmus->should_wait_for_stack(next)) {
82 /* plugin aborted the wait */
83 TRACE_TASK(next,
84 "plugin gave up waiting for stack\n");
85 next = NULL;
86 /* Make sure plugin is given a chance to
87 * reconsider. */
88 litmus_reschedule_local();
89 /* give up */
90 raw_spin_lock(&rq->lock);
91 return next;
92 }
93
81 if (lt_before(_maybe_deadlock + 1000000000L, 94 if (lt_before(_maybe_deadlock + 1000000000L,
82 litmus_clock())) { 95 litmus_clock())) {
83 /* We've been spinning for 1s. 96 /* We've been spinning for 1s.
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index 6ab5b85082c9..4007e5129e80 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -70,6 +70,11 @@ static struct task_struct* litmus_dummy_schedule(struct task_struct * prev)
70 return NULL; 70 return NULL;
71} 71}
72 72
73static bool litmus_dummy_should_wait_for_stack(struct task_struct *next)
74{
75 return true; /* by default, wait indefinitely */
76}
77
73static long litmus_dummy_admit_task(struct task_struct* tsk) 78static long litmus_dummy_admit_task(struct task_struct* tsk)
74{ 79{
75 printk(KERN_CRIT "LITMUS^RT: Linux plugin rejects %s/%d.\n", 80 printk(KERN_CRIT "LITMUS^RT: Linux plugin rejects %s/%d.\n",
@@ -186,6 +191,7 @@ int register_sched_plugin(struct sched_plugin* plugin)
186 /* make sure we don't trip over null pointers later */ 191 /* make sure we don't trip over null pointers later */
187 CHECK(finish_switch); 192 CHECK(finish_switch);
188 CHECK(schedule); 193 CHECK(schedule);
194 CHECK(should_wait_for_stack);
189 CHECK(task_wake_up); 195 CHECK(task_wake_up);
190 CHECK(task_exit); 196 CHECK(task_exit);
191 CHECK(task_cleanup); 197 CHECK(task_cleanup);