[PATCH v1 1/3] vdso: Switch get/put unaligned from packed struct to memcpy
Christophe Leroy
christophe.leroy at csgroup.eu
Tue Jun 17 19:13:26 AEST 2025
+linuxppc list
Le 17/06/2025 à 08:32, Eric Biggers a écrit :
> On Tue, Jun 17, 2025 at 07:22:57AM +0200, Christophe Leroy wrote:
>>
>>
>> Le 17/06/2025 à 02:57, Ian Rogers a écrit :
>>> Type punning is necessary for get/put unaligned but the use of a
>>> packed struct violates strict aliasing rules, requiring
>>> -fno-strict-aliasing to be passed to the C compiler. Switch to using
>>> memcpy so that -fno-strict-aliasing isn't necessary.
>>
>> VDSO build fails with this patch:
>>
>> VDSO32L arch/powerpc/kernel/vdso/vdso32.so.dbg
>> arch/powerpc/kernel/vdso/vdso32.so.dbg: dynamic relocations are not
>> supported
>> make[2]: *** [arch/powerpc/kernel/vdso/Makefile:79:
>> arch/powerpc/kernel/vdso/vdso32.so.dbg] Error 1
>>
>> Behind the relocation issue, calling memcpy() for a single 4-bytes word
>> kills performance.
>
> memcpy() does normally do the right thing for unaligned accesses of 1, 2, 4, or
> 8-byte values. The snag here seems to be that the VDSO is built with
> -fno-builtin (and -ffreestanding which implies -fno-builtin). That causes the
> compiler to no longer optimize out the calls to memcpy(). If __builtin_memcpy()
> is used instead of memcpy(), it does work and generates the same code as before.
Yes right, changing memcpy() to __builtin_memcpy() seems to work, the
exact same code is generated.
Christophe
More information about the Linuxppc-dev
mailing list