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

Christoph Hellwig hch at infradead.org
Tue May 8 13:48:02 CEST 2012


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.




More information about the sheepdog mailing list