From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BABFC4332F for ; Mon, 7 Nov 2022 09:14:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75BF56B0071; Mon, 7 Nov 2022 04:14:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70AF26B0072; Mon, 7 Nov 2022 04:14:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 603916B0073; Mon, 7 Nov 2022 04:14:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5216D6B0071 for ; Mon, 7 Nov 2022 04:14:33 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2DBAA1A0E56 for ; Mon, 7 Nov 2022 09:14:33 +0000 (UTC) X-FDA: 80106085626.19.AEE1ACD Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf26.hostedemail.com (Postfix) with ESMTP id E857F140009 for ; Mon, 7 Nov 2022 09:14:30 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-225-AnRwuhTfMWGD1U-3qJHg_A-1; Mon, 07 Nov 2022 09:14:26 +0000 X-MC-Unique: AnRwuhTfMWGD1U-3qJHg_A-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 7 Nov 2022 09:14:24 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Mon, 7 Nov 2022 09:14:24 +0000 From: David Laight To: 'Peter Zijlstra' , "Jason A. Donenfeld" CC: Linus Torvalds , Nathan Chancellor , Uros Bizjak , "x86@kernel.org" , "willy@infradead.org" , "akpm@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "aarcange@redhat.com" , "kirill.shutemov@linux.intel.com" , "jroedel@suse.de" Subject: RE: [PATCH 11/13] x86_64: Remove pointless set_64bit() usage Thread-Topic: [PATCH 11/13] x86_64: Remove pointless set_64bit() usage Thread-Index: AQHY8Slas2UAHB8/vU20d4zgnfqWVa4zL9Vw Date: Mon, 7 Nov 2022 09:14:24 +0000 Message-ID: References: <20221022111403.531902164@infradead.org> <20221022114425.168036718@infradead.org> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667812472; a=rsa-sha256; cv=none; b=8KbaXrka/6kMcgjSg7PxYALlrzfssozTYdFy4a0bm9N27QgH9sF+kuADAB5TW59A73TAgd 0vWmsLcDdh5iHrODYPBuYgTTHIpgqSVBIYTLy0zTZw6dA1PYszf9UOWTI94+lgok0pkM6Z H4kbQaR2219BRd2+IfLIwxyZCu6oLiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667812472; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7fB3p4R8ezCCvtjR9vtqN+ystFjq3XNsBE8wTxiUT84=; b=u1zMqiH3ygSevo/EZfnGAytRBbyCQ+I3lD1sI4EScfVc/U5E3SPj+FAnZ0dm7LW50lalKt 5UOQVW4a4scxhj3uyu5pdeKdeFr99dwoCfqlDwJ/achwrP/+FJ50ejD7IUQEYw8+bvXzgo Ud4TjEFULBKfL0LqVv65ef1c9g1kENU= X-Stat-Signature: ge9gmi4bmcx68w3wbja6sbanb15qm514 X-Rspamd-Queue-Id: E857F140009 Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com X-Rspamd-Server: rspam05 X-Rspam-User: X-HE-Tag: 1667812470-103864 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Peter Zijlstra > Sent: 05 November 2022 15:14 >=20 > On Sat, Nov 05, 2022 at 02:29:47PM +0100, Jason A. Donenfeld wrote: > > On Fri, Nov 04, 2022 at 10:15:08AM -0700, Linus Torvalds wrote: > > > On Fri, Nov 4, 2022 at 9:01 AM Peter Zijlstra = wrote: > > > > > > > > So cmpxchg_double() does a cmpxchg on a double long value and is > > > > currently supported by: i386, x86_64, arm64 and s390. > > > > > > > > On all those, except i386, two longs are u128. > > > > > > > > So how about we introduce u128 and cmpxchg128 -- then it directly > > > > mirrors the u64 and cmpxchg64 usage we already have. It then also > > > > naturally imposses the alignment thing. > > > > > > Ack, except that we might have some "u128" users that do *not* > > > necessarily want any alignment thing. > > > > > > But maybe we could at least start with an u128 type that is marked as > > > being fully aligned, and if some other user comes in down the line > > > that wants relaxed alignment we can call it "u128_unaligned" or > > > something. > > > > Hm, sounds maybe not so nice for another use case: arithmetic code that > > makes use of u128 for efficient computations, but otherwise has > > no particular alignment requirements. For example, `typedef __uint128_t > > u128;` in: >=20 > Natural alignment is... natural. Making it unaligned is quite mad. That > whole u64 is not naturally aligned on i386 thing Linus referred to is a > sodding pain in the backside. >=20 > If the code has no alignment requirements, natural alignment is as good > as any. And if it does have requirements, you can use u128_unaligned. >=20 > Also: >=20 > $ ./align > 16, 16 >=20 > --- >=20 > #include >=20 > int main(int argx, char **argv) > { > =09__int128 a; >=20 > =09printf("%d, %d\n", sizeof(a), __alignof(a)); > =09return 0; > } Well, __alignof() doesn't return the required value. (cf 'long long' on 32bit x86). But the alignment of __int128 is 16 :-) =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)