Skip to contentSkip to conversation

x86/vdso: Emit a GNU hash

PATCH In review Andy Lutomirski 6 participants 7 messages Aug 6, 2015 – Aug 9, 2015

Subsystems (4)
lore
Share & tools
lore

Andy Lutomirski

author maintainer
#0 lore raw

PATCH 1/1 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.

---

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(-)
arch/x86/entry/vdso/Makefile +1 -1
index e97032069f88..20f3ac53148d 100644
@@ -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
 
Signature · 1 line
2.4.3
#1 lore raw

[adding lots of cc's]

Quoted 12 lines · Andy Lutomirski

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.

Quoted 4 lines

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

Quoted 25 lines

---

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(-)
arch/x86/entry/vdso/Makefile +1 -2
index e97032069f88..20f3ac53148d 100644
@@ -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

Signature · 2 lines
Andy Lutomirski
AMA Capital Management, LLC
#2 lore raw

PATCH 1/1 tile/vdso: emit a GNU hash as well

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

---
 arch/tile/kernel/vdso/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/tile/kernel/vdso/Makefile +2 -2
index a025f63d54cd..c54fff37b5ff 100644
@@ -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)
Signature · 1 line
2.1.2
#3 lore raw

PATCH 1/1 s390/vdso: emit a GNU hash

In reply to Andy Lutomirski
Quoted 1 line

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.

---
 arch/s390/kernel/vdso32/Makefile | 2 +-
 arch/s390/kernel/vdso64/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/vdso32/Makefile +1 -1
index 8ad2b34..ee8a18e 100644
@@ -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)
arch/s390/kernel/vdso64/Makefile +1 -1
index 2a8ddfd..c4b03f9 100644
@@ -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)
Signature · 1 line
2.3.8
#4 lore raw
In reply to Andy Lutomirski
Quoted 8 lines · Andy Lutomirski

[adding lots of cc's]

Quoted 5 lines · Andy Lutomirski

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.

#5 lore raw
Quoted 6 lines · Nathan Lynch
Quoted 5 lines · Andy Lutomirski

[adding lots of cc's]

Quoted 2 lines · Andy Lutomirski

From: Andy Lutomirski <[email protected]>

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

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

#6 lore raw
In reply to Andy Lutomirski
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.

---
 arch/x86/entry/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/vdso/Makefile +1 -1
index 96c0617..a3d0767 100644
@@ -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