From: Eric Biggers <ebiggers@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Ian Rogers <irogers@google.com>, Yuzhuo Jing <yuzhuo@google.com>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/3] vdso: Switch get/put unaligned from packed struct to memcpy
Date: Mon, 16 Jun 2025 23:32:36 -0700 [thread overview]
Message-ID: <20250617063236.GI8289@sol> (raw)
In-Reply-To: <c57de5bf-d55c-48c5-9dfa-e2fb844dafe9@csgroup.eu>
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.
- Eric
next prev parent reply other threads:[~2025-06-17 6:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 0:57 [PATCH v1 0/3] Switch get/put unaligned to use memcpy Ian Rogers
2025-06-17 0:57 ` [PATCH v1 1/3] vdso: Switch get/put unaligned from packed struct to memcpy Ian Rogers
2025-06-17 5:22 ` Christophe Leroy
2025-06-17 6:32 ` Eric Biggers [this message]
2025-06-17 9:13 ` Christophe Leroy
2025-06-17 17:21 ` kernel test robot
2025-06-17 18:55 ` kernel test robot
2025-06-17 0:57 ` [PATCH v1 2/3] tools headers: Update the linux/unaligned.h copy with the kernel sources Ian Rogers
2025-06-17 0:58 ` [PATCH v1 3/3] tools headers: Remove unneeded ignoring of warnings in unaligned.h Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250617063236.GI8289@sol \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=acme@redhat.com \
--cc=christophe.leroy@csgroup.eu \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yuzhuo@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox