[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2Z9yzmtYtmYi5rx@hirez.programming.kicks-ass.net>
Date: Sat, 5 Nov 2022 16:14:19 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Nathan Chancellor <nathan@...nel.org>,
Uros Bizjak <ubizjak@...il.com>, x86@...nel.org,
willy@...radead.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
aarcange@...hat.com, kirill.shutemov@...ux.intel.com,
jroedel@...e.de
Subject: Re: [PATCH 11/13] x86_64: Remove pointless set_64bit() usage
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 <peterz@...radead.org> 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 <stdio.h>
int main(int argx, char **argv)
{
__int128 a;
printf("%d, %d\n", sizeof(a), __alignof(a));
return 0;
}
Powered by blists - more mailing lists