Date: Thu, 01 Aug 2013 20:39:59 -0400 From: Jung-uk Kim <jkim@FreeBSD.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: bde@FreeBSD.org, dumbbell@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: [PATCH] Atomic swap and test-and-set Message-ID: <51FAFFDF.7040309@FreeBSD.org> In-Reply-To: <51F96D2C.6030109@FreeBSD.org> References: <51F81A74.4030009@FreeBSD.org> <20130731173247.GK4972@kib.kiev.ua> <51F96D2C.6030109@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2013-07-31 16:01:48 -0400, Jung-uk Kim wrote: > On 2013-07-31 13:32:47 -0400, Konstantin Belousov wrote: >> On Tue, Jul 30, 2013 at 03:56:36PM -0400, Jung-uk Kim wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>> >>> The attached patch implements atomic_swap_<type>() and >>> atomic_testandset_<type>() for x86. <type> is int or long >>> ATM. >>> >>> The semantics of each operation (in atomic(9) style): >>> >>> atomic_swap(p, v) r = *p; *p = v; return (r); >>> >>> atomic_testandset(p, s) v = (<type>)1 << s % (sizeof(<type>) * >>> NBBY); r = (*p & v) != 0; *p |= v; return (r); >>> >>> Note atomic_readandclear_<type>() is now obsolete and >>> implemented as a macro around atomic_swap_<type>() where the >>> new value v is 0. >>> >>> Please let me know if you have any objection. >> I think that the atomic.diff is fine. > >> You did not documented swap and testandset, which would be good >> to have in the manpage. > > Sure. > >> I think that constraints for all added inlines contradict the >> explicit requirement in the gcc documentation, which states that >> rmw operands should be specified using the 'same location' >> output operand for the input operand (hopefully this can be >> parsed). It just happens so that for "m" compiler cannot do >> anything else then passing the address. > >> The problem is not specific to the new functions, it seems to be >> present in other functions as well, e.g. cmpset. This probably >> can be postponed. > > What a coincidence! I was cleaning up the constraints before I > read your e-mail. Also, I am implementing 64-bit versions for i386 > and moving atomic_cmpset_64 from pmap.h to atomic.h. > > I'll post new patches when I am done. I just created a branch and committed the patches because the final version grew too big. http://svnweb.freebsd.org/base/projects/atomic64 Please let me know what you think. Especially, I need more eyes to review the last two changes: http://svnweb.freebsd.org/changeset/base/253876 http://svnweb.freebsd.org/changeset/base/253877 Feel free to implement the new atomic ops for other architectures, BTW. :-) Thanks! Jung-uk Kim * Note: drm2 patches for AMD GPUs were updated as well: http://people.freebsd.org/~jkim/drm2_atomic.diff http://people.freebsd.org/~jkim/drm2_radeon.diff The second patch is a new addition, which makes it build on i386. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQEcBAEBAgAGBQJR+v/fAAoJECXpabHZMqHOL3kH/1Ak7vGgolriV3XP3vontBjf 6Wj0MkuzA3ytF6uhdoV5XQaDT6De2hTOOJfSDzLvaUiRI7gwlGW+WlGgE03Raly6 bsqcEUID9JCSUDpLc+MaxVBnbSZM6bkenTaSgDzMVCqtHt28BLsFrEHP+yModqaY f/FrVR8RRJc7kjpKu0kpbSwTAUBVR73oJeWP4z58dQvN4EjRd3VbrZDrP42ppzjq CEKjaub4pd7AEOPH18aB4j/WNp1uY04ybsbFubsOdfjOJbSz7oDRhC+rM8rKEuYL XBkNFE5xRL14CxPAluEkgrSNd4RQYTlPPQbup998tgN5gOu9M2wVYPtYlUXQCYk= =CzrX -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51FAFFDF.7040309>