From: Mathieu Desnoyers Date: Wed, 14 Apr 2010 16:56:53 +0000 (-0400) Subject: Simplify qsbr online condition X-Git-Tag: v0.4.4~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=92cb20a84557a365cabcde63cb19809a7cbb2651;p=userspace-rcu.git Simplify qsbr online condition Alan Stern wrote: > return v && (v - rcu_gp_ctr > ULONG_MAX / 2); > > Wouldn't it be better to write: > > return v != 0 && v != rcu_gp_ctr; > > or something equivalent? The point is, it's foolish to return 0 when > rcu_gp_ctr has wrapped around to below v. This can happen only when > rcu_thread_online() is delayed (as by preemption), in which case we > know that there's a good chance the algorithm will fail. My version of > the test eliminates the possibility of this failure, although it > doesn't eliminate the possibility that rcu_gp_ctr has wrapped around so > far that it is equal to v. Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 8822e05..125301f 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -169,7 +169,7 @@ static inline int rcu_gp_ongoing(unsigned long *ctr) unsigned long v; v = LOAD_SHARED(*ctr); - return v && (v - rcu_gp_ctr > ULONG_MAX / 2); + return v && (v != rcu_gp_ctr); } #endif /* !(BITS_PER_LONG < 64) */