public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Re: [ppc] Include hwcap as ifunc argument
       [not found] <4FBA744A.6000702@twiddle.net>
@ 2012-05-24 14:40 ` Richard Henderson
  2012-05-24 14:45   ` Joseph S. Myers
  2012-05-24 19:47   ` David Miller
  2012-05-25 17:44 ` Richard Henderson
  1 sibling, 2 replies; 8+ messages in thread
From: Richard Henderson @ 2012-05-24 14:40 UTC (permalink / raw)
  To: libc-alpha, libc-ports; +Cc: Ryan S. Arnold, David Miller, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

On 05/21/2012 09:58 AM, Richard Henderson wrote:
> Aside from the x86 port, there are only two targets that have ifunc
> support in glibc mainline: ppc and arm.  It would be awesomely handy
> if we switch these targets to mirror the sparc lead in passing along
> the dl_hwcap contents as an argument to the resolver, *and* to do it
> in the same release as adding getauxval.  There are some clever things
> we can do at static link time if we know that getauxval corresponds to
> the availability of the ifunc argument.
>
> Dave, dunno if you wanna change the signature of the arg from int to
> unsigned long for 64-bit?  It just seemed prudent to do that here...
>
> I'll present a similar patch for arm shortly...

Like so.  Tested on armv7.  And a ping for the ppc patch?


r~

[-- Attachment #2: d-hwcap-6 --]
[-- Type: text/plain, Size: 404 bytes --]

diff --git a/sysdeps/arm/dl-irel.h b/sysdeps/arm/dl-irel.h
index 5141031..5b1964e 100644
--- a/sysdeps/arm/dl-irel.h
+++ b/sysdeps/arm/dl-irel.h
@@ -29,7 +29,7 @@ static inline Elf32_Addr
 __attribute ((always_inline))
 elf_ifunc_invoke (Elf32_Addr addr)
 {
-  return ((Elf32_Addr (*) (void)) (addr)) ();
+  return ((Elf32_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
 }
 
 static inline void

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ppc] Include hwcap as ifunc argument
  2012-05-24 14:40 ` [ppc] Include hwcap as ifunc argument Richard Henderson
@ 2012-05-24 14:45   ` Joseph S. Myers
  2012-05-24 19:47   ` David Miller
  1 sibling, 0 replies; 8+ messages in thread
From: Joseph S. Myers @ 2012-05-24 14:45 UTC (permalink / raw)
  To: Richard Henderson; +Cc: libc-alpha, libc-ports, Ryan S. Arnold, David Miller

On Thu, 24 May 2012, Richard Henderson wrote:

> On 05/21/2012 09:58 AM, Richard Henderson wrote:
> > Aside from the x86 port, there are only two targets that have ifunc
> > support in glibc mainline: ppc and arm.  It would be awesomely handy
> > if we switch these targets to mirror the sparc lead in passing along
> > the dl_hwcap contents as an argument to the resolver, *and* to do it
> > in the same release as adding getauxval.  There are some clever things
> > we can do at static link time if we know that getauxval corresponds to
> > the availability of the ifunc argument.
> > 
> > Dave, dunno if you wanna change the signature of the arg from int to
> > unsigned long for 64-bit?  It just seemed prudent to do that here...
> > 
> > I'll present a similar patch for arm shortly...
> 
> Like so.  Tested on armv7.  And a ping for the ppc patch?

This ARM patch is OK with the usual copyright dates update.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ppc] Include hwcap as ifunc argument
  2012-05-24 14:40 ` [ppc] Include hwcap as ifunc argument Richard Henderson
  2012-05-24 14:45   ` Joseph S. Myers
@ 2012-05-24 19:47   ` David Miller
  1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2012-05-24 19:47 UTC (permalink / raw)
  To: rth; +Cc: libc-alpha, libc-ports, rsa, joseph

From: Richard Henderson <rth@twiddle.net>
Date: Thu, 24 May 2012 07:40:03 -0700

> On 05/21/2012 09:58 AM, Richard Henderson wrote:
>> Aside from the x86 port, there are only two targets that have ifunc
>> support in glibc mainline: ppc and arm.  It would be awesomely handy
>> if we switch these targets to mirror the sparc lead in passing along
>> the dl_hwcap contents as an argument to the resolver, *and* to do it
>> in the same release as adding getauxval.  There are some clever things
>> we can do at static link time if we know that getauxval corresponds to
>> the availability of the ifunc argument.
>>
>> Dave, dunno if you wanna change the signature of the arg from int to
>> unsigned long for 64-bit?  It just seemed prudent to do that here...
>>
>> I'll present a similar patch for arm shortly...
> 
> Like so.  Tested on armv7.  And a ping for the ppc patch?

You also have to adjust the IFUNC invocations in dl-machine.h, and
potentially elsewhere in the port.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Include hwcap as ifunc argument
       [not found] <4FBA744A.6000702@twiddle.net>
  2012-05-24 14:40 ` [ppc] Include hwcap as ifunc argument Richard Henderson
@ 2012-05-25 17:44 ` Richard Henderson
  2012-06-04 21:22   ` Ryan S. Arnold
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2012-05-25 17:44 UTC (permalink / raw)
  To: libc-alpha, libc-ports

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]

Committed as follows, after re-testing on arm, ppc[32/64].


r~

[-- Attachment #2: z1 --]
[-- Type: text/plain, Size: 1686 bytes --]

        * sysdeps/arm/dl-irel.h (elf_ifunc_invoke): Pass dl_hwcap.
        * sysdeps/arm/dl-machine.h (elf_machine_rel): Use elf_ifunc_invoke.
        (elf_machine_rela): Likewise.



diff --git a/sysdeps/arm/dl-irel.h b/sysdeps/arm/dl-irel.h
index 5141031..5b1964e 100644
--- a/sysdeps/arm/dl-irel.h
+++ b/sysdeps/arm/dl-irel.h
@@ -29,7 +29,7 @@ static inline Elf32_Addr
 __attribute ((always_inline))
 elf_ifunc_invoke (Elf32_Addr addr)
 {
-  return ((Elf32_Addr (*) (void)) (addr)) ();
+  return ((Elf32_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
 }
 
 static inline void
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index 58cf418..8d905e8 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -25,6 +25,7 @@
 #include <sys/param.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-irel.h>
 
 #define CLEAR_CACHE(BEG,END)						\
   INTERNAL_SYSCALL_ARM (cacheflush, , 3, (BEG), (END), 0)
@@ -377,7 +378,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
 	  && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
 	  && __builtin_expect (!skip_ifunc, 1))
-	value = ((Elf32_Addr (*) (void)) value) ();
+	value = elf_ifunc_invoke (value);
 
       switch (r_type)
 	{
@@ -551,7 +552,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
 	  && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
 	  && __builtin_expect (!skip_ifunc, 1))
-	value = ((Elf32_Addr (*) (void)) value) ();
+	value = elf_ifunc_invoke (value);
 
       switch (r_type)
 	{

[-- Attachment #3: z2 --]
[-- Type: text/plain, Size: 3723 bytes --]

        * sysdeps/powerpc/powerpc32/dl-irel.h (elf_ifunc_invoke): Pass
        dl_hwcap to ifunc resolver.
        * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela): Use
        elf_ifunc_invoke.
        * sysdeps/powerpc/powerpc64/dl-irel.h (elf_ifunc_invoke): Pass
        dl_hwcap to ifunc resolver.
        * sysdeps/powerpc/powerpc64/dl-machine.h (resolve_ifunc): Likewise.



diff --git a/sysdeps/powerpc/powerpc32/dl-irel.h b/sysdeps/powerpc/powerpc32/dl-irel.h
index c8e50ee..ebaf44a 100644
--- a/sysdeps/powerpc/powerpc32/dl-irel.h
+++ b/sysdeps/powerpc/powerpc32/dl-irel.h
@@ -1,6 +1,6 @@
 /* Machine-dependent ELF indirect relocation inline functions.
    PowerPC version.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@ static inline Elf32_Addr
 __attribute ((always_inline))
 elf_ifunc_invoke (Elf32_Addr addr)
 {
-  return ((Elf32_Addr (*) (void)) (addr)) ();
+  return ((Elf32_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
 }
 
 static inline void
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index 45868f5..3ae27a4 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  PowerPC version.
-   Copyright (C) 1995-2003, 2005, 2006, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
 
 #include <assert.h>
 #include <dl-tls.h>
+#include <dl-irel.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
@@ -308,7 +309,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
       && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
       && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
       && __builtin_expect (!skip_ifunc, 1))
-    value = ((Elf32_Addr (*) (void)) value) ();
+    value = elf_ifunc_invoke (value);
 
   /* A small amount of code is duplicated here for speed.  In libc,
      more than 90% of the relocs are R_PPC_RELATIVE; in the X11 shared
diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h
index 7270275..ced0f3f 100644
--- a/sysdeps/powerpc/powerpc64/dl-irel.h
+++ b/sysdeps/powerpc/powerpc64/dl-irel.h
@@ -1,6 +1,6 @@
 /* Machine-dependent ELF indirect relocation inline functions.
    PowerPC64 version.
-   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,7 +31,7 @@ static inline Elf64_Addr
 __attribute ((always_inline))
 elf_ifunc_invoke (Elf64_Addr addr)
 {
-  return ((Elf64_Addr (*) (void)) (addr)) ();
+  return ((Elf64_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
 }
 
 static inline void
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index a964a29..7c7d768 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -545,7 +545,7 @@ resolve_ifunc (Elf64_Addr value,
       value = (Elf64_Addr) &opd;
     }
 #endif
-  return ((Elf64_Addr (*) (void)) value) ();
+  return ((Elf64_Addr (*) (unsigned long int)) value) (GLRO(dl_hwcap));
 }
 
 /* Perform the relocation specified by RELOC and SYM (which is fully

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Include hwcap as ifunc argument
  2012-05-25 17:44 ` Richard Henderson
@ 2012-06-04 21:22   ` Ryan S. Arnold
  2012-06-04 22:14     ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan S. Arnold @ 2012-06-04 21:22 UTC (permalink / raw)
  To: Richard Henderson; +Cc: libc-alpha, libc-ports

On Fri, May 25, 2012 at 12:44 PM, Richard Henderson <rth@twiddle.net> wrote:
> Committed as follows, after re-testing on arm, ppc[32/64].

Hi Richard,

Peter Bergner reminded me today that on PowerPC the IFUNC resolver
will most likely/often use the value in AT_PLATFORM rather than
AT_HWCAP to determine which optimized function to use.  I suppose this
would diminish the necessity of passing the hwcap to the ifunc
resolver.

Ryan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Include hwcap as ifunc argument
  2012-06-04 21:22   ` Ryan S. Arnold
@ 2012-06-04 22:14     ` Richard Henderson
  2012-06-08 14:01       ` Andreas Krebbel
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2012-06-04 22:14 UTC (permalink / raw)
  To: Ryan S. Arnold; +Cc: libc-alpha, libc-ports

On 06/04/2012 02:21 PM, Ryan S. Arnold wrote:
> Peter Bergner reminded me today that on PowerPC the IFUNC resolver
> will most likely/often use the value in AT_PLATFORM rather than
> AT_HWCAP to determine which optimized function to use.  I suppose this
> would diminish the necessity of passing the hwcap to the ifunc
> resolver.

It depends on what's being tested, I suppose.

Within glibc itself you've got lots of platform-specific tuning, so 
you may well use AT_PLATFORM more.

Outside glibc, it might just be a test for Altivec or VDX or whatever.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Include hwcap as ifunc argument
  2012-06-04 22:14     ` Richard Henderson
@ 2012-06-08 14:01       ` Andreas Krebbel
  2012-06-08 14:49         ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Krebbel @ 2012-06-08 14:01 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Ryan S. Arnold, libc-alpha, libc-ports

On 06/05/2012 12:14 AM, Richard Henderson wrote:
> On 06/04/2012 02:21 PM, Ryan S. Arnold wrote:
>> Peter Bergner reminded me today that on PowerPC the IFUNC resolver
>> will most likely/often use the value in AT_PLATFORM rather than
>> AT_HWCAP to determine which optimized function to use.  I suppose this
>> would diminish the necessity of passing the hwcap to the ifunc
>> resolver.
> 
> It depends on what's being tested, I suppose.
> 
> Within glibc itself you've got lots of platform-specific tuning, so 
> you may well use AT_PLATFORM more.
> 
> Outside glibc, it might just be a test for Altivec or VDX or whatever.

From a S/390 perspective AT_PLATFORM would also be more helpful. We do not add every new
machine feature to the hwcaps vector so it is not possible to deduce the cpu level just
from the hwcaps vector.

I'm working on the S/390 ifunc support and hope to be able to come up with a patch soon.

Bye,

-Andreas-

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Include hwcap as ifunc argument
  2012-06-08 14:01       ` Andreas Krebbel
@ 2012-06-08 14:49         ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2012-06-08 14:49 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: Ryan S. Arnold, libc-alpha, libc-ports

On 2012-06-08 07:00, Andreas Krebbel wrote:
>From a S/390 perspective AT_PLATFORM would also be more helpful. We do not add every new
> machine feature to the hwcaps vector so it is not possible to deduce the cpu level just
> from the hwcaps vector.

No, but the one important thing in s390's AT_HWCAP is HWCAP_S390_STFLE,
which tells you (without setting up sigill handlers) that you can go ahead
and find out *everything* you want to know via stfle.  More or less exactly
how the x86 port works atm with its cpuid bits.

But again, it depends on what you're trying to test.  Are you looking at
choosing a version based on scheduling, or choosing a version based on
features?

I'd would hope that any multiarch'd version of e.g. feraiseexcept would test
for the ieee-exception-simulation-facility (included in bit 41 of stfle results)
rather than using a strcmp of AT_PLATFORM vs "z109-xx" (or whatever).

Certainly for libatomic I would be most interested in testing for the 
presence of the interlocked-access and compare-and-swap-and-store-2 facilities.
 
> I'm working on the S/390 ifunc support and hope to be able to come up with a patch soon.

Excellent.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-06-08 14:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4FBA744A.6000702@twiddle.net>
2012-05-24 14:40 ` [ppc] Include hwcap as ifunc argument Richard Henderson
2012-05-24 14:45   ` Joseph S. Myers
2012-05-24 19:47   ` David Miller
2012-05-25 17:44 ` Richard Henderson
2012-06-04 21:22   ` Ryan S. Arnold
2012-06-04 22:14     ` Richard Henderson
2012-06-08 14:01       ` Andreas Krebbel
2012-06-08 14:49         ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).