aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/fifo_lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/fifo_lock.c')
-rw-r--r--litmus/fifo_lock.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/litmus/fifo_lock.c b/litmus/fifo_lock.c
index be49cd3a58d2..cc3e1ab5a965 100644
--- a/litmus/fifo_lock.c
+++ b/litmus/fifo_lock.c
@@ -7,8 +7,6 @@
7 7
8#include <litmus/litmus_proc.h> 8#include <litmus/litmus_proc.h>
9 9
10//#include <litmus/edf_common.h>
11
12#if defined(CONFIG_LITMUS_AFFINITY_LOCKING) && defined(CONFIG_LITMUS_NVIDIA) 10#if defined(CONFIG_LITMUS_AFFINITY_LOCKING) && defined(CONFIG_LITMUS_NVIDIA)
13#include <litmus/gpu_affinity.h> 11#include <litmus/gpu_affinity.h>
14#endif 12#endif
@@ -22,33 +20,16 @@ static struct task_struct* fifo_mutex_find_hp_waiter(struct fifo_mutex *mutex,
22 struct list_head *pos; 20 struct list_head *pos;
23 struct task_struct *queued = NULL, *found = NULL; 21 struct task_struct *queued = NULL, *found = NULL;
24 22
25#ifdef CONFIG_LITMUS_DGL_SUPPORT
26 dgl_wait_state_t *dgl_wait = NULL;
27#endif
28
29 list_for_each(pos, &mutex->wait.task_list) { 23 list_for_each(pos, &mutex->wait.task_list) {
30 q = list_entry(pos, wait_queue_t, task_list); 24 q = list_entry(pos, wait_queue_t, task_list);
31 25
32#ifdef CONFIG_LITMUS_DGL_SUPPORT 26 queued = get_queued_task(q);
33 if(q->func == dgl_wake_up) {
34 dgl_wait = (dgl_wait_state_t*) q->private;
35 if(tsk_rt(dgl_wait->task)->blocked_lock == &mutex->litmus_lock) {
36 queued = dgl_wait->task;
37 }
38 else {
39 queued = NULL; // skip it.
40 }
41 }
42 else {
43 queued = (struct task_struct*) q->private;
44 }
45#else
46 queued = (struct task_struct*) q->private;
47#endif
48 27
49 /* Compare task prios, find high prio task. */ 28 /* Compare task prios, find high prio task. */
50 //if (queued && queued != skip && edf_higher_prio(queued, found)) { 29 if (queued &&
51 if (queued && queued != skip && litmus->compare(queued, found)) { 30 (queued != skip) &&
31 (tsk_rt(queued)->blocked_lock == &mutex->litmus_lock) &&
32 litmus->compare(queued, found)) {
52 found = queued; 33 found = queued;
53 } 34 }
54 } 35 }
@@ -64,6 +45,12 @@ int fifo_mutex_is_owner(struct litmus_lock *l, struct task_struct *t)
64 return(mutex->owner == t); 45 return(mutex->owner == t);
65} 46}
66 47
48struct task_struct* fifo_mutex_get_owner(struct litmus_lock *l)
49{
50 struct fifo_mutex *mutex = fifo_mutex_from_lock(l);
51 return(mutex->owner);
52}
53
67// return 1 if resource was immediatly acquired. 54// return 1 if resource was immediatly acquired.
68// Assumes mutex->lock is held. 55// Assumes mutex->lock is held.
69// Must set task state to TASK_UNINTERRUPTIBLE if task blocks. 56// Must set task state to TASK_UNINTERRUPTIBLE if task blocks.
@@ -110,12 +97,16 @@ void fifo_mutex_enable_priority(struct litmus_lock *l,
110 struct task_struct *owner = mutex->owner; 97 struct task_struct *owner = mutex->owner;
111 unsigned long flags = 0; // these are unused under DGL coarse-grain locking 98 unsigned long flags = 0; // these are unused under DGL coarse-grain locking
112 99
100 /**************************************
101 * This code looks like it supports fine-grain locking, but it does not!
102 * TODO: Gaurantee that mutex->lock is held by the caller to support fine-grain locking.
103 **************************************/
104
113 BUG_ON(owner == t); 105 BUG_ON(owner == t);
114 106
115 tsk_rt(t)->blocked_lock = l; 107 tsk_rt(t)->blocked_lock = l;
116 mb(); 108 mb();
117 109
118 //if (edf_higher_prio(t, mutex->hp_waiter)) {
119 if (litmus->compare(t, mutex->hp_waiter)) { 110 if (litmus->compare(t, mutex->hp_waiter)) {
120 111
121 struct task_struct *old_max_eff_prio; 112 struct task_struct *old_max_eff_prio;
@@ -141,7 +132,6 @@ void fifo_mutex_enable_priority(struct litmus_lock *l,
141 TRACE_TASK(t, "is new hp_waiter.\n"); 132 TRACE_TASK(t, "is new hp_waiter.\n");
142 133
143 if ((effective_priority(owner) == old_max_eff_prio) || 134 if ((effective_priority(owner) == old_max_eff_prio) ||
144 //(__edf_higher_prio(new_max_eff_prio, BASE, owner, EFFECTIVE))){
145 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))){ 135 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))){
146 new_prio = new_max_eff_prio; 136 new_prio = new_max_eff_prio;
147 } 137 }
@@ -234,7 +224,6 @@ int fifo_mutex_lock(struct litmus_lock* l)
234 __add_wait_queue_tail_exclusive(&mutex->wait, &wait); 224 __add_wait_queue_tail_exclusive(&mutex->wait, &wait);
235 225
236 /* check if we need to activate priority inheritance */ 226 /* check if we need to activate priority inheritance */
237 //if (edf_higher_prio(t, mutex->hp_waiter)) {
238 if (litmus->compare(t, mutex->hp_waiter)) { 227 if (litmus->compare(t, mutex->hp_waiter)) {
239 228
240 struct task_struct *old_max_eff_prio; 229 struct task_struct *old_max_eff_prio;
@@ -260,7 +249,6 @@ int fifo_mutex_lock(struct litmus_lock* l)
260 TRACE_TASK(t, "is new hp_waiter.\n"); 249 TRACE_TASK(t, "is new hp_waiter.\n");
261 250
262 if ((effective_priority(owner) == old_max_eff_prio) || 251 if ((effective_priority(owner) == old_max_eff_prio) ||
263 //(__edf_higher_prio(new_max_eff_prio, BASE, owner, EFFECTIVE))){
264 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))){ 252 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))){
265 new_prio = new_max_eff_prio; 253 new_prio = new_max_eff_prio;
266 } 254 }
@@ -368,8 +356,6 @@ int fifo_mutex_unlock(struct litmus_lock* l)
368 (effective_priority(t) == old_max_eff_prio)) ) 356 (effective_priority(t) == old_max_eff_prio)) )
369 { 357 {
370 // old_max_eff_prio > new_max_eff_prio 358 // old_max_eff_prio > new_max_eff_prio
371
372 //if(__edf_higher_prio(new_max_eff_prio, BASE, t, EFFECTIVE)) {
373 if(litmus->__compare(new_max_eff_prio, BASE, t, EFFECTIVE)) { 359 if(litmus->__compare(new_max_eff_prio, BASE, t, EFFECTIVE)) {
374 TRACE_TASK(t, "new_max_eff_prio > task's eff_prio-- new_max_eff_prio: %s/%d task: %s/%d [%s/%d]\n", 360 TRACE_TASK(t, "new_max_eff_prio > task's eff_prio-- new_max_eff_prio: %s/%d task: %s/%d [%s/%d]\n",
375 new_max_eff_prio->comm, new_max_eff_prio->pid, 361 new_max_eff_prio->comm, new_max_eff_prio->pid,
@@ -395,10 +381,7 @@ int fifo_mutex_unlock(struct litmus_lock* l)
395 381
396 /* check if there are jobs waiting for this resource */ 382 /* check if there are jobs waiting for this resource */
397#ifdef CONFIG_LITMUS_DGL_SUPPORT 383#ifdef CONFIG_LITMUS_DGL_SUPPORT
398 __waitqueue_dgl_remove_first(&mutex->wait, &dgl_wait, &next); 384 next = __waitqueue_dgl_remove_first(&mutex->wait, &dgl_wait);
399 if(dgl_wait) {
400 next = dgl_wait->task;
401 }
402#else 385#else
403 next = __waitqueue_remove_first(&mutex->wait); 386 next = __waitqueue_remove_first(&mutex->wait);
404#endif 387#endif
@@ -434,7 +417,6 @@ int fifo_mutex_unlock(struct litmus_lock* l)
434#ifdef CONFIG_LITMUS_DGL_SUPPORT 417#ifdef CONFIG_LITMUS_DGL_SUPPORT
435 if(dgl_wait) { 418 if(dgl_wait) {
436 select_next_lock_if_primary(l, dgl_wait); 419 select_next_lock_if_primary(l, dgl_wait);
437 //wake_up_task = atomic_dec_and_test(&dgl_wait->nr_remaining);
438 --(dgl_wait->nr_remaining); 420 --(dgl_wait->nr_remaining);
439 wake_up_task = (dgl_wait->nr_remaining == 0); 421 wake_up_task = (dgl_wait->nr_remaining == 0);
440 } 422 }
@@ -476,7 +458,6 @@ int fifo_mutex_unlock(struct litmus_lock* l)
476 { 458 {
477 if(dgl_wait && tsk_rt(next)->blocked_lock) { 459 if(dgl_wait && tsk_rt(next)->blocked_lock) {
478 BUG_ON(wake_up_task); 460 BUG_ON(wake_up_task);
479 //if(__edf_higher_prio(l->nest.hp_waiter_eff_prio, BASE, next, EFFECTIVE)) {
480 if(litmus->__compare(l->nest.hp_waiter_eff_prio, BASE, next, EFFECTIVE)) { 461 if(litmus->__compare(l->nest.hp_waiter_eff_prio, BASE, next, EFFECTIVE)) {
481 litmus->nested_increase_prio(next, 462 litmus->nested_increase_prio(next,
482 l->nest.hp_waiter_eff_prio, &mutex->lock, flags); // unlocks lock && hp_blocked_tasks_lock. 463 l->nest.hp_waiter_eff_prio, &mutex->lock, flags); // unlocks lock && hp_blocked_tasks_lock.
@@ -557,7 +538,6 @@ void fifo_mutex_propagate_increase_inheritance(struct litmus_lock* l,
557 538
558 old_max_eff_prio = top_priority(&tsk_rt(owner)->hp_blocked_tasks); 539 old_max_eff_prio = top_priority(&tsk_rt(owner)->hp_blocked_tasks);
559 540
560 //if((t != mutex->hp_waiter) && edf_higher_prio(t, mutex->hp_waiter)) {
561 if((t != mutex->hp_waiter) && litmus->compare(t, mutex->hp_waiter)) { 541 if((t != mutex->hp_waiter) && litmus->compare(t, mutex->hp_waiter)) {
562 TRACE_TASK(t, "is new highest-prio waiter by propagation.\n"); 542 TRACE_TASK(t, "is new highest-prio waiter by propagation.\n");
563 mutex->hp_waiter = t; 543 mutex->hp_waiter = t;
@@ -580,7 +560,6 @@ void fifo_mutex_propagate_increase_inheritance(struct litmus_lock* l,
580 if(new_max_eff_prio != old_max_eff_prio) { 560 if(new_max_eff_prio != old_max_eff_prio) {
581 // new_max_eff_prio > old_max_eff_prio holds. 561 // new_max_eff_prio > old_max_eff_prio holds.
582 if ((effective_priority(owner) == old_max_eff_prio) || 562 if ((effective_priority(owner) == old_max_eff_prio) ||
583 //(__edf_higher_prio(new_max_eff_prio, BASE, owner, EFFECTIVE))) {
584 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))) { 563 (litmus->__compare(new_max_eff_prio, BASE, owner, EFFECTIVE))) {
585 TRACE_CUR("Propagating inheritance to holder of lock %d.\n", 564 TRACE_CUR("Propagating inheritance to holder of lock %d.\n",
586 l->ident); 565 l->ident);
@@ -675,7 +654,6 @@ void fifo_mutex_propagate_decrease_inheritance(struct litmus_lock* l,
675 TRACE_CUR("Propagating decreased inheritance to holder of lock %d.\n", 654 TRACE_CUR("Propagating decreased inheritance to holder of lock %d.\n",
676 l->ident); 655 l->ident);
677 656
678 //if(__edf_higher_prio(new_max_eff_prio, BASE, owner, BASE)) {
679 if(litmus->__compare(new_max_eff_prio, BASE, owner, BASE)) { 657 if(litmus->__compare(new_max_eff_prio, BASE, owner, BASE)) {
680 TRACE_CUR("%s/%d has greater base priority than base priority of owner (%s/%d) of lock %d.\n", 658 TRACE_CUR("%s/%d has greater base priority than base priority of owner (%s/%d) of lock %d.\n",
681 (new_max_eff_prio) ? new_max_eff_prio->comm : "null", 659 (new_max_eff_prio) ? new_max_eff_prio->comm : "null",