Module: xenomai-gch
Branch: for-forge
Commit: a4b8e90560b52abe29962fd3f10ed768d3b24a54
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=a4b8e90560b52abe29962fd3f10ed768d3b24a54

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Fri Apr 25 21:32:33 2014 +0200

cobalt/shadow: do not use xnsched_current_thread()

for the implementation of per personality private data.

---

 kernel/cobalt/shadow.c |   40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index 04652bf..c107dc4 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -82,6 +82,7 @@ static void *mayday_page;
 static struct xnsynch yield_sync;
 
 static struct hlist_head *process_hash;
+static DEFINE_XNLOCK(process_hash_lock);
 #define PROCESS_HASH_SIZE 13
 
 static int enter_personality(struct xnshadow_process *process,
@@ -114,8 +115,13 @@ static unsigned __attribute__((pure)) 
process_hash_crunch(struct mm_struct *mm)
 
 static struct xnshadow_process *__process_hash_search(struct mm_struct *mm)
 {
-       unsigned bucket = process_hash_crunch(mm);
        struct xnshadow_process *p;
+       unsigned bucket;
+
+       if (mm == NULL)
+               return NULL;
+
+       bucket = process_hash_crunch(mm);
        
        atomic_only();
 
@@ -131,9 +137,9 @@ static struct xnshadow_process *process_hash_search(struct 
mm_struct *mm)
        struct xnshadow_process *process;
        spl_t s;
        
-       xnlock_get_irqsave(&nklock, s);
+       xnlock_get_irqsave(&process_hash_lock, s);
        process = __process_hash_search(mm);
-       xnlock_put_irqrestore(&nklock, s);
+       xnlock_put_irqrestore(&process_hash_lock, s);
        
        return process;
 }
@@ -145,7 +151,7 @@ static int process_hash_enter(struct xnshadow_process *p)
        int err;
        spl_t s;
 
-       xnlock_get_irqsave(&nklock, s);
+       xnlock_get_irqsave(&process_hash_lock, s);
        if (__process_hash_search(mm)) {
                err = -EBUSY;
                goto out;
@@ -155,7 +161,7 @@ static int process_hash_enter(struct xnshadow_process *p)
        hlist_add_head(&p->hlink, &process_hash[bucket]);
        err = 0;
   out:
-       xnlock_put_irqrestore(&nklock, s);
+       xnlock_put_irqrestore(&process_hash_lock, s);
        return err;
 }
 
@@ -163,10 +169,10 @@ static void process_hash_remove(struct xnshadow_process 
*p)
 {
        spl_t s;
 
-       xnlock_get_irqsave(&nklock, s);
+       xnlock_get_irqsave(&process_hash_lock, s);
        if (p->mm)
                hlist_del(&p->hlink);
-       xnlock_put_irqrestore(&nklock, s);
+       xnlock_put_irqrestore(&process_hash_lock, s);
 }
 
 /* nklock locked, irqs off. */
@@ -175,7 +181,7 @@ static void *private_lookup(unsigned int muxid)
        struct xnshadow_process *p = xnshadow_current_process();
 
        if (p == NULL) {
-               p = __process_hash_search(current->mm);
+               p = process_hash_search(current->mm);
                if (p == NULL)
                        return NULL;
        }
@@ -1327,10 +1333,10 @@ static int xnshadow_sys_bind(unsigned int magic,
 
        return -ESRCH;
 do_bind:
-       xnlock_get_irqsave(&nklock, s);
+       xnlock_get_irqsave(&process_hash_lock, s);
        process = __process_hash_search(current->mm);
        priv = private_lookup(muxid);
-       xnlock_put_irqrestore(&nklock, s);
+       xnlock_put_irqrestore(&process_hash_lock, s);
 
        /*
         * Protect from the same process binding to the same interface
@@ -1753,19 +1759,7 @@ EXPORT_SYMBOL_GPL(xnshadow_unregister_personality);
  */
 void *xnshadow_get_context(unsigned int muxid)
 {
-       struct xnthread *curr;
-       void *context = NULL;
-       spl_t s;
-
-       xnlock_get_irqsave(&nklock, s);
-
-       curr = xnsched_current_thread();
-       if (likely(xnthread_test_state(curr, XNROOT|XNUSER)))
-               context = private_lookup(muxid);
-
-       xnlock_put_irqrestore(&nklock, s);
-
-       return context;
+       return private_lookup(muxid);
 }
 EXPORT_SYMBOL_GPL(xnshadow_get_context);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to