Module: xenomai-3
Branch: wip/dovetail
Commit: 248297b3e7ae5516140b836eda749099cbecd1f8
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=248297b3e7ae5516140b836eda749099cbecd1f8

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 b758d50..7983165 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1594,7 +1594,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),
@@ -1606,6 +1606,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();
@@ -1724,7 +1726,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);
@@ -1737,7 +1739,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:
@@ -2632,10 +2634,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))
@@ -2652,6 +2654,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