From owner-freebsd-arch@FreeBSD.ORG Fri Aug 2 00:41:29 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by hub.freebsd.org (Postfix) with ESMTP id D766E937; Fri, 2 Aug 2013 00:41:28 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Message-ID: <51FAFFDF.7040309@FreeBSD.org> Date: Thu, 01 Aug 2013 20:39:59 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130715 Thunderbird/17.0.7 MIME-Version: 1.0 To: Konstantin Belousov Subject: Re: [PATCH] Atomic swap and test-and-set References: <51F81A74.4030009@FreeBSD.org> <20130731173247.GK4972@kib.kiev.ua> <51F96D2C.6030109@FreeBSD.org> In-Reply-To: <51F96D2C.6030109@FreeBSD.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: bde@FreeBSD.org, dumbbell@FreeBSD.org, freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Aug 2013 00:41:29 -0000 -----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_() and >>> atomic_testandset_() for x86. 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 = ()1 << s % (sizeof() * >>> NBBY); r = (*p & v) != 0; *p |= v; return (r); >>> >>> Note atomic_readandclear_() is now obsolete and >>> implemented as a macro around atomic_swap_() 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-----