From 92cb20a84557a365cabcde63cb19809a7cbb2651 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 14 Apr 2010 12:56:53 -0400 Subject: [PATCH] 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 --- urcu-qsbr-static.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) */ -- 2.34.1