aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanya Amert <tamert@cs.unc.edu>2020-10-12 13:28:23 -0400
committerTanya Amert <tamert@cs.unc.edu>2020-10-12 13:28:23 -0400
commit4f6266335535e47a82a6d9b1d4b0472819bbcab3 (patch)
treefd3d14ef438fed3120842d2de8ebfa6ace51e57a
parent213fa45747f8977878a0e048de5442d8badf57cb (diff)
Added empty lock functions for OMLP-FZ.
-rw-r--r--include/litmus/reservations/ext_reservation.h19
-rw-r--r--litmus/reservations/gedf_reservation.c137
-rw-r--r--litmus/sched_ext_res.c24
3 files changed, 179 insertions, 1 deletions
diff --git a/include/litmus/reservations/ext_reservation.h b/include/litmus/reservations/ext_reservation.h
index c9ec924fc55b..cc16b036920c 100644
--- a/include/litmus/reservations/ext_reservation.h
+++ b/include/litmus/reservations/ext_reservation.h
@@ -6,6 +6,10 @@
6#include <litmus/debug_trace.h> 6#include <litmus/debug_trace.h>
7#include <litmus/reservations/budget-notifier.h> 7#include <litmus/reservations/budget-notifier.h>
8 8
9#ifdef CONFIG_LITMUS_LOCKING
10#include <litmus/locking.h>
11#endif
12
9struct reservation_environment; 13struct reservation_environment;
10struct reservation; 14struct reservation;
11 15
@@ -141,6 +145,16 @@ typedef int (*env_is_np_t) (
141typedef void (*env_shutdown_t) ( 145typedef void (*env_shutdown_t) (
142 struct reservation_environment* env); 146 struct reservation_environment* env);
143 147
148#ifdef CONFIG_LITMUS_LOCKING
149/* Called when the current task attempts to create a new lock of a given
150 * protocol type. */
151typedef long (*env_allocate_lock_t) (
152 struct reservation_environment* env,
153 struct litmus_lock **lock,
154 int type,
155 void* __user config);
156#endif
157
144struct reservation_environment_ops { 158struct reservation_environment_ops {
145 env_update_time_t update_time; 159 env_update_time_t update_time;
146 env_dispatch_t dispatch; 160 env_dispatch_t dispatch;
@@ -151,6 +165,11 @@ struct reservation_environment_ops {
151 env_find_res_t find_res_by_id; 165 env_find_res_t find_res_by_id;
152 env_is_np_t is_np; 166 env_is_np_t is_np;
153 env_shutdown_t shutdown; 167 env_shutdown_t shutdown;
168
169#ifdef CONFIG_LITMUS_LOCKING
170 /* locking protocols */
171 env_allocate_lock_t allocate_lock;
172#endif
154}; 173};
155 174
156struct reservation_environment { 175struct reservation_environment {
diff --git a/litmus/reservations/gedf_reservation.c b/litmus/reservations/gedf_reservation.c
index 2ed16575144e..5f7c97eb980c 100644
--- a/litmus/reservations/gedf_reservation.c
+++ b/litmus/reservations/gedf_reservation.c
@@ -688,6 +688,138 @@ static void gedf_env_release_jobs(rt_domain_t* rt, struct bheap* res)
688 raw_spin_unlock_irqrestore(&rt->ready_lock, flags); 688 raw_spin_unlock_irqrestore(&rt->ready_lock, flags);
689} 689}
690 690
691#ifdef CONFIG_LITMUS_LOCKING
692
693#include <litmus/fdso.h>
694#include <litmus/wait.h>
695
696/* ******************** OMLP support ********************** */
697
698/* struct for semaphore with priority inheritance */
699struct omlp_semaphore {
700 struct litmus_lock litmus_lock;
701
702 /* current resource holder */
703 struct task_struct *owner;
704
705 /* highest-priority waiter */
706 struct task_struct *hp_waiter;
707
708 /* FIFO queue of waiting tasks */
709 wait_queue_head_t fifo_wait;
710 /* Priority queue of waiting tasks */
711 wait_queue_head_t prio_wait;
712
713 /* How many slots remaining in FIFO queue? */
714 unsigned int num_free;
715};
716
717static inline struct omlp_semaphore* omlp_from_lock(struct litmus_lock* lock)
718{
719 return container_of(lock, struct omlp_semaphore, litmus_lock);
720}
721
722int gedf_env_omlp_lock(struct litmus_lock* l)
723{
724 struct task_struct* t = current;
725 struct omlp_semaphore *sem = omlp_from_lock(l);
726 prio_wait_queue_t wait;
727 unsigned long flags;
728
729 return 0;
730}
731
732static int gedf_env_omlp_unlock(struct litmus_lock* l)
733{
734 struct task_struct *t = current, *next;
735 struct omlp_semaphore *sem = omlp_from_lock(l);
736 unsigned long flags;
737 int err = 0;
738
739 return err;
740}
741
742static int gedf_env_omlp_close(struct litmus_lock* l)
743{
744 struct task_struct *t = current;
745 struct omlp_semaphore *sem = omlp_from_lock(l);
746 unsigned long flags;
747
748 int owner;
749
750 spin_lock_irqsave(&sem->fifo_wait.lock, flags);
751
752 owner = sem->owner == t;
753
754 spin_unlock_irqrestore(&sem->fifo_wait.lock, flags);
755
756 if (owner)
757 gedf_env_omlp_unlock(l);
758
759 return 0;
760}
761
762static void gedf_env_omlp_free(struct litmus_lock* lock)
763{
764 kfree(omlp_from_lock(lock));
765}
766
767static struct litmus_lock_ops gedf_env_omlp_lock_ops = {
768 .close = gedf_env_omlp_close,
769 .lock = gedf_env_omlp_lock,
770 .unlock = gedf_env_omlp_unlock,
771 .deallocate = gedf_env_omlp_free,
772};
773
774static struct litmus_lock* gedf_env_new_omlp(void)
775{
776 struct omlp_semaphore* sem;
777
778 sem = kmalloc(sizeof(*sem), GFP_KERNEL);
779 if (!sem)
780 return NULL;
781
782 sem->owner = NULL;
783 sem->hp_waiter = NULL;
784 init_waitqueue_head(&sem->fifo_wait);
785 init_waitqueue_head(&sem->prio_wait);
786 sem->litmus_lock.ops = &gedf_env_omlp_lock_ops;
787 /* free = cpus -1 since ->owner is the head and also counted */
788 sem->num_free = num_online_cpus() - 1; // TODO tamert: check this
789
790 return &sem->litmus_lock;
791}
792
793/* **** lock constructor **** */
794
795static long gedf_env_allocate_lock(
796 struct reservation_environment* env,
797 struct litmus_lock **lock,
798 int type,
799 void* __user unused)
800{
801 int err = -ENXIO;
802
803 /* EXT-RES currently only supports the OMLP within components
804 for global resources. */
805 switch (type) {
806
807 case OMLP_SEM:
808 /* O(m) Multiprocessor Locking Protocol */
809 *lock = gedf_env_new_omlp();
810 if (*lock)
811 err = 0;
812 else
813 err = -ENOMEM;
814 break;
815
816 };
817
818 return err;
819}
820
821#endif
822
691static struct reservation_environment_ops gedf_env_ops = { 823static struct reservation_environment_ops gedf_env_ops = {
692 .update_time = gedf_env_update_time, 824 .update_time = gedf_env_update_time,
693 .dispatch = gedf_env_dispatch, 825 .dispatch = gedf_env_dispatch,
@@ -697,7 +829,10 @@ static struct reservation_environment_ops gedf_env_ops = {
697 .remove_res = gedf_env_remove_res, 829 .remove_res = gedf_env_remove_res,
698 .find_res_by_id = gedf_find_res_by_id, 830 .find_res_by_id = gedf_find_res_by_id,
699 .is_np = gedf_env_is_np, 831 .is_np = gedf_env_is_np,
700 .shutdown = gedf_env_shutdown 832 .shutdown = gedf_env_shutdown,
833#ifdef CONFIG_LITMUS_LOCKING
834 .allocate_lock = gedf_env_allocate_lock,
835#endif
701}; 836};
702 837
703long alloc_gedf_reservation_environment( 838long alloc_gedf_reservation_environment(
diff --git a/litmus/sched_ext_res.c b/litmus/sched_ext_res.c
index 583a2ed9aef0..4bf81cd46c59 100644
--- a/litmus/sched_ext_res.c
+++ b/litmus/sched_ext_res.c
@@ -275,6 +275,27 @@ static bool ext_res_should_wait_for_stack(struct task_struct* t) {
275} 275}
276*/ 276*/
277 277
278
279#ifdef CONFIG_LITMUS_LOCKING
280
281/* **** lock constructor **** */
282
283static long ext_res_allocate_lock(struct litmus_lock **lock, int type,
284 void* __user unused)
285{
286 struct reservation_environment *gedf_env;
287 int err = -ENXIO;
288
289 /* pass the allocate_lock call to the task's component */
290 gedf_env = ((struct reservation*) tsk_rt(current)->plugin_state)->par_env;
291 err = gedf_env->ops->allocate_lock(gedf_env, lock, type, unused);
292
293 return err;
294}
295
296#endif
297
298
278static struct domain_proc_info ext_res_domain_proc_info; 299static struct domain_proc_info ext_res_domain_proc_info;
279 300
280static long ext_res_get_domain_proc_info(struct domain_proc_info **ret) 301static long ext_res_get_domain_proc_info(struct domain_proc_info **ret)
@@ -361,6 +382,9 @@ static struct sched_plugin ext_res_plugin = {
361 .reservation_create = ext_res_reservation_create, 382 .reservation_create = ext_res_reservation_create,
362 //.current_budget = pres_current_budget, 383 //.current_budget = pres_current_budget,
363 //.should_wait_for_stack = ext_res_should_wait_for_stack, 384 //.should_wait_for_stack = ext_res_should_wait_for_stack,
385#ifdef CONFIG_LITMUS_LOCKING
386 .allocate_lock = ext_res_allocate_lock,
387#endif
364}; 388};
365 389
366static int __init init_ext_res(void) 390static int __init init_ext_res(void)