[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFwLnz4ZNgKxJ6ANn7usppJC_OKHy0uVuh2+EhYTuiL5yw@mail.gmail.com>
Date: Wed, 24 Oct 2012 16:18:13 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Juri Lelli <juri.lelli@...il.com>
Cc: peterz@...radead.org, tglx@...utronix.de, mingo@...hat.com,
rostedt@...dmis.org, oleg@...hat.com, fweisbec@...il.com,
darren@...art.com, johan.eker@...csson.com, p.faure@...tech.ch,
linux-kernel@...r.kernel.org, claudio@...dence.eu.com,
michael@...rulasolutions.com, fchecconi@...il.com,
tommaso.cucinotta@...up.it, nicola.manica@...i.unitn.it,
luca.abeni@...tn.it, dhaval.giani@...il.com, hgu1972@...il.com,
paulmck@...ux.vnet.ibm.com, raistlin@...ux.it,
insop.song@...csson.com, liming.wang@...driver.com,
jkacur@...hat.com, harald.gustafsson@...csson.com,
vincent.guittot@...aro.org,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 01/16] math128: Introduce various 128bit primitives
On Wed, Oct 24, 2012 at 2:53 PM, Juri Lelli <juri.lelli@...il.com> wrote:
> From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
>
> Grow rudimentary u128 support without relying on gcc/libgcc.
I missed the part where somebody explains why and what needs this?
It's going to be very expensive indeed on some platforms, so the fact
that it is *sometimes* cheap doesn't necessarily imply it should ever
be used.
So please, explain what the pressing need is that is so worthwhile
that this is worth it. Maybe it was in a 00/16 cover letter, but not
only was that not sent out to the people who got 01, you'd still want
it in the commit message.
> +typedef union {
> + struct {
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> + u64 lo, hi;
> +#else
> + u64 hi, lo;
> +#endif
> + };
> +#ifdef __SIZEOF_INT128__ /* gcc-4.6+ */
> + unsigned __int128 val;
> +#endif
> +} u128;
This also looks totally wrong.
If gcc has native support for __int128, then the union is pointless.
Don't do it. Just do
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 u128;
#else
typedef struct { ... u64 hi/lo in the right order } u128;
#endif
because it's possible that using the native bare type will make gcc
able to do better for various things.
Sure, it's possible that you want to use a union in low-level
architecture code that implements the actual math, BUT EVEN THEN the
above union is pure and utter garbage. On 32-bit machines, you'd want
to make it a union of 4 32-bit entities etc. So putting it like this
in a generic file looks wrong. In fact, your very own generic
mul_u64_u64() would seem to want to use the "4 32-bit words" kind of
model.
Also, the union isn't used for generic code anyway, since the generic
code has that same __SIZEOF_INT128__ test for which generic version it
should include (and I wonder if it should just be
#ifdef __SIZEOF_INT128__
#include <linux/native-128bit.h>
#elif CONFIG_64BIT
#include <linux/generic64bit-128bit.h>
#else
#include <linux/generic64bit-128bit.h>
#endif
and then have separate files entirely for the "gcc handles the common
operations" vs "64-bit architecture needs two words for most things"
vs "32-bit architectures need 4 words for most things".
I dunno. But I think this is wrong.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists