From: Mathieu Desnoyers Date: Thu, 23 Apr 2015 18:00:23 +0000 (-0400) Subject: Fix: deadlock when thread join is issued in read-side C.S. X-Git-Tag: v0.9.0~60 X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=731ccb963c80afd067e20acee2f9bd7cb4875ffb;hp=731ccb963c80afd067e20acee2f9bd7cb4875ffb;p=userspace-rcu.git Fix: deadlock when thread join is issued in read-side C.S. The transitive dependency between: RCU read-side C.S. -> synchronize_rcu -> rcu_gp_lock -> rcu_register_thread and the dependency: pthread_join -> awaiting for thread completion Can block a thread on join, and thus have the side-effect of deadlocking a thread doing a pthread_join while within a RCU read-side critical section. This join would be awaiting for completion of register_thread or rcu_unregister_thread, which may never complete because the rcu_gp_lock is held by synchronize_rcu executed from another thread. One solution to fix this is to add a new lock, rcu_registry_lock. This lock now protects the thread registry. It is released between iterations on the registry by synchronize_rcu, thus allowing thread registration/unregistration to complete even though synchronize_rcu is awaiting for RCU read-side critical sections to complete. Signed-off-by: Mathieu Desnoyers Reviewed-by: Paul E. McKenney CC: Eugene Ivanov CC: Lai Jiangshan CC: Stephen Hemminger ---