Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1452740rwb; Mon, 7 Nov 2022 01:38:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM6o4MnJsmIorJVmkcdIScriaD8ybfaH7k35Gy4hStgRFyW97jcWsuEnllnNUX8AtT3hTOW2 X-Received: by 2002:a17:907:d10:b0:79a:a1fe:8be5 with SMTP id gn16-20020a1709070d1000b0079aa1fe8be5mr47410462ejc.125.1667813939711; Mon, 07 Nov 2022 01:38:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667813939; cv=none; d=google.com; s=arc-20160816; b=F5hXMZqmlKcMCP/91PkCbvaNOyDDBw3M9pDDmEKRNS0UDaUw26LEcMwmYSMEd1gZx+ lpyCcRVp5K9TQRZ3knzskkYTcw2VLreJZ/uHIAWlgewk44FeTowFBgJ0ntazTsmTzAuD FL+seD4xgo/Dc79swn47Fus6iVSDnc4ZQMkEaQLUnHQQWJ/GEcbcREERgJRlbT18PtU3 Ot4N+B8XnULbDIYdzFBAaSUxjreyZh/mFESTLjaPL+0hXBceSaqnIZBwGjvTslIAUfZt nivKVpoxfbkryRjj7hQSouQUr1HJb+CS8wPl+jIUoifHpxB44sFgQgv+cpvenX4PNi7Q YGuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=Aw4KncDvZNqI/UtCsZFSzHHrUJMmnES2r93WyLZRlXk=; b=JvT64T/fQrn6PDFiRJ5rglSCGJfewtV4ZUWPmElJ1nmfEDJhorBcO3phqvpQkL1A41 OSbM5jjT9xMr4mWD2oq219sWFhoALCi4jXTeUfSMvbAnPYlsY3JMXIo6156nZkgtVGRG hok042p+b0fvDkCJAvjtYZMUaGNR56/JCf3Rr2Ma5mXafONOl6/J+t4uIvMWds9L/Y2e icCdYzt5Eb729CJuO0gocHw7o/JDqHx/tlZtQ+ajX01pFZPZfX6Tvh+dMAefnpBSPfiA LbUrQvKKjJ7TvM7LPEi4e2nXKbg/+6RpiWNhUvd9FL9lzCA1OQ4Uakf0/AWHruON5jOR mJlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn16-20020a05640222f000b00461c8f80e34si7486458edb.53.2022.11.07.01.38.35; Mon, 07 Nov 2022 01:38:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbiKGJOc convert rfc822-to-8bit (ORCPT + 95 others); Mon, 7 Nov 2022 04:14:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbiKGJOa (ORCPT ); Mon, 7 Nov 2022 04:14:30 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C672B3 for ; Mon, 7 Nov 2022 01:14:29 -0800 (PST) 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: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra > Sent: 05 November 2022 15:14 > > 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: > > 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. > > 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. > > Also: > > $ ./align > 16, 16 > > --- > > #include > > int main(int argx, char **argv) > { > __int128 a; > > printf("%d, %d\n", sizeof(a), __alignof(a)); > return 0; > } Well, __alignof() doesn't return the required value. (cf 'long long' on 32bit x86). But the alignment of __int128 is 16 :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)