Re: [Regression] [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy
From: Ian Rogers
Date: Mon Oct 19 2026 - 12:16:20 EST
On Mon, Oct 19, 2026 at 5:37 AM Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
>
> On 10.10.2026 08:04:42, Ian Rogers wrote:
> [...]
> > So completely fwiw, I speak to the compiler folks within Google and
> > there has always been unanimous support for code using memcpy over
> > type punning. I'm not sure where the inlining decisions would be
> > impacted, as to my understanding those are made later in the compiler
> > pipeline and things like __unqual_scalar_typeof are almost at the
> > stage of the preprocessor. If -Os is not inlining small fixed size
> > memcpys, this sounds like another compiler bug. It would also be
> > completely valid for the compiler to lower packed struct accesses to
> > memcpys.
> >
> > I was trying to reach an implementation that avoided undefined
> > behavior and benefited both user and kernel code. Performance
> > regressions aren't a benefit and fixing compilers can be tricky, so
> > work remains. I'd prefer to avoid undefined behavior at least in user
> > land. I'd also prefer to avoid config values, so using packed structs
> > for __KERNEL__ code is a possibility. It seems a little sad that we've
> > lived with a strict-aliasing-compliant implementation for a year, and
> > we could regress that for the sake of ARMv5. I don't feel strongly
> > enough to argue for kernel land; hopefully, Thomas can say what
> > motivated moving the patch series forward as I'm pretty certain it
> > wouldn't be undefined behavior in the perf tool :-)
>
> Can we revert commit a339671db64b ("vdso: Switch get/put_unaligned()
> from packed struct to memcpy()")? It touches "include/vdso/unaligned.h"
> only, so the perf header will be unaffected. Or is there an automagic
> copying to "tools/include/vdso/unaligned.h" happening?
It is a little more manual than automagic :-) When perf builds there
is a script that complains if the tools' version of files is
out-of-sync with the kernel's:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/check-headers.sh#n28
It doesn't break the perf build, it just adds noise to it.
My understanding, biased by my opinions, is that the preferred option
is to add a config variable controlling whether to use memcpy or a
packed struct. My preference, to avoid undefined behavior, is to
default to memcpy but set it to use packed structs for ARMv5. I will
vibe code this up, and apologize in advance for any offense such a
patch series may cause (ie I'm sure someone on LKML will want to
complain at me for using memcpy at all and give me a lecture about
strict aliasing being nonsense, etc.). Arnd or someone else may have a
different preferred solution, to which I'm more than happy to defer.
Thanks and apologies again for your ongoing problems,
Ian
> regards,
> 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 |