Simplify qsbr online condition
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 14 Apr 2010 16:56:53 +0000 (12:56 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 14 Apr 2010 16:56:53 +0000 (12:56 -0400)
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 <mathieu.desnoyers@efficios.com>
urcu-qsbr-static.h

index 8822e050bac8aaa00a8c210dfb122193f2e90280..125301f9b7749c4a93784068eb3f6e320aa156d9 100644 (file)
@@ -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) */
 
This page took 0.025329 seconds and 4 git commands to generate.