From owner-freebsd-arch@FreeBSD.ORG Wed Jul 31 17:32:52 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DB791C9E; Wed, 31 Jul 2013 17:32:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 550AE2EFA; Wed, 31 Jul 2013 17:32:52 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id r6VHWlte080920; Wed, 31 Jul 2013 20:32:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua r6VHWlte080920 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id r6VHWl2J080919; Wed, 31 Jul 2013 20:32:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 31 Jul 2013 20:32:47 +0300 From: Konstantin Belousov To: Jung-uk Kim Subject: Re: [PATCH] Atomic swap and test-and-set Message-ID: <20130731173247.GK4972@kib.kiev.ua> References: <51F81A74.4030009@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8BaRf9C5c8wiXWYy" Content-Disposition: inline In-Reply-To: <51F81A74.4030009@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: 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: Wed, 31 Jul 2013 17:32:52 -0000 --8BaRf9C5c8wiXWYy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 30, 2013 at 03:56:36PM -0400, Jung-uk Kim wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >=20 > The attached patch implements atomic_swap_() and > atomic_testandset_() for x86. is int or long ATM. >=20 > The semantics of each operation (in atomic(9) style): >=20 > atomic_swap(p, v) > r =3D *p; > *p =3D v; > return (r); >=20 > atomic_testandset(p, s) > v =3D ()1 << s % (sizeof() * NBBY); > r =3D (*p & v) !=3D 0; > *p |=3D v; > return (r); >=20 > Note atomic_readandclear_() is now obsolete and implemented as a > macro around atomic_swap_() where the new value v is 0. >=20 > 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. 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. --8BaRf9C5c8wiXWYy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJR+Uo+AAoJEJDCuSvBvK1BNwIP/A6R23nUTIikAx0NRkjQzmlw eksqbyOIxOKDvWhiIjXxhFbxuU0y55usIiXS0mLQS/6NcaPkGmJWYouCvBbK5ION FbyXhjbN0yVWa9qYnCn3aipbMrmVw+yTNYkmerEBkv/i/0TGNRfaDPnKzZt29u/K dsl2aTeTllugh4Zce9JiiNgK6BiBFzsVSiAGFgXqEvbfsGM4waTisH9nS4ReeQyx ryteWLHjbCWHLJX/hhqSDjL/zYkD767XXlmzdCfLbD+FWZh4gxsgFz/LL3Y+ugwy ie292+xnDbCVNGz60W8zizuYMTHXiH9J2J51RY8wlJ0RcKfpmNyy2DMqLlMqeCr0 SgQ1/UhKVNDcsXlAm9l8qEgmjRi7p38IXEw4Xlz3mcBGaM8kv/gwAVJwKa4p9CK9 d8OzdBOaV7KKhQrt3defuYs2qCLJk/9U/dYjKpqD4ZXp13Q2XYFRbPzsU1Z+Mt1Y gRR1OSbBbsLe+aV0BysFlHIntS3+5TI1aV1OIZuAb/ofZ8OSuhegZUwkKT2Peq6n OqpfIs5EMuLFhYBGOuTHGFXXqzntCSR+pmr11r2QEDg8g/y7H/Pc0qmYdvBpUkbg DYwcyoUss+BozChMNflQOCd4/Tnjg8gV6Q7cEzhAKi2j+wxqsKWGHhDDR6EU3lUy R6Dzj7lIBH1jysnbGiOC =0S+E -----END PGP SIGNATURE----- --8BaRf9C5c8wiXWYy--