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: [PATCH v2 07/12] elf: Move vDSO setup to rtld (BZ#24967)



On 13/12/2019 09:12, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> index 07d38466e2..6475840117 100644
>> --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> @@ -38,12 +38,9 @@ __gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz)
>>  }
>>  
>>  #ifdef SHARED
>> -# include <dl-vdso.h>
>> -# include <sysdep-vdso.h>
>> -
>>  # define INIT_ARCH()
>>  libc_ifunc (__gettimeofday,
>> -	    (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
>> +	    (GLRO(dl_vdso_gettimeofday)
>>  	    ?: __gettimeofday_vsyscall))
> 
> This IFUNC resolver is still not valid because _rtld_global_ro has a
> relocation dependency.

Afaik with current ld guaranties, .rel{a}.dyn will be sort prior ifunc
so _rtld_global_ro should be reallocated prior the ifunc itself.

> 
> What we should do instead is to patch the vDSO function pointers (and
> pretty much all shared variables, including the page size) into
> libc.so.6 right after loading it (before relocation).  I had hoped to
> post a patch for this, but the prerequisite
> 
>   <https://sourceware.org/ml/libc-alpha/2019-11/msg00977.html>
> 
> has not been reviewed.  It provides _dl_lookup_direct, which we could
> use to get access to this global variables structure very efficiently.

We can go on this way (which is a rather complex solution with might add
even more pitfalls). However another much simple possibility is to make 
gettimeoday and time use normal function that calls the vDSO directly.  
On x86_64 haswell (i7-4790K) I see just 7% increase of latency to by 
using INLINE_VSYSCALL with my patch, which I think it quite acceptable. 



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