lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20061125211818.GA167@oleg>
Date:	Sun, 26 Nov 2006 00:18:18 +0300
From:	Oleg Nesterov <oleg@...sign.ru>
To:	"David S. Miller" <davem@...emloft.net>,
	David Howells <dhowells@...hat.com>
Cc:	Alan Stern <stern@...land.harvard.edu>,
	"Paul E. McKenney" <paulmck@...ibm.com>,
	linux-kernel@...r.kernel.org
Subject: atomic_add_unless() and mb()

Both Documentation/memory-barriers.txt and Documentation/atomic_ops.txt state
that atomic_add_unless() implies smp_mb() on each side of the operation.

Is it true?

include/asm-most_of/atomic.h:

	#define atomic_add_unless(v, a, u)				\
	({								\
		int c, old;						\
		c = atomic_read(v);					\
		for (;;) {						\
			if (unlikely(c == (u)))				\
				break;					\
			old = atomic_cmpxchg((v), c, c + (a));		\
			if (likely(old == c))				\
				break;					\
			c = old;					\
		}							\
		c != (u);						\
	})

This looks like atomic_add_unless() implies mb() only if it returns 1.
Otherwise it could fail (return 0) before the first atomic_cmpxchg(),
but atomic_read() provides a compiler barrier only.

Could you clarify?

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ