It is redundant to wake the grantee task if it is already running

Credit goes to Peter for the general idea.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
Signed-off-by: Peter Morreale <[EMAIL PROTECTED]>
---

 kernel/rtmutex.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index 15fc6e6..cb27b08 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -511,6 +511,24 @@ static void wakeup_next_waiter(struct rt_mutex *lock, int 
savestate)
        pendowner = waiter->task;
        waiter->task = NULL;
 
+       /*
+        * Do the wakeup before the ownership change to give any spinning
+        * waiter grantees a headstart over the other threads that will
+        * trigger once owner changes.
+        */
+       if (!savestate)
+               wake_up_process(pendowner);
+       else {
+               smp_mb();
+               /*
+                * This may appear to be a race, but the barriers close the
+                * window.
+                */
+               if ((pendowner->state != TASK_RUNNING)
+                   && (pendowner->state != TASK_RUNNING_MUTEX))
+                       wake_up_process_mutex(pendowner);
+       }
+
        rt_mutex_set_owner(lock, pendowner, RT_MUTEX_OWNER_PENDING);
 
        spin_unlock(&current->pi_lock);
@@ -537,11 +555,6 @@ static void wakeup_next_waiter(struct rt_mutex *lock, int 
savestate)
                plist_add(&next->pi_list_entry, &pendowner->pi_waiters);
        }
        spin_unlock(&pendowner->pi_lock);
-
-       if (savestate)
-               wake_up_process_mutex(pendowner);
-       else
-               wake_up_process(pendowner);
 }
 
 /*

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to