From mboxrd@z Thu Jan 1 00:00:00 1970 From: ryx@gwmail.gwu.edu (Yuxin Ren) Date: Wed, 27 Apr 2016 22:18:04 -0400 Subject: [lttng-dev] Question about lock in synchronize_rcu implementation of URCU In-Reply-To: <20160428020803.GN4967@linux.vnet.ibm.com> References: <20160428020803.GN4967@linux.vnet.ibm.com> Message-ID: As they don't currently perform grace period, why do we use the rcu_gp_lock? Thank you. Yuxin On Wed, Apr 27, 2016 at 10:08 PM, Paul E. McKenney wrote: > On Wed, Apr 27, 2016 at 09:34:16PM -0400, Yuxin Ren wrote: >> Hi, >> >> I am learning the URCU code. >> >> Why do we need rcu_gp_lock in synchronize_rcu? >> https://github.com/urcu/userspace-rcu/blob/master/urcu.c#L401 >> >> In the comment, it says this lock ensures mutual exclusion between >> threads calling synchronize_rcu(). >> But only the first thread added to waiter queue can proceed to detect >> grace period. >> How can multiple threads currently perform the grace thread? > > They don't concurrently perform grace periods, and it would be wasteful > for them to do so. Instead, the first one performs the grace period, > and all that were waiting at the time it started get the benefit of that > same grace period. > > Any that arrived after the first grace period performs the first > grace period are served by whichever of them performs the second > grace period. > > Thanx, Paul >