Message ID | 1525975253.28825.227.camel@cavium.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 4194 invoked by alias); 10 May 2018 18:01:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4023 invoked by uid 89); 10 May 2018 18:01:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=100000000, 5.5, 55, H*MI:227 X-HELO: NAM03-DM3-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Steve.Ellcey@cavium.com; Message-ID: <1525975253.28825.227.camel@cavium.com> Subject: [Patch] Use VDSO interface for gettimeofday on aarch64 From: Steve Ellcey <sellcey@cavium.com> Reply-To: sellcey@cavium.com To: libc-alpha <libc-alpha@sourceware.org> Date: Thu, 10 May 2018 11:00:53 -0700 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CO2PR04CA0112.namprd04.prod.outlook.com (2603:10b6:104:7::14) To SN6PR07MB4574.namprd07.prod.outlook.com (2603:10b6:805:5f::18) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4574; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4574; 3:5eKSfC9vW4pYavWp3pkzyV8rSWHD1SzZRz4KGJbnRnOKzxJjl8A42GB7xPPInnWi1WtFZPCJTqHpb/3wzG4+q1OmVSB3gpxw0U/xYJKiD8VKxZ8EfQtnJpugf6c8tClUmw5cvKuvB3ORN6Y9FRahSWU2ymACEAMsR/MMO/bb2nw8us+vpeIMDr9Y1n4Tio1birbY/pkXZQjjH4u/k/gvnOSODZcLIinkjeMB/TH8vGwCtcgNRJWOpd1Aoe72+kd4; 25:I97AEfw49QbRIk8RZooaG/8LNxC9LXlZyIJau12vshA9+zu6d4psqT6cSRCJZ2q/7Yj96vkDQIjLAEwftpz9CKilanVqCl3KxBI8IdIbYJ9D0Q1vRCde6V1aG6q2itsXH8X8nRkI/TCnQAjngTARSx7f7t6DThWwgTxJY9UYgNMMpuFWDbfCS5p9DHjie69vAXK/DVzxIYRbQkxTnHSuJ9ld9HddD1kgp8YzBXjJ6QHNw74xq+W0M8jnfqwaFIwthDjNKkpLiwmUTqEkp0XrMrLkSdTLBuntnvyml44d+u1eL/BjMnoyKwrVXhTHZWkmYxax0QqXWZZYEY6n1vSXnA==; 31:wPNhZSQ04hAQhFWZ+/faC7kz1cFPVKeOsgVIid55pnUjUn63+2h/diMmMJgF6CilyHEznOmnvZPd8zzDyhvFx+gstBp+BIH9isvyM2+KHu0Ul2oTSDJP/LTNoWWoVg2Fb66KASVi+MRUySDUrDHmg4L0j/rDNrI0qOzSt+wnr28E3YuqsrCtLhODgDlRUv6qHMe8xSB9aH9ApA/YKha/K2fbVcyaruwbdcbcZRad70w= X-MS-TrafficTypeDiagnostic: SN6PR07MB4574: X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4574; 20:wUnYjeUFhUP+Pvtupl3Cz7fYq1COuKtX050F/2n0+EKC4uoeougwcpVPuvK2bn1NpEDytkaZE1elU6mui8GVTQW76Chr7WcPXMSJoSZGe0aZmQmcuKJJ3El2XvzVKmOKaCwXyX4o2QLhpMn2I2dXNHx3z8k/gBYm9NbXAqennJ/gppfg6QwGpmsNGu6Aytl0X/jAzh6bUrKD7eqYC57I0zCDr4LMvTwkHU16BAwiCiEGh9Tr7Lwub+E7o005Z6Vb8N2dUTRskQ7YCva6Mdy9ohsChO2zZ8QhJYNNh19rN/ST32PXxH+e4qjQrMeuJH8wQXQtaeSR7+/7drJcw8YTqxIL44zeMLrnIZY+TQt57gn7nrtilP+AVYY/5EwHuL63n37ri0FioZd4IANLUae0jm5dPV9FrD8nQG7ZIe9JJSUdhZuL+TMb8mfz0NlYFyVgIbZyHgZcaOgRfmGnG4LbhzEDM4wG6Vu+DATyHC7VKWOLo+QBO7ToQdjZ4gaUU8qB; 4:T00xEBg4B8F/KzjnGJEoQQj8yXOdhSI28kuPQtiT6bGLUxhQ9Jg8iyAZ5e7ISEAAUSUoZfpBpw+fF+W7kPC26L6TFWWLxerlOBsKdSG6fwzJ9LAHMTrbturzNhmW0hQ4O+Am5lhR2Lj99BkJnq8WTTFD/R368fDpilSjEswe30cpuDFWIS4kCGjeZYJXksRpmxhxjmV9uaeWWTXNDKNTGD6ib3lT/t6mK77GH1J1pBlt5MkmoeozCIe7LZf63cjO2e9c1kwuYsDjg3YyVNeh0Hl1t1vPKf62pCZzhyHhiGLUy/TBhyhTRByh3AnIUF3grMPw0R/bnj5Iu/WGfMPxEBBkgU2z6MWmVo1D3Eg6dks= X-Microsoft-Antispam-PRVS: <SN6PR07MB457435029075518EEBD870F4F5980@SN6PR07MB4574.namprd07.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123560045)(201703131423095)(201703061421075)(201703161042150)(20161123562045)(20161123558120)(6072148)(6042181)(201708071742011); SRVR:SN6PR07MB4574; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4574; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(189003)(199004)(377424004)(50226002)(106356001)(47776003)(23676004)(50466002)(36756003)(53416004)(43066004)(53936002)(52116002)(103116003)(6486002)(2906002)(6916009)(5660300001)(3450700001)(305945005)(2870700001)(105586002)(97736004)(6666003)(5820100001)(69596002)(3846002)(2616005)(476003)(8676002)(26005)(68736007)(8936002)(1857600001)(7736002)(6116002)(72206003)(6306002)(6506007)(81166006)(25786009)(81156014)(498600001)(386003)(486006)(66066001)(956004)(6512007)(16526019)(186003)(99106002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4574; H:sellcey-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjZQUjA3TUI0NTc0OzIzOndvUTNFRlI1MU9nWlI3RlNNN21MWFphUGtj?= =?utf-8?B?ODduQTBIRkg2SWwyK2tnWE5xeUNQQkNQV3BWRW1CTG5qWk5TQ1NqT3YzZFht?= =?utf-8?B?cU5DaHFhVWQ3V0ptdmVJa2tEQVpld21LQy9PS3lJU3ZyUmczTzdIS0txeWU1?= =?utf-8?B?MHU0M0w0UTRreUVadFlydVJQWVJZRWhIZnMyWmdUZTVNYXlKZDcxTitFYUVp?= =?utf-8?B?TlNxMkVrTUZ6ZGhucG94VGN0VUh2SU5VSk40RG1hclZpL080Vmo3N2EycnBx?= =?utf-8?B?QUFpVEJvTWMvaDhGZ1NrS3htYzdFeThyOVg4VkhjczdnS0RZalNIcG5PTnlO?= =?utf-8?B?QTFkaW54NmhKa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Z4pJ2K6gV+bQK+9QujfKGKWz7TQqsxJssNAnQJ3h3GC7jiiG02E/3pKmkw7YFgNogSqkTk7BVoDTIQI4VCwoioubIFsBpOWl0WrR1T3NaGpefw==; 5:wC/zqhpAPz84xlhPzTDPdDCMJ0FTblIvwNDr6Dkg6MzyxMJSwnLFnERbmRM5+HyDz4xHvpYGhAnPPTEDWZSxApIE5KlSVHNHdAyBwujSN9Qbyt2FQ4lrHkmb4F82kAYpl8+BBIirNlH9CbpiE+0xp655SuamNvA7HP5jKFWUZDU=; 24:o1kexDlDrRRJrfqVJRD+xshkWm3ntL2IxcYe054+G0s5MCKWn/3MzMjDYF87tiCXmD9trL6xB8dr9DRL+iYGUy5T4dyCSp7Tbi14s3TlMXk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4574; 7:C5BrojJex/3B62G6tmRb+AjEg9oIXGM7UKR4WftuwWAMTRnt4+KfNzprWTV086QzIVzk5mjg9kwbF6Hy/c23B0aJXkO9N0Mx2CEdWnUN3QYMeTD/2hYYD51zQ2y1SD7xQj9UoajkmiZyfUalU7F2le4s+nXrcbkZWHJX3twGWDPgdMOIk+3mJoL5BLVNxbFeTEr5w8d7O+6wFPGmDywEGLQq6EpUia7FM1eBVPl6WRp7pM0mAmGF8DbkixXpNpG+ X-MS-Office365-Filtering-Correlation-Id: 772fc430-9896-4817-8a96-08d5b69ffb19 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 18:00:56.9103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 772fc430-9896-4817-8a96-08d5b69ffb19 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4574 |
Commit Message
Steve Ellcey
May 10, 2018, 6 p.m. UTC
This is a Aarch64 version of gettimeofday that uses the VDSO interface when it is available. I did a test with 100000000 gettimeofday calls on a T88 and the time went from 7.1 seconds to 5.5 seconds. I also ran the glibc testsuite and I did not get any regressions. OK to checkin? Steve Ellcey sellcey@cavium.com 2018-05-10 Steve Ellcey <sellcey@caviumnetworks.com> * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: New file.
Comments
Hi, Steve Ellcey wrote: > This is a Aarch64 version of gettimeofday that uses the VDSO interface > when it is available. I did a test with 100000000 gettimeofday calls > on a T88 and the time went from 7.1 seconds to 5.5 seconds. I also > ran the glibc testsuite and I did not get any regressions. Yay! [...] > --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c > +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c > @@ -0,0 +1,69 @@ [...] > +/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support > + goes in. See _libc_vdso_platform_setup in > + sysdeps/unix/sysv/linux/aarch64/init-first.c. */ > + > +# undef INIT_ARCH > +# define INIT_ARCH() \ > + PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \ Can this be added as a PREPARE_VERSION_KNOWN? > + void *vdso_gettimeofday = \ > + _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); I was surprised to see LINUX_2.6.39 here, but that's really what the symbol version exported from Linux is called. It was actually introduced in v3.7-rc1~178^2~15. I then suspected it was for consistency with arm, but arm uses LINUX_2.6. Maybe that's just how long it took for the patch to be merged? Not related to your patch, just an issue I was curious about on the way. The rest looks good. With or without the PREPARE_VERSION_KNOWN change mentioned above, Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Thanks.
On 05/10/2018 11:30 PM, Steve Ellcey wrote: > > This is a Aarch64 version of gettimeofday that uses the VDSO interface > when it is available. I did a test with 100000000 gettimeofday calls > on a T88 and the time went from 7.1 seconds to 5.5 seconds. I also > ran the glibc testsuite and I did not get any regressions. > > OK to checkin? Can you please add a benchmark in benchtests that measures this? I think you could walk the ifuncs and compare with the fallback similar to what we do with string functions. Also, do you see an impact of this on any standard benchmarks such as phoronix/openbenchmarking or SPEC? Thanks, Siddhesh > Steve Ellcey > sellcey@cavium.com > > > 2018-05-10 Steve Ellcey <sellcey@caviumnetworks.com> > > * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: New file. > > > diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c > index e69de29..973b6ff 100644 > --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c > +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c > @@ -0,0 +1,69 @@ > +/* Copyright (C) 2018 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 > + <http://www.gnu.org/licenses/>. */ > + > +/* Get the current time of day and timezone information, > + putting it into *tv and *tz. If tz is null, *tz is not filled. > + Returns 0 on success, -1 on errors. */ > + > +#ifdef SHARED > + > +# define __gettimeofday __redirect___gettimeofday > +# include <sys/time.h> > +# undef __gettimeofday > +# define HAVE_VSYSCALL > +# include <dl-vdso.h> > +# include <sysdep-vdso.h> > + > +static int > +__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) > +{ > + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); > +} > + > +/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support > + goes in. See _libc_vdso_platform_setup in > + sysdeps/unix/sysv/linux/aarch64/init-first.c. */ > + > +# undef INIT_ARCH > +# define INIT_ARCH() \ > + PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \ > + void *vdso_gettimeofday = \ > + _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); > + > +libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, > + vdso_gettimeofday ?: (void *) __gettimeofday_syscall) > + > +# undef libc_hidden_def > +# define libc_hidden_def(name) \ > + __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \ > + __gettimeofday_syscall); > + > +#else > + > +# include <sys/time.h> > +# include <sysdep.h> > +int > +__gettimeofday (struct timeval *tv, struct timezone *tz) > +{ > + return INLINE_SYSCALL (gettimeofday, 2, tv, tz); > +} > +#endif > + > +libc_hidden_def (__gettimeofday) > +weak_alias (__gettimeofday, gettimeofday) > +libc_hidden_weak (gettimeofday) >
On Thu, May 10, 2018 at 9:05 PM, Siddhesh Poyarekar <siddhesh@gotplt.org> wrote: > On 05/10/2018 11:30 PM, Steve Ellcey wrote: >> >> >> This is a Aarch64 version of gettimeofday that uses the VDSO interface >> when it is available. I did a test with 100000000 gettimeofday calls >> on a T88 and the time went from 7.1 seconds to 5.5 seconds. I also >> ran the glibc testsuite and I did not get any regressions. >> >> OK to checkin? > > > Can you please add a benchmark in benchtests that measures this? I think > you could walk the ifuncs and compare with the fallback similar to what we > do with string functions. That does not measure the difference here. We were already using the VDSO before; just differently. Before we had a PLT that calls into the libc and would do then an check on the VDSO and then (another) indirect call (to the VDSO). After we just have an PLT (indirect) call into the VDSO directly. Basically saving the check and an extra indirect call (the indirect call can be costly if not predicted correctly). Walking the ifuncs won't benchmark the difference that is gotten here. > > Also, do you see an impact of this on any standard benchmarks such as > phoronix/openbenchmarking or SPEC? You will see the biggest benefit from Apache Bench and running Apache as the web server (maybe any other webserver which calls gettimeofday a lot as you are producing a date for each socket connection). And yes this is considered a standard benchmark when it comes to CDN. Thanks, Andrew > > Thanks, > Siddhesh > > >> Steve Ellcey >> sellcey@cavium.com >> >> >> 2018-05-10 Steve Ellcey <sellcey@caviumnetworks.com> >> >> * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: New file. >> >> >> diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c >> b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c >> index e69de29..973b6ff 100644 >> --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c >> +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c >> @@ -0,0 +1,69 @@ >> +/* Copyright (C) 2018 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 >> + <http://www.gnu.org/licenses/>. */ >> + >> +/* Get the current time of day and timezone information, >> + putting it into *tv and *tz. If tz is null, *tz is not filled. >> + Returns 0 on success, -1 on errors. */ >> + >> +#ifdef SHARED >> + >> +# define __gettimeofday __redirect___gettimeofday >> +# include <sys/time.h> >> +# undef __gettimeofday >> +# define HAVE_VSYSCALL >> +# include <dl-vdso.h> >> +# include <sysdep-vdso.h> >> + >> +static int >> +__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) >> +{ >> + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); >> +} >> + >> +/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support >> + goes in. See _libc_vdso_platform_setup in >> + sysdeps/unix/sysv/linux/aarch64/init-first.c. */ >> + >> +# undef INIT_ARCH >> +# define INIT_ARCH() \ >> + PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \ >> + void *vdso_gettimeofday = \ >> + _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); >> + >> +libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, >> + vdso_gettimeofday ?: (void *) __gettimeofday_syscall) >> + >> +# undef libc_hidden_def >> +# define libc_hidden_def(name) \ >> + __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \ >> + __gettimeofday_syscall); >> + >> +#else >> + >> +# include <sys/time.h> >> +# include <sysdep.h> >> +int >> +__gettimeofday (struct timeval *tv, struct timezone *tz) >> +{ >> + return INLINE_SYSCALL (gettimeofday, 2, tv, tz); >> +} >> +#endif >> + >> +libc_hidden_def (__gettimeofday) >> +weak_alias (__gettimeofday, gettimeofday) >> +libc_hidden_weak (gettimeofday) >> >
On 05/11/2018 10:13 AM, Andrew Pinski wrote: > That does not measure the difference here. We were already using the > VDSO before; just differently. Before we had a PLT that calls into > the libc and would do then an check on the VDSO and then (another) > indirect call (to the VDSO). After we just have an PLT (indirect) > call into the VDSO directly. Basically saving the check and an extra > indirect call (the indirect call can be costly if not predicted > correctly). Ah OK, got it. > Walking the ifuncs won't benchmark the difference that is gotten here. > > You will see the biggest benefit from Apache Bench and running Apache > as the web server (maybe any other webserver which calls gettimeofday > a lot as you are producing a date for each socket connection). And > yes this is considered a standard benchmark when it comes to CDN. OK, thanks. Looks good to me too then. The benchmark would still be nice to have (let me know if y'all don't intend to write it so that I can put it in my list of things to do), but not a blocker for this patch. Siddhesh
On 10/05/18 19:00, Steve Ellcey wrote: > > This is a Aarch64 version of gettimeofday that uses the VDSO interface > when it is available. I did a test with 100000000 gettimeofday calls > on a T88 and the time went from 7.1 seconds to 5.5 seconds. I also > ran the glibc testsuite and I did not get any regressions. > > OK to checkin? > > Steve Ellcey > sellcey@cavium.com > > > 2018-05-10 Steve Ellcey <sellcey@caviumnetworks.com> > > * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: New file. thanks, it looks reasonable approach, but the commit message should be fixed to indicate that this is a new VDSO mechanism (using ifunc) and why the old mechanism is still needed. please test with LD_BIND_NOW=1 too (this applies whenever ifuncs are involved, since they may behave differently when resolved lazily vs at load time and i don't see such test in glibc currently, a simple helloworld.c with gettimeofday usage is enough i think, it would be even better to add something like that to the test system) > + > +#ifdef SHARED > + note that static linked binaries do a real syscall now, this should be solved since users who really care about performance want to use static linked binaries, this is https://sourceware.org/bugzilla/show_bug.cgi?id=19767 (i think if !SHARED then global __vdso pointers can be initialized while the process is still single threaded using custom elf symbol lookup code and then current VSYSCALL mechanism should work) > +# define __gettimeofday __redirect___gettimeofday > +# include <sys/time.h> > +# undef __gettimeofday is this necessary? can we write out the declarations here? such macro redirection looks fragile to me. > +# define HAVE_VSYSCALL > +# include <dl-vdso.h> > +# include <sysdep-vdso.h> > + > +static int > +__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) > +{ > + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); > +} > + i'd call it __gettimeofday_vsyscall if you use VSYSCALL. is there a way _dl_vdso_vsym fails in the ifunc resolver but succeeds in VDSO_SETUP during _init? are there cases when __gettimeofday_syscall is called directly instead of via ifunc dispatch? (e.g. libc internal calls) vdso mechanisms are getting confusing, adding new mechanism is ok, but then either old ones should be cleaned up or comments added there clarifying which mechanism is used when (so the questions above are easy to answer). > +/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support > + goes in. See _libc_vdso_platform_setup in > + sysdeps/unix/sysv/linux/aarch64/init-first.c. */ > + > +# undef INIT_ARCH > +# define INIT_ARCH() \ > + PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \ > + void *vdso_gettimeofday = \ > + _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); > + > +libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, > + vdso_gettimeofday ?: (void *) __gettimeofday_syscall) > + this may do a vdso symbol look up whenever a dso is loaded that references gettimeofday (or when it's called in case of lazy binding) we could do the lookup only once at early init and use that in the ifunc resolver, but currently VDSO_SETUP runs after libc.so is relocated so i don't have a better idea. note that clock_gettime could use the same mechanism on aarch64 if we introduced a new abi symbol: __clock_gettime_noerrno and the public time.h had something like #define clock_gettime(id,ts) \ ( __id <= 6U \ ? __clock_gettime_noerrno (__id, __ts) \ : clock_gettime (__id, __ts) ) there might be better ways, not sure if glibc is happy with such hacks in public headers, but it's worth considering if you see significant performance difference. > +# undef libc_hidden_def > +# define libc_hidden_def(name) \ > + __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \ > + __gettimeofday_syscall); i'd use a new macro with different name here, e.g. #define hidden_vsyscall(name) __hidden_ver1 (name##_syscall,...) (or just write out explicitly what you want for SHARED vs !SHARED case separately.) does this mean internally in libc.so gettimeofday uses the existing VSYSCALL mechanism, but e.g. another dso like libpthread.so goes via ifunc? > + > +#else > + > +# include <sys/time.h> > +# include <sysdep.h> > +int > +__gettimeofday (struct timeval *tv, struct timezone *tz) > +{ > + return INLINE_SYSCALL (gettimeofday, 2, tv, tz); > +} > +#endif > + > +libc_hidden_def (__gettimeofday) > +weak_alias (__gettimeofday, gettimeofday) > +libc_hidden_weak (gettimeofday) >
diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index e69de29..973b6ff 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2018 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 +   <http://www.gnu.org/licenses/>.  */ + +/* Get the current time of day and timezone information, +   putting it into *tv and *tz.  If tz is null, *tz is not filled. +   Returns 0 on success, -1 on errors.  */ + +#ifdef SHARED + +# define __gettimeofday __redirect___gettimeofday +# include <sys/time.h> +# undef __gettimeofday +# define HAVE_VSYSCALL +# include <dl-vdso.h> +# include <sysdep-vdso.h> + +static int +__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) +{ +  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); +} + +/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support +   goes in.  See _libc_vdso_platform_setup in +   sysdeps/unix/sysv/linux/aarch64/init-first.c.  */ + +# undef INIT_ARCH +# define INIT_ARCH() \ +    PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \ +    void *vdso_gettimeofday = \ +      _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); + +libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, +                    vdso_gettimeofday ?: (void *) __gettimeofday_syscall) + +# undef libc_hidden_def +# define libc_hidden_def(name)                               \ +  __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday,  \ +               __gettimeofday_syscall); + +#else + +# include <sys/time.h> +# include <sysdep.h> +int +__gettimeofday (struct timeval *tv, struct timezone *tz) +{ +  return INLINE_SYSCALL (gettimeofday, 2, tv, tz); +} +#endif + +libc_hidden_def (__gettimeofday) +weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday)