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>
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) */