Date: Sat, 4 Jan 2014 19:29:23 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Oleg Bulyzhin <oleg@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: atomic_load_acq @ i386/amd64 Message-ID: <20140104172923.GY59496@kib.kiev.ua> In-Reply-To: <20140103205159.GA99722@lath.rinet.ru> References: <20140103205159.GA99722@lath.rinet.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
--pfhDleuqWB4Kh3F0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 04, 2014 at 12:51:59AM +0400, Oleg Bulyzhin wrote: >=20 > Hello. >=20 > I've got a question: why atomic_load_acq_* implemented on i386/amd64 archs > with locked cmpxchg instruction? Comment about this > (in /sys/(amd64|i386)/include/atomic.h) looks wrong for me. I believe > acquire/release semantics does not require StoreLoad barrier so simple al= igned > load should be enough. (because acquire/release semantics does not guaran= tee > sequential consistency). You did not explicitely wrote which statement in the comment is false, in your opinion. FreeBSD assumes a property of _acq/_rel stuff which is sometimes called 'total lock ordering'. It is indeed sort of sequential consistency, but only for atomic+membar ops. Would atomic_load_acq() implemented as plain load, it can pass stores, in particular stores from the _rel op, which breaks the guarantee. For x86, there are indeed two possible schemes for implementing critical section, one is lock cmpxchg for get(), and plain store for release(), which is what we use. Another is plain load for get(), and xchg for release(). Then, the load_acq() must be adopted to not break the acq/rel consistency, and since we use plain store for release(), load_acq must use serialing instruction. --pfhDleuqWB4Kh3F0 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJSyETyAAoJEJDCuSvBvK1Bo5QP/1A+2IP95QtfUmdMb5KYY1XT w2oQIODKTsJ9pTjreuNhj4ShdcPJ5IhxilYrLY4lcUycdY/LQzVypO0/2M/1L/TJ 5KcHOYdcsxvEd7gQHqIzgMJLLnHtLK0CT3D2VJ/Tee67FB/fGbCOa55JIL0OWbeD E4gUvqZovhIUE7tjqZW7Dcco6IfPWtvMnr5CIIRR3b7s4Yud4gW5dI1NUfL/jvl9 PwcJQo/KOeFL+7ZkGR6EN5pY9q8e/dNLsJGLbGYjmKboYZN6GfPIZ5Blri0v1yEM nQCs6j+Smhthc1x3Uvi5HdUSc4PcvzRDkHltKAW5+Tuo2gQPMEoIr75AjPWjYdTw cCOjP9mHnZPcSkv5CoDGh+LrbFBr3adgSRa6wD08GJxEZ24wgeXwtBW+jYX+IoRF Ze9nNW91pMsfWKhwxPGs+RSJCMeRgenLRCppg86yGHJ33gUGwRIguijqiH87MOLt IhHrhJV6pk3uZIWB6/Ktv+C4TsTxRtyoIQ1ZZnqq5aIv6uxg+4HTm2UB1fc7vTCy vHi26KTpCrGU5daPRoEJvS8P41Zuw/Ghpc1Ky/DV7ZqxoRLgNz6MlISsscxoZBWU UMCcW/HEcu3tHe8yeZ5rB95H6/r5LObnPX4/f5JSkexjSWuEv78Dj1xP/2zGDCdV pZXfiQ/9oLZVxkV6Z5wy =NHEV -----END PGP SIGNATURE----- --pfhDleuqWB4Kh3F0--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140104172923.GY59496>