[PATCH] Enable VDSO for static linking on s390
Stefan Liebler
stli@linux.ibm.com
Mon Jan 7 14:32:00 GMT 2019
Hi Rafael,
sorry for the delay. I'm just returned from vacation.
Starting with your previous message, I saw the patch.
But if I look at "Re: [PATCH] Enable VDSO for static linking on s390"
(https://www.sourceware.org/ml/libc-alpha/2018-12/msg00757.html) I can't
see it.
Anyway on s390 the vdso is currently only mapped for dynamically linked
elf binaries! See <kernel-src>/arch/s390/kernel/vdso.c:
/*
* This is called from binfmt_elf, we create the special vma for the
* vDSO and insert it into the mm struct tree
*/
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
unsigned long vdso_pages;
unsigned long vdso_base;
int rc;
if (!vdso_enabled)
return 0;
/*
* Only map the vdso for dynamically linked elf binaries.
*/
if (!uses_interp)
return 0;
...
What is your motivation to enable vdso for static binaries?
Do you have a special workload in mind?
Bye.
Stefan
On 12/26/2018 05:41 PM, Rafael Avila de Espindola wrote:
> Hi Stefan,
>
> Have you had a change to try the patch?
>
> Thanks,
> Rafael
>
> "Rafael Avila de Espindola" <rafael@espindo.la> writes:
>
>> "Stefan Liebler" <stli@linux.ibm.com> writes:
>>
>>> Hi Rafael,
>>>
>>> can you please resend the patch?
>>
>> Attached.
>>
>>> But I have a question: Do I need a special kernel parameter / configuration?
>>
>> I don't think so, but I don't know if there is something special on s390x.
>>
>>> When I run it on Intel, I recognize that there is a vdso mapped and
>>> AT_SYSINFO_EHDR contains the address.
>>
>> That was already working. What was missing is just glibc using the
>> loaded vdso.
>>
>> What I have been using for testing is running the following program with
>> strace:
>>
>> #include <time.h>
>> #include <stdio.h>
>> int main() {
>> struct timespec ts;
>> clock_gettime(CLOCK_REALTIME, &ts);
>> printf("%ld.%09ld\n", ts.tv_sec, ts.tv_nsec);
>> return 0;
>> }
>>
>> My expectation is
>>
>> * If built as shared, no syscall for clock_realtime.
>> * If built as static with glibc master, there will be a syscall.
>> * The patch avoids the syscall.
>>
>> Cheers,
>> Rafael
>>
>>
>> From ffe4dc79ffd5ffef09a1275208f56ec5686c74a1 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?=
>> <rafael@espindo.la>
>> Date: Thu, 13 Dec 2018 19:25:34 -0800
>> Subject: [PATCH] Enable VDSO for static linking on s390
>>
>> I don't have access to a s390, so I have not been able to test this.
>> ---
>> sysdeps/unix/sysv/linux/s390/init-first.c | 8 +++-----
>> sysdeps/unix/sysv/linux/s390/libc-vdso.h | 3 ---
>> sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h | 3 +++
>> sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 3 +++
>> 4 files changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
>> index 3a862309bf..10f47ef346 100644
>> --- a/sysdeps/unix/sysv/linux/s390/init-first.c
>> +++ b/sysdeps/unix/sysv/linux/s390/init-first.c
>> @@ -16,9 +16,8 @@
>> License along with the GNU C Library; if not, see
>> <http://www.gnu.org/licenses/>. */
>>
>> -#ifdef SHARED
>> -# include <dl-vdso.h>
>> -# include <libc-vdso.h>
>> +#include <dl-vdso.h>
>> +#include <libc-vdso.h>
>>
>> long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
>> attribute_hidden;
>> @@ -54,7 +53,6 @@ _libc_vdso_platform_setup (void)
>> VDSO_SYMBOL (getcpu) = p;
>> }
>>
>> -# define VDSO_SETUP _libc_vdso_platform_setup
>> -#endif
>> +#define VDSO_SETUP _libc_vdso_platform_setup
>>
>> #include <csu/init-first.c>
>> diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
>> index 664bd15f3d..0d4ecb39a8 100644
>> --- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
>> +++ b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
>> @@ -20,8 +20,6 @@
>> #ifndef _LIBC_VDSO_H
>> #define _LIBC_VDSO_H
>>
>> -#ifdef SHARED
>> -
>> #include <sysdep-vdso.h>
>>
>> extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
>> @@ -33,6 +31,5 @@ extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
>>
>> extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
>> attribute_hidden;
>> -#endif
>>
>> #endif /* _LIBC_VDSO_H */
>> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
>> index 0d683a5bcb..cebd4cbfad 100644
>> --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
>> @@ -19,6 +19,9 @@
>> #ifndef _LINUX_S390_SYSDEP_H
>> #define _LINUX_S390_SYSDEP_H
>>
>> +/* Always enable vsyscalls on s390-32. */
>> +#define ALWAYS_USE_VSYSCALL 1
>> +
>> #include <sysdeps/s390/s390-32/sysdep.h>
>> #include <sysdeps/unix/sysdep.h>
>> #include <sysdeps/unix/sysv/linux/sysdep.h>
>> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
>> index 0414fc5f2c..348f1afb58 100644
>> --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
>> @@ -20,6 +20,9 @@
>> #ifndef _LINUX_S390_SYSDEP_H
>> #define _LINUX_S390_SYSDEP_H
>>
>> +/* Always enable vsyscalls on s390-64. */
>> +#define ALWAYS_USE_VSYSCALL 1
>> +
>> #include <sysdeps/s390/s390-64/sysdep.h>
>> #include <sysdeps/unix/sysdep.h>
>> #include <sysdeps/unix/sysv/linux/sysdep.h>
>> --
>> 2.19.2
>
More information about the Libc-alpha
mailing list