[Sheepdog] [PATCH] zookeeper: switch gcc atomic builtins to atomic helpers

Liu Yuan namei.unix at gmail.com
Tue May 8 13:55:14 CEST 2012


On 05/08/2012 07:48 PM, Christoph Hellwig wrote:

> On Tue, May 08, 2012 at 05:34:25PM +0800, Liu Yuan wrote:
>> +	if (!uatomic_add_return(&zk_notify_blocked, 0)
>> +		&& uatomic_add_return(&nr_zk_levents, 0)) {
> 
> Shouldn't these use uatomic_read?
> 
>> +		nr_levents = uatomic_sub_return(&nr_zk_levents, 1) + 1;
> 
> The combination of a read and an atomic_sub later looks racy to me, what
> prevents nr_zk_levents from changing between the two calls?
> 
>> +		if (uatomic_add_return(&nr_zk_levents, 0) || rc == ZOK) {
> 
> uatomic_read again?
> 
>> +	if (uatomic_add_return(&zk_notify_blocked, 0))
> 
> here as well.
> 


Ah, yea, thanks for reminding, I wasn't aware of this handful helper.

Thanks,
Yuan



More information about the sheepdog mailing list