Re: Fix misaligned access of ItemPointerData on ARM

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix misaligned access of ItemPointerData on ARM
Date: 2015-05-21 20:38:08
Message-ID: 555E4230.7010900@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 05/21/2015 04:08 PM, Tom Lane wrote:
> I wrote:
>> But BlockIdData is laid out and accessed as two 16-bit fields, so there
>> should be no problem. On what platform exactly do you see a failure?
> Ah, after reading the gcc manual a bit more closely, I get the point.
> For some reason I think we assumed that "packed" would not result in
> misaligning the struct overall, but it clearly could do so, with possible
> efficiency consequences on hardware that doesn't like misaligned accesses.
>
> If the compiler accepts __attribute__((aligned)) then what you've done is
> clearly better. It's not clear to me whether all compilers that accept
> "packed" also accept "aligned", but there are enough ARM machines in the
> buildfarm that we could hope that we'll find out if this isn't portable.
>
> I wonder whether we should drop the ARM assumption and instead write
>
> #if defined(pg_attribute_packed) && defined(pg_attribute_aligned)
> pg_attribute_packed()
> pg_attribute_aligned(2)
> #endif
>
> so that the annotations are applied on every compiler that accepts them.
>
>

Sounds reasonable.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-05-21 20:42:26 Re: INSERT ... ON CONFLICT DO UPDATE with _any_ constraint
Previous Message Tom Lane 2015-05-21 20:28:39 Re: GiST KNN Crasher