aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-07-31 05:58:51 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-07-31 05:58:51 -0400
commit17423950c90eeb4da6f818bb4379385f0a14699d (patch)
treecffba8fce9b95f7e29f7089cd1792473ef15fc31
parent9be2cb4ac4a6d775f158ee338505fbcc3753e43e (diff)
WIP snapshot
-rw-r--r--include/litmus/sched_plugin.h6
-rw-r--r--kernel/sched.c3
-rw-r--r--litmus/sched_cedf.c18
-rw-r--r--litmus/sched_plugin.c6
4 files changed, 32 insertions, 1 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index 6e7cabdddae8..b5d1ae7bc3b6 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -53,6 +53,10 @@ typedef void (*task_block_t) (struct task_struct *task);
53 */ 53 */
54typedef void (*task_exit_t) (struct task_struct *); 54typedef void (*task_exit_t) (struct task_struct *);
55 55
56/* called early before the caller holds the runqueue lock */
57typedef void (*pre_setsched_t) (struct task_struct *, int policy);
58
59
56/* Called when the current task attempts to create a new lock of a given 60/* Called when the current task attempts to create a new lock of a given
57 * protocol type. */ 61 * protocol type. */
58typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type, 62typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type,
@@ -93,6 +97,8 @@ struct sched_plugin {
93 task_block_t task_block; 97 task_block_t task_block;
94 task_exit_t task_exit; 98 task_exit_t task_exit;
95 99
100 pre_setsched_t pre_setsched;
101
96#ifdef CONFIG_LITMUS_LOCKING 102#ifdef CONFIG_LITMUS_LOCKING
97 /* locking protocols */ 103 /* locking protocols */
98 allocate_lock_t allocate_lock; 104 allocate_lock_t allocate_lock;
diff --git a/kernel/sched.c b/kernel/sched.c
index c5d775079027..b1fd83dbfb47 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4660,6 +4660,9 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
4660 struct rq *rq; 4660 struct rq *rq;
4661 int reset_on_fork; 4661 int reset_on_fork;
4662 4662
4663 if (litmus->pre_setsched)
4664 litmus->pre_setsched(p, policy);
4665
4663 /* may grab non-irq protected spin_locks */ 4666 /* may grab non-irq protected spin_locks */
4664 BUG_ON(in_interrupt()); 4667 BUG_ON(in_interrupt());
4665recheck: 4668recheck:
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c
index e905c5362d55..f9df2b098493 100644
--- a/litmus/sched_cedf.c
+++ b/litmus/sched_cedf.c
@@ -262,6 +262,8 @@ static noinline void requeue(struct task_struct* task)
262 262
263#ifdef CONFIG_LITMUS_LOCKING 263#ifdef CONFIG_LITMUS_LOCKING
264static int update_pending_job(cedf_domain_t* cluster, struct task_struct* t); 264static int update_pending_job(cedf_domain_t* cluster, struct task_struct* t);
265static void priodon_become_eligible(void);
266static void priodon_complete_request(void);
265#endif 267#endif
266 268
267/* check for any necessary preemptions */ 269/* check for any necessary preemptions */
@@ -990,13 +992,26 @@ static void cedf_task_block(struct task_struct *t)
990 BUG_ON(!is_realtime(t)); 992 BUG_ON(!is_realtime(t));
991} 993}
992 994
995#ifdef CONFIG_LITMUS_LOCKING
996static void cedf_pre_setsched(struct task_struct *t, int policy)
997{
998 /* we can only handle current atm */
999 if (is_realtime(t) && t == current) {
1000 TRACE_CUR("cedf_pre_setsched\n");
1001
1002 /* Pretend to issue a request to make sure
1003 * we are no longer a priority donor. */
1004 priodon_become_eligible();
1005 priodon_complete_request();
1006 }
1007}
1008#endif
993 1009
994static void cedf_task_exit(struct task_struct * t) 1010static void cedf_task_exit(struct task_struct * t)
995{ 1011{
996 unsigned long flags; 1012 unsigned long flags;
997 cedf_domain_t *cluster = task_cpu_cluster(t); 1013 cedf_domain_t *cluster = task_cpu_cluster(t);
998 1014
999
1000 /* unlink if necessary */ 1015 /* unlink if necessary */
1001 raw_spin_lock_irqsave(&cluster->cluster_lock, flags); 1016 raw_spin_lock_irqsave(&cluster->cluster_lock, flags);
1002 1017
@@ -1464,6 +1479,7 @@ static struct sched_plugin cedf_plugin __cacheline_aligned_in_smp = {
1464 .activate_plugin = cedf_activate_plugin, 1479 .activate_plugin = cedf_activate_plugin,
1465#ifdef CONFIG_LITMUS_LOCKING 1480#ifdef CONFIG_LITMUS_LOCKING
1466 .allocate_lock = cedf_allocate_lock, 1481 .allocate_lock = cedf_allocate_lock,
1482 .pre_setsched = cedf_pre_setsched,
1467#endif 1483#endif
1468}; 1484};
1469 1485
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index 00a1900d6457..950fe5e6a1ab 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -95,6 +95,11 @@ static void litmus_dummy_task_exit(struct task_struct *task)
95{ 95{
96} 96}
97 97
98static void litmus_dummy_pre_setsched(struct task_struct *task, int policy)
99{
100}
101
102
98static long litmus_dummy_complete_job(void) 103static long litmus_dummy_complete_job(void)
99{ 104{
100 return -ENOSYS; 105 return -ENOSYS;
@@ -178,6 +183,7 @@ int register_sched_plugin(struct sched_plugin* plugin)
178 CHECK(allocate_lock); 183 CHECK(allocate_lock);
179#endif 184#endif
180 CHECK(admit_task); 185 CHECK(admit_task);
186 CHECK(pre_setsched);
181 187
182 if (!plugin->release_at) 188 if (!plugin->release_at)
183 plugin->release_at = release_at; 189 plugin->release_at = release_at;