2015-08-06 21:45:55

by Andy Lutomirski

[permalink] [raw]
Subject: [PATCH] x86/vdso: Emit a GNU hash

From: Andy Lutomirski <[email protected]>

Some dynamic loaders may be slightly faster if a GNU hash is
available. Strangely, this seems to have no effect at all on the
vdso size.

This is unlikely to have any measurable effect on the time it takes
to resolve vdso symbols (since there are so few of them). In some
contexts, it can be a win for a different reason: if every DSO has a
GNU hash section, then libc can avoid calculating SysV hashes at
all. Both musl and glibc appear to have this optimization.

It's plausible that this breaks some ancient glibc version. If so,
then, depending on what glibc versions break, we could either
require COMPAT_VDSO for them or consider reverting.

Signed-off-by: Andy Lutomirski <[email protected]>
---

For review. I'll add it to my (currently empty) 4.3 pull request if
people like it, unless Ingo feels like adding it to -tip directly.

arch/x86/entry/vdso/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index e97032069f88..20f3ac53148d 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'

-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
+VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
$(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
GCOV_PROFILE := n

--
2.4.3


2015-08-06 22:53:06

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH] x86/vdso: Emit a GNU hash

[adding lots of cc's]

On Thu, Aug 6, 2015 at 2:45 PM, Andy Lutomirski <[email protected]> wrote:
> From: Andy Lutomirski <[email protected]>
>
> Some dynamic loaders may be slightly faster if a GNU hash is
> available. Strangely, this seems to have no effect at all on the
> vdso size.
>
> This is unlikely to have any measurable effect on the time it takes
> to resolve vdso symbols (since there are so few of them). In some
> contexts, it can be a win for a different reason: if every DSO has a
> GNU hash section, then libc can avoid calculating SysV hashes at
> all. Both musl and glibc appear to have this optimization.
>
> It's plausible that this breaks some ancient glibc version. If so,
> then, depending on what glibc versions break, we could either
> require COMPAT_VDSO for them or consider reverting.
>

Adding lots of arch vdso people.

I think this would be a good thing to do in general. Want to update
your arches (powerpc, arm(64), s390, tile, and hexagon -- did I miss
any?)?

--Andy

> Signed-off-by: Andy Lutomirski <[email protected]>
> ---
>
> For review. I'll add it to my (currently empty) 4.3 pull request if
> people like it, unless Ingo feels like adding it to -tip directly.
>
> arch/x86/entry/vdso/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
> index e97032069f88..20f3ac53148d 100644
> --- a/arch/x86/entry/vdso/Makefile
> +++ b/arch/x86/entry/vdso/Makefile
> @@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
> -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
> sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
>
> -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
> +VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
> $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
> GCOV_PROFILE := n
>
> --
> 2.4.3
>



--
Andy Lutomirski
AMA Capital Management, LLC

2015-08-07 00:49:00

by Chris Metcalf

[permalink] [raw]
Subject: [PATCH] tile/vdso: emit a GNU hash as well

In principle, including the GNU hash can allow libc to avoid
calculating SysV hashes at all.

Signed-off-by: Chris Metcalf <[email protected]>
---
arch/tile/kernel/vdso/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/tile/kernel/vdso/Makefile b/arch/tile/kernel/vdso/Makefile
index a025f63d54cd..c54fff37b5ff 100644
--- a/arch/tile/kernel/vdso/Makefile
+++ b/arch/tile/kernel/vdso/Makefile
@@ -54,7 +54,7 @@ $(obj)/built-in.o: $(obj)/vdso-syms.o
$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o

SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
- $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+ $(call cc-ldoption, -Wl$(comma)--hash-style=both)
SYSCFLAGS_vdso_syms.o = -r
$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
$(call if_changed,vdsold)
@@ -113,6 +113,6 @@ $(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S
$(obj)/vdso32.o: $(obj)/vdso32.so

SYSCFLAGS_vdso32.so.dbg = -m32 -shared -s -Wl,-soname=linux-vdso32.so.1 \
- $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+ $(call cc-ldoption, -Wl$(comma)--hash-style=both)
$(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32)
$(call if_changed,vdsold)
--
2.1.2

2015-08-07 07:03:06

by Martin Schwidefsky

[permalink] [raw]
Subject: [PATCH] s390/vdso: emit a GNU hash

>From 9a3d93634bd74b07a988fa0fc729d1f711253a91 Mon Sep 17 00:00:00 2001
From: Martin Schwidefsky <[email protected]>
Date: Fri, 7 Aug 2015 08:55:48 +0200
Subject: [PATCH] s390/vdso: emit a GNU hash

As proposed by Andy Lutomirski create the SysV and the GNU hash
for the vdso objects. This may make some dynamic loaders a bit
faster.

Signed-off-by: Martin Schwidefsky <[email protected]>
---
arch/s390/kernel/vdso32/Makefile | 2 +-
arch/s390/kernel/vdso64/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
index 8ad2b34..ee8a18e 100644
--- a/arch/s390/kernel/vdso32/Makefile
+++ b/arch/s390/kernel/vdso32/Makefile
@@ -13,7 +13,7 @@ KBUILD_AFLAGS_31 += -m31 -s
KBUILD_CFLAGS_31 := $(filter-out -m64,$(KBUILD_CFLAGS))
KBUILD_CFLAGS_31 += -m31 -fPIC -shared -fno-common -fno-builtin
KBUILD_CFLAGS_31 += -nostdlib -Wl,-soname=linux-vdso32.so.1 \
- $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+ $(call cc-ldoption, -Wl$(comma)--hash-style=both)

$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_31)
$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_31)
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
index 2a8ddfd..c4b03f9 100644
--- a/arch/s390/kernel/vdso64/Makefile
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -13,7 +13,7 @@ KBUILD_AFLAGS_64 += -m64 -s
KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin
KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
- $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+ $(call cc-ldoption, -Wl$(comma)--hash-style=both)

$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
--
2.3.8

2015-08-07 16:12:03

by Lynch, Nathan

[permalink] [raw]
Subject: Re: [PATCH] x86/vdso: Emit a GNU hash

On 08/06/2015 05:52 PM, Andy Lutomirski wrote:
> [adding lots of cc's]
>
> On Thu, Aug 6, 2015 at 2:45 PM, Andy Lutomirski <[email protected]> wrote:
>> From: Andy Lutomirski <[email protected]>
>>
>> Some dynamic loaders may be slightly faster if a GNU hash is
>> available. Strangely, this seems to have no effect at all on the
>> vdso size.

FWIW, I see arch/x86/entry/vdso/vdso64.so increase by 168 bytes here,
using GCC 4.9.2, Binutils 2.24 as packaged by Fedora 21.

I see a similar increase when I make the equivalent change for ARM.

2015-08-07 18:14:11

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH] x86/vdso: Emit a GNU hash

On Fri, Aug 7, 2015 at 9:10 AM, Nathan Lynch <[email protected]> wrote:
> On 08/06/2015 05:52 PM, Andy Lutomirski wrote:
>> [adding lots of cc's]
>>
>> On Thu, Aug 6, 2015 at 2:45 PM, Andy Lutomirski <[email protected]> wrote:
>>> From: Andy Lutomirski <[email protected]>
>>>
>>> Some dynamic loaders may be slightly faster if a GNU hash is
>>> available. Strangely, this seems to have no effect at all on the
>>> vdso size.
>
> FWIW, I see arch/x86/entry/vdso/vdso64.so increase by 168 bytes here,
> using GCC 4.9.2, Binutils 2.24 as packaged by Fedora 21.
>
> I see a similar increase when I make the equivalent change for ARM.
>
>

At least on my configuration, that doesn't push it across a page
boundary, so it doesn't really matter.

--Andy

Subject: [tip:x86/asm] x86/vdso: Emit a GNU hash

Commit-ID: 6b7e26547fad7ace3dcb27a5babd2317fb9d1e12
Gitweb: http://git.kernel.org/tip/6b7e26547fad7ace3dcb27a5babd2317fb9d1e12
Author: Andy Lutomirski <[email protected]>
AuthorDate: Thu, 6 Aug 2015 14:45:45 -0700
Committer: Ingo Molnar <[email protected]>
CommitDate: Sat, 8 Aug 2015 10:42:07 +0200

x86/vdso: Emit a GNU hash

Some dynamic loaders may be slightly faster if a GNU hash is
available. Strangely, this seems to have no effect at all on
the vdso size.

This is unlikely to have any measurable effect on the time it
takes to resolve vdso symbols (since there are so few of them).
In some contexts, it can be a win for a different reason: if
every DSO has a GNU hash section, then libc can avoid
calculating SysV hashes at all. Both musl and glibc appear to
have this optimization.

It's plausible that this breaks some ancient glibc version. If
so, then, depending on what glibc versions break, we could
either require COMPAT_VDSO for them or consider reverting.

Signed-off-by: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Isaac Dunham <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Nathan Lynch <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected] <[email protected]>
Link: http://lkml.kernel.org/r/fd56cc057a2d62ab31c56a48d04fccb435b3fd4f.1438897382.git.luto@kernel.org
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/entry/vdso/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 96c0617..a3d0767 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'

-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
+VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
$(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
GCOV_PROFILE := n