Module: xenomai-3
Branch: wip/prioceil
Commit: 655a7fc6ce1e2b50de22947dbb4f54c765a26047
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=655a7fc6ce1e2b50de22947dbb4f54c765a26047

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Mar  2 15:09:11 2016 +0100

cobalt/thread: wait for RCU grace period after killall

---

 kernel/cobalt/thread.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 3e29b3e..a13ecaf 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1598,7 +1598,7 @@ static void grace_elapsed(struct rcu_head *head)
        complete(&wgs->done);
 }
 
-static void wait_grace_period(struct pid *pid)
+static void wait_for_rcu_grace_period(struct pid *pid)
 {
        struct wait_grace_struct wait = {
                .done = COMPLETION_INITIALIZER_ONSTACK(wait.done),
@@ -1610,6 +1610,8 @@ static void wait_grace_period(struct pid *pid)
        for (;;) {
                call_rcu(&wait.rcu, grace_elapsed);
                wait_for_completion(&wait.done);
+               if (pid == NULL)
+                       break;
                rcu_read_lock();
                p = pid_task(pid, PIDTYPE_PID);
                rcu_read_unlock();
@@ -1728,7 +1730,7 @@ int xnthread_join(struct xnthread *thread, bool 
uninterruptible)
         * (__xnthread_cleanup), then waits for a full RCU grace
         * period to have elapsed. Since the completion signal is sent
         * on behalf of do_exit(), we may assume that the joinee has
-        * scheduled away before the grace period ends.
+        * scheduled away before the RCU grace period ends.
         */
        if (uninterruptible)
                wait_for_completion(&thread->exited);
@@ -1741,7 +1743,7 @@ int xnthread_join(struct xnthread *thread, bool 
uninterruptible)
        }
 
        /* Make sure the joinee has scheduled away ultimately. */
-       wait_grace_period(pid);
+       wait_for_rcu_grace_period(pid);
 
        put_pid(pid);
 done:
@@ -2636,10 +2638,10 @@ int xnthread_killall(int grace, int mask)
        xnlock_put_irqrestore(&nklock, s);
 
        /*
-        * Cancel then join all existing user threads during the grace
+        * Cancel then join all existing threads during the grace
         * period. It is the caller's responsibility to prevent more
-        * user threads to bind to the system if required, we won't
-        * make any provision for this here.
+        * threads to bind to the system if required, we won't make
+        * any provision for this here.
         */
        count = nrthreads - nrkilled;
        if (XENO_DEBUG(COBALT))
@@ -2656,6 +2658,9 @@ int xnthread_killall(int grace, int mask)
                ret = wait_event_interruptible(join_all,
                                               cobalt_nrthreads == count);
 
+       /* Wait for a full RCU grace period to expire. */
+       wait_for_rcu_grace_period(NULL);
+
        if (XENO_DEBUG(COBALT))
                printk(XENO_INFO "joined %d threads\n",
                       count + nrkilled - cobalt_nrthreads);


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

Reply via email to