diff mbox series

[1/3] LoongArch: Add vdso support for gettimeofday.

Message ID 20220728073009.2588790-2-caiyinyu@loongson.cn
State New
Headers show
Series GLIBC LOONGARCH PATCHES | expand

Commit Message

caiyinyu July 28, 2022, 7:30 a.m. UTC
---
 .../unix/sysv/linux/loongarch/gettimeofday.c  | 22 +++++++++++++++++++
 sysdeps/unix/sysv/linux/loongarch/sysdep.h    |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/gettimeofday.c

Comments

Adhemerval Zanella Netto July 28, 2022, 12:58 p.m. UTC | #1
I think we should postpone it to 2.37, it is an optimization and we
can backport it if required.

The patch looks ok though.

On 28/07/22 04:30, caiyinyu wrote:
> ---
>  .../unix/sysv/linux/loongarch/gettimeofday.c  | 22 +++++++++++++++++++
>  sysdeps/unix/sysv/linux/loongarch/sysdep.h    |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
> 
> diff --git a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
> new file mode 100644
> index 0000000000..ee35a08650
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
> @@ -0,0 +1,22 @@
> +/* gettimeofday -- Get the current time of day.
> +   Copyright (C) 2022 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
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +
> +#define USE_IFUNC_GETTIMEOFDAY
> +#include <sysdeps/unix/sysv/linux/gettimeofday.c>
> diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
> index c586df819c..306e0af3a3 100644
> --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
> @@ -116,6 +116,7 @@
>  /* List of system calls which are supported as vsyscalls.  */
>  #define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
>  #define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
>  #define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
>  
>  #define HAVE_CLONE3_WRAPPER 1
Carlos O'Donell July 29, 2022, 3:10 p.m. UTC | #2
On 7/28/22 08:58, Adhemerval Zanella Netto wrote:
> I think we should postpone it to 2.37, it is an optimization and we
> can backport it if required.

Agreed, lets wait until after the release for this.

vDSO additions can be done at any point in time after the release and backported.
 
> The patch looks ok though.
> 
> On 28/07/22 04:30, caiyinyu wrote:
>> ---
>>  .../unix/sysv/linux/loongarch/gettimeofday.c  | 22 +++++++++++++++++++
>>  sysdeps/unix/sysv/linux/loongarch/sysdep.h    |  1 +
>>  2 files changed, 23 insertions(+)
>>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>> new file mode 100644
>> index 0000000000..ee35a08650
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>> @@ -0,0 +1,22 @@
>> +/* gettimeofday -- Get the current time of day.
>> +   Copyright (C) 2022 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
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library.  If not, see
>> +   <https://www.gnu.org/licenses/>.  */
>> +
>> +
>> +#define USE_IFUNC_GETTIMEOFDAY
>> +#include <sysdeps/unix/sysv/linux/gettimeofday.c>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>> index c586df819c..306e0af3a3 100644
>> --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>> @@ -116,6 +116,7 @@
>>  /* List of system calls which are supported as vsyscalls.  */
>>  #define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
>>  #define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
>> +#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
>>  #define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
>>  
>>  #define HAVE_CLONE3_WRAPPER 1
>
caiyinyu Aug. 3, 2022, 3:12 a.m. UTC | #3
在 2022/7/29 下午11:10, Carlos O'Donell 写道:
> On 7/28/22 08:58, Adhemerval Zanella Netto wrote:
>> I think we should postpone it to 2.37, it is an optimization and we
>> can backport it if required.
> Agreed, lets wait until after the release for this.
>
> vDSO additions can be done at any point in time after the release and backported.


The new vdsotest results with this patch are much better on kernel 5.19 
rc1 (old results[1]):

clock-gettime-monotonic: syscall: 228 nsec/call
clock-gettime-monotonic:    libc: 30 nsec/call
clock-gettime-monotonic:    vdso: 29 nsec/call
clock-getres-monotonic: syscall: 196 nsec/call
clock-getres-monotonic:    libc: 9 nsec/call
clock-getres-monotonic:    vdso: 5 nsec/call
clock-gettime-monotonic-coarse: syscall: 217 nsec/call
clock-gettime-monotonic-coarse:    libc: 25 nsec/call
clock-gettime-monotonic-coarse:    vdso: 24 nsec/call
clock-getres-monotonic-coarse: syscall: 198 nsec/call
clock-getres-monotonic-coarse:    libc: 8 nsec/call
clock-getres-monotonic-coarse:    vdso: 4 nsec/call
clock-gettime-monotonic-raw: syscall: 226 nsec/call
clock-gettime-monotonic-raw:    libc: 30 nsec/call
clock-gettime-monotonic-raw:    vdso: 29 nsec/call
clock-getres-monotonic-raw: syscall: 196 nsec/call
clock-getres-monotonic-raw:    libc: 9 nsec/call
clock-getres-monotonic-raw:    vdso: 5 nsec/call
clock-gettime-tai: syscall: 230 nsec/call
clock-gettime-tai:    libc: 30 nsec/call
clock-gettime-tai:    vdso: 29 nsec/call
clock-getres-tai: syscall: 196 nsec/call
clock-getres-tai:    libc: 9 nsec/call
clock-getres-tai:    vdso: 5 nsec/call
clock-gettime-boottime: syscall: 228 nsec/call
clock-gettime-boottime:    libc: 30 nsec/call
clock-gettime-boottime:    vdso: 29 nsec/call
clock-getres-boottime: syscall: 196 nsec/call
clock-getres-boottime:    libc: 9 nsec/call
clock-getres-boottime:    vdso: 5 nsec/call
clock-gettime-realtime: syscall: 227 nsec/call
clock-gettime-realtime:    libc: 30 nsec/call
clock-gettime-realtime:    vdso: 29 nsec/call
clock-getres-realtime: syscall: 196 nsec/call
clock-getres-realtime:    libc: 9 nsec/call
clock-getres-realtime:    vdso: 5 nsec/call
clock-gettime-realtime-coarse: syscall: 225 nsec/call
clock-gettime-realtime-coarse:    libc: 25 nsec/call
clock-gettime-realtime-coarse:    vdso: 24 nsec/call
clock-getres-realtime-coarse: syscall: 198 nsec/call
clock-getres-realtime-coarse:    libc: 8 nsec/call
clock-getres-realtime-coarse:    vdso: 4 nsec/call
getcpu: syscall: 176 nsec/call
getcpu:    libc: 8 nsec/call
getcpu:    vdso: 6 nsec/call
gettimeofday: syscall: 213 nsec/call
gettimeofday:    libc: 29 nsec/call
gettimeofday:    vdso: 29 nsec/call


[1]: on kernel 5.18

clock-gettime-monotonic: syscall: 228 nsec/call
clock-gettime-monotonic:    libc: 243 nsec/call
clock-gettime-monotonic:    vdso: 239 nsec/call
clock-getres-monotonic: syscall: 196 nsec/call
clock-getres-monotonic:    libc: 8 nsec/call
clock-getres-monotonic:    vdso: 5 nsec/call
clock-gettime-monotonic-coarse: syscall: 218 nsec/call
clock-gettime-monotonic-coarse:    libc: 25 nsec/call
clock-gettime-monotonic-coarse:    vdso: 24 nsec/call
clock-getres-monotonic-coarse: syscall: 198 nsec/call
clock-getres-monotonic-coarse:    libc: 8 nsec/call
clock-getres-monotonic-coarse:    vdso: 4 nsec/call
clock-gettime-monotonic-raw: syscall: 228 nsec/call
clock-gettime-monotonic-raw:    libc: 243 nsec/call
clock-gettime-monotonic-raw:    vdso: 240 nsec/call
clock-getres-monotonic-raw: syscall: 197 nsec/call
clock-getres-monotonic-raw:    libc: 8 nsec/call
clock-getres-monotonic-raw:    vdso: 4 nsec/call
clock-gettime-tai: syscall: 231 nsec/call
clock-gettime-tai:    libc: 246 nsec/call
clock-gettime-tai:    vdso: 242 nsec/call
clock-getres-tai: syscall: 197 nsec/call
clock-getres-tai:    libc: 8 nsec/call
clock-getres-tai:    vdso: 4 nsec/call
clock-gettime-boottime: syscall: 229 nsec/call
clock-gettime-boottime:    libc: 243 nsec/call
clock-gettime-boottime:    vdso: 240 nsec/call
clock-getres-boottime: syscall: 196 nsec/call
clock-getres-boottime:    libc: 8 nsec/call
clock-getres-boottime:    vdso: 4 nsec/call
clock-gettime-realtime: syscall: 228 nsec/call
clock-gettime-realtime:    libc: 242 nsec/call
clock-gettime-realtime:    vdso: 239 nsec/call
clock-getres-realtime: syscall: 197 nsec/call
clock-getres-realtime:    libc: 8 nsec/call
clock-getres-realtime:    vdso: 5 nsec/call
clock-gettime-realtime-coarse: syscall: 227 nsec/call
clock-gettime-realtime-coarse:    libc: 25 nsec/call
clock-gettime-realtime-coarse:    vdso: 24 nsec/call
clock-getres-realtime-coarse: syscall: 198 nsec/call
clock-getres-realtime-coarse:    libc: 7 nsec/call
clock-getres-realtime-coarse:    vdso: 4 nsec/call
getcpu: syscall: 178 nsec/call
getcpu:    libc: 179 nsec/call
getcpu:    vdso: not tested
Note: vDSO version of getcpu not found
gettimeofday: syscall: 215 nsec/call
gettimeofday:    libc: 226 nsec/call
gettimeofday:    vdso: 226 nsec/call


>   
>> The patch looks ok though.
>>
>> On 28/07/22 04:30, caiyinyu wrote:
>>> ---
>>>   .../unix/sysv/linux/loongarch/gettimeofday.c  | 22 +++++++++++++++++++
>>>   sysdeps/unix/sysv/linux/loongarch/sysdep.h    |  1 +
>>>   2 files changed, 23 insertions(+)
>>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>>> new file mode 100644
>>> index 0000000000..ee35a08650
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
>>> @@ -0,0 +1,22 @@
>>> +/* gettimeofday -- Get the current time of day.
>>> +   Copyright (C) 2022 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
>>> +   modify it under the terms of the GNU Lesser General Public
>>> +   License as published by the Free Software Foundation; either
>>> +   version 2.1 of the License, or (at your option) any later version.
>>> +
>>> +   The GNU C Library is distributed in the hope that it will be useful,
>>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> +   Lesser General Public License for more details.
>>> +
>>> +   You should have received a copy of the GNU Lesser General Public
>>> +   License along with the GNU C Library.  If not, see
>>> +   <https://www.gnu.org/licenses/>.  */
>>> +
>>> +
>>> +#define USE_IFUNC_GETTIMEOFDAY
>>> +#include <sysdeps/unix/sysv/linux/gettimeofday.c>
>>> diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>>> index c586df819c..306e0af3a3 100644
>>> --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
>>> @@ -116,6 +116,7 @@
>>>   /* List of system calls which are supported as vsyscalls.  */
>>>   #define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
>>>   #define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
>>> +#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
>>>   #define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
>>>   
>>>   #define HAVE_CLONE3_WRAPPER 1
>
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
new file mode 100644
index 0000000000..ee35a08650
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c
@@ -0,0 +1,22 @@ 
+/* gettimeofday -- Get the current time of day.
+   Copyright (C) 2022 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+
+#define USE_IFUNC_GETTIMEOFDAY
+#include <sysdeps/unix/sysv/linux/gettimeofday.c>
diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
index c586df819c..306e0af3a3 100644
--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
@@ -116,6 +116,7 @@ 
 /* List of system calls which are supported as vsyscalls.  */
 #define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
 #define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
 #define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
 
 #define HAVE_CLONE3_WRAPPER 1