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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1E2FC4332F for ; Sat, 5 Nov 2022 13:30:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbiKENaA (ORCPT ); Sat, 5 Nov 2022 09:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiKEN36 (ORCPT ); Sat, 5 Nov 2022 09:29:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C537DFFF for ; Sat, 5 Nov 2022 06:29:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CDBA8B82D6B for ; Sat, 5 Nov 2022 13:29:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51B8FC433D6; Sat, 5 Nov 2022 13:29:53 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="hjcmsaqx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1667654991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R8ndFeWwtbidwmu8ZqWvQNw9vpteG/tvbT1CnALU5sI=; b=hjcmsaqxZPJdNb/SShsGMITrrANeiPj7TEDeov/h5qjjSx35qyF/bbDL+rKwFHLBcZXap/ x5QfUFasXInh1eguji7rbPDV99dvXawiiWB9WQp3JE4dXklrhu+cF23SckzuMZZi6yuzPm RAabW9uqEENLVS2JPtg0zCTbsamtm7E= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 091ecb54 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 5 Nov 2022 13:29:50 +0000 (UTC) Date: Sat, 5 Nov 2022 14:29:47 +0100 From: "Jason A. Donenfeld" To: Linus Torvalds Cc: Peter Zijlstra , 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 Message-ID: References: <20221022111403.531902164@infradead.org> <20221022114425.168036718@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/crypto/poly1305-donna64.c https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/crypto/curve25519-hacl64.c I always thought it'd be nice to see that typedef alongside the others in the shared kernel headers, but figured the requirement for 64-bit and libgcc for some operations on some architectures made it a bit less general purpose, so I never proposed it. Jason