Re: [Regression] [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy

From: Ian Rogers

Date: Mon Nov 30 2026 - 18:44:45 EST


On Tue, Nov 17, 2026 at 2:26 PM Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
>
> On 17.11.2026 14:15:06, Ian Rogers wrote:
> > On Tue, Nov 17, 2026 at 12:27 PM Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
> > >
> > > On 17.11.2026 09:46:55, Ian Rogers wrote:
> > > > > There was discussion and I learned a lot about the nitty gritty details
> > > > > of compilers, optimization and UB. But the problem is still in the
> > > > > mainline tree. What can we do about it? Is reverting an option?
> > > >
> > > > I see the config option was picked up here:
> > > > https://lore.kernel.org/lkml/179423891136.2093942.13129678709622655290.tip-bot2@tip-bot2/
> > >
> > > Doh! Thanks for the pointer.
> >
> > No worries, sorry for the regression. Have bugs been filed against GCC
> > and LLVM regarding this?
>
> Not from our side.

Hi Marc,

I looked into this further and filed a bug with GCC tracking the missed
optimization on targets with -mno-unaligned-access:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129182

On ARMv5TE (and other strict-alignment architectures), GCC spills scalars to
the stack and generates out-of-line 'bl memcpy' library calls when taking
the address of local variables in put_unaligned(), whereas the packed struct
approach lowers inline to ldrb/strb and register shifts.

Regarding LLVM / Clang: it turns out Clang already optimizes this properly.
On '--target=armv5te-linux-gnueabi -mno-unaligned-access', Clang successfully
folds constant-size scalar __builtin_memcpy() calls into inline byte accesses
with zero stack spills and no libcalls, so no bug was needed there. The
I/O regression appears to have been strictly an issue with GCC's lowering.

Thanks,
Ian

> Marc
>
> --
> Pengutronix e.K. | Marc Kleine-Budde |
> Embedded Linux | https://www.pengutronix.de |
> Vertretung Nürnberg | Phone: +49-5121-206917-129 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |