This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC: gettimeofday optimization by using IFUNC


On Mon, Mar 11, 2013 at 7:28 AM, Adhemerval Zanella
<azanella@linux.vnet.ibm.com> wrote:
> Ping.
>
> On 03/05/2013 12:49 PM, Adhemerval Zanella wrote:
>> On 03/05/2013 12:06 PM, Richard Henderson wrote:
>>> On 03/05/2013 04:22 AM, Adhemerval Zanella wrote:
>>>> +/* Macro to return vdso_xxx value on IFUNC implementations.
>>>> +   On PPC64 the returned value is actually an OPD entry.  */
>>>> +#if defined(__PPC64__) || defined(__powerpc64__)
>>>> +#define PTR_IFUNC_RET(value)  &value
>>>> +#else
>>>> +#define PTR_IFUNC_RET(value)  value
>>>> +#endif
>>>> +
>>> We are talking about function symbols in C right?  These two expressions are
>>> identical due to function pointer decomposition.
>>>
>>>
>>> r~
>>>
>> Not in this case: without the '&' on PPC64 the vDSO function address will be
>> returned instead of ODP entry and then elf_ifunc_invoke will fail to correct
>> resolve the symbol. On PPC32 this is not need, the vDSO address is returned
>> instead.
>>
>> Here is the disassemble of the IFUNC resolver with my latest patch:
>>
>> Dump of assembler code for function __gettimeofday:
>> => 0x00000fffb7ed7700 <+0>:     nop
>>    0x00000fffb7ed7704 <+4>:     ld      r9,-14952(r2)
>>    0x00000fffb7ed7708 <+8>:     addi    r3,r2,-14952
>>    0x00000fffb7ed770c <+12>:    cmpdi   cr7,r9,0
>>    0x00000fffb7ed7710 <+16>:    bnelr   cr7
>>    0x00000fffb7ed7714 <+20>:    addis   r3,r2,-1
>>    0x00000fffb7ed7718 <+24>:    addi    r3,r3,-5200
>>    0x00000fffb7ed771c <+28>:    blr
>>
>> And here it is the resolver with '#define PTR_IFUNC_RET(value)  value':
>>
>> => 0x00000fffb7ed7700 <+0>:     nop
>>    0x00000fffb7ed7704 <+4>:     ld      r3,-14952(r2)
>>    0x00000fffb7ed7708 <+8>:     cmpdi   cr7,r3,0
>>    0x00000fffb7ed770c <+12>:    bnelr   cr7
>>    0x00000fffb7ed7710 <+16>:    addis   r3,r2,-1
>>    0x00000fffb7ed7714 <+20>:    addi    r3,r3,-5200
>>    0x00000fffb7ed7718 <+24>:    blr
>>
>> The addi instruction will correctly point to ODP entry instead of the vDSO entry.

This is fine with me as long as Richard's objection has been addressed
to his liking.

Ryan S. Arnold


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]