aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2011-03-31 10:47:01 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2011-03-31 10:47:01 -0400
commit0f6a8e02773f8c23b5b6a3dbfa044e50c9d7d811 (patch)
treeae9ee07707eaeefc6f7c3cc09d74e40e8c3a1eef
parentc05eaa8091d2cadc20363d44a85ee454262f4bc2 (diff)
Improve FMLP queue management.wip-fmlp-dequeue
The next owner of a FMLP-protected resource is dequeued from the FMLP FIFO queue by unlock() (when the resource is freed by the previous owner) instead of performing the dequeue by the next owner immediately after it has been woken up. This simplifies the code a little bit and also reduces potential spinlock contention.
-rw-r--r--include/litmus/litmus.h2
-rw-r--r--litmus/locking.c12
-rw-r--r--litmus/sched_gsn_edf.c4
-rw-r--r--litmus/sched_psn_edf.c6
4 files changed, 10 insertions, 14 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h
index 94086e2b38db..e7769ca36ec0 100644
--- a/include/litmus/litmus.h
+++ b/include/litmus/litmus.h
@@ -26,7 +26,7 @@ static inline int in_list(struct list_head* list)
26 ); 26 );
27} 27}
28 28
29struct task_struct* waitqueue_first(wait_queue_head_t *wq); 29struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq);
30 30
31#define NO_CPU 0xffffffff 31#define NO_CPU 0xffffffff
32 32
diff --git a/litmus/locking.c b/litmus/locking.c
index 728b56835cf7..2693f1aca859 100644
--- a/litmus/locking.c
+++ b/litmus/locking.c
@@ -107,16 +107,18 @@ asmlinkage long sys_litmus_unlock(int lock_od)
107 return err; 107 return err;
108} 108}
109 109
110struct task_struct* waitqueue_first(wait_queue_head_t *wq) 110struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq)
111{ 111{
112 wait_queue_t *q; 112 wait_queue_t* q;
113 struct task_struct* t = NULL;
113 114
114 if (waitqueue_active(wq)) { 115 if (waitqueue_active(wq)) {
115 q = list_entry(wq->task_list.next, 116 q = list_entry(wq->task_list.next,
116 wait_queue_t, task_list); 117 wait_queue_t, task_list);
117 return (struct task_struct*) q->private; 118 t = (struct task_struct*) q->private;
118 } else 119 __remove_wait_queue(wq, q);
119 return NULL; 120 }
121 return(t);
120} 122}
121 123
122 124
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c
index c5c9600c33d8..08b8847ede97 100644
--- a/litmus/sched_gsn_edf.c
+++ b/litmus/sched_gsn_edf.c
@@ -776,8 +776,6 @@ int gsnedf_fmlp_lock(struct litmus_lock* l)
776 * ->owner. We can thus check it without acquiring the spin 776 * ->owner. We can thus check it without acquiring the spin
777 * lock. */ 777 * lock. */
778 BUG_ON(sem->owner != t); 778 BUG_ON(sem->owner != t);
779
780 remove_wait_queue(&sem->wait, &wait);
781 } else { 779 } else {
782 /* it's ours now */ 780 /* it's ours now */
783 sem->owner = t; 781 sem->owner = t;
@@ -803,7 +801,7 @@ int gsnedf_fmlp_unlock(struct litmus_lock* l)
803 } 801 }
804 802
805 /* check if there are jobs waiting for this resource */ 803 /* check if there are jobs waiting for this resource */
806 next = waitqueue_first(&sem->wait); 804 next = __waitqueue_remove_first(&sem->wait);
807 if (next) { 805 if (next) {
808 /* next becomes the resouce holder */ 806 /* next becomes the resouce holder */
809 sem->owner = next; 807 sem->owner = next;
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c
index abb06fa53e3a..71c02409efa2 100644
--- a/litmus/sched_psn_edf.c
+++ b/litmus/sched_psn_edf.c
@@ -442,10 +442,6 @@ int psnedf_fmlp_lock(struct litmus_lock* l)
442 * ->owner. We can thus check it without acquiring the spin 442 * ->owner. We can thus check it without acquiring the spin
443 * lock. */ 443 * lock. */
444 BUG_ON(sem->owner != t); 444 BUG_ON(sem->owner != t);
445
446 /* FIXME: could we punt the dequeuing to the previous job,
447 * which is holding the spinlock anyway? */
448 remove_wait_queue(&sem->wait, &wait);
449 } else { 445 } else {
450 /* it's ours now */ 446 /* it's ours now */
451 sem->owner = t; 447 sem->owner = t;
@@ -478,7 +474,7 @@ int psnedf_fmlp_unlock(struct litmus_lock* l)
478 unboost_priority(t); 474 unboost_priority(t);
479 475
480 /* check if there are jobs waiting for this resource */ 476 /* check if there are jobs waiting for this resource */
481 next = waitqueue_first(&sem->wait); 477 next = __waitqueue_remove_first(&sem->wait);
482 if (next) { 478 if (next) {
483 /* boost next job */ 479 /* boost next job */
484 boost_priority(next); 480 boost_priority(next);