From: Nathan Lynch <Nathan_Lynch@codesourcery.com>
To: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Cc: "GNU C. Library" <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2] Add x86 32 bit vDSO time function support
Date: Thu, 09 Oct 2014 20:50:00 -0000 [thread overview]
Message-ID: <5436F50C.9070002@codesourcery.com> (raw)
In-Reply-To: <5436D48C.2090509@linux.vnet.ibm.com>
On 10/09/2014 01:31 PM, Adhemerval Zanella wrote:
> diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
> new file mode 100644
> index 0000000..dc3b1ba
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/i386/init-first.c
> @@ -0,0 +1,52 @@
> +/* Initialization code run first thing by the ELF startup code. Linux/i386.
> + Copyright (C) 2014 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/>. */
> +
> +#ifdef SHARED
> +# include <time.h>
> +# include <sysdep.h>
> +# include <dl-vdso.h>
> +# include <libc-vdso.h>
> +
> +long int (*__vdso_clock_gettime) (clockid_t, struct timespec *)
> + __attribute__ ((nocommon));
> +libc_hidden_proto (__vdso_clock_gettime)
> +libc_hidden_data_def (__vdso_clock_gettime)
> +
> +static long int
> +clock_gettime_syscall (clockid_t id, struct timespec *tp)
> +{
> + INTERNAL_SYSCALL_DECL (err);
> + return INTERNAL_SYSCALL (clock_gettime, err, 2, id, tp);
> +}
> +
> +static inline void
> +__vdso_platform_setup (void)
> +{
> + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
Perhaps:
PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
(here and several other places)
> +
> + void *p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
> + if (p == NULL)
> + p = clock_gettime_syscall;
> + PTR_MANGLE (p);
> + __vdso_clock_gettime = p;
> +}
> +
> +# define VDSO_SETUP __vdso_platform_setup
> +#endif
> +
> +#include <csu/init-first.c>
[...]
> diff --git a/sysdeps/unix/sysv/linux/x86/clock_gettime.c b/sysdeps/unix/sysv/linux/x86/clock_gettime.c
> new file mode 100644
> index 0000000..2547a8c
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/x86/clock_gettime.c
> @@ -0,0 +1,38 @@
> +/* Get the current value of a clock. Linux/x86 version.
> + Copyright (C) 2014 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/>. */
> +
> +#include <libc-vdso.h>
> +
> +#ifdef SHARED
> +# define SYSCALL_GETTIME(id, tp) \
> + ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
> + long int v_ret; \
> + PTR_DEMANGLE (f); \
> + v_ret = (*f) (id, tp); \
> + if (INTERNAL_SYSCALL_ERROR_P (v_ret, )) { \
> + __set_errno (INTERNAL_SYSCALL_ERRNO (v_ret, )); \
> + v_ret = -1; \
> + } \
> + v_ret; })
Does introducing the dispatch through function pointer here cause a
measurable performance regression on i386 kernels which lack the VDSO?
If so, is that a concern?
When I've tried this approach on ARM, it appears to do so (around 5%
slowdown).
> +# define INTERNAL_GETTIME(id, tp) \
> + ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
> + PTR_DEMANGLE (f); \
> + (*f) (id, tp); })
> +#endif
I'm probably missing something, but I am failing to see the need for an
INTERNAL_GETTIME definition in
sysdeps/unix/sysv/linux/x86/clock_gettime.c. I know this patch is
merely moving existing code, but sysdeps/unix/sysv/linux/clock_gettime.c
does not use INTERNAL_GETTIME, and neither does
sysdeps/unix/clock_gettime.c.
INTERNAL_GETTIME is needed for timespec_get, but I am not seeing the
need to duplicate it for clock_gettime.
next prev parent reply other threads:[~2014-10-09 20:50 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-09 18:31 Adhemerval Zanella
2014-10-09 20:50 ` Nathan Lynch [this message]
2014-11-03 20:30 ` Adhemerval Zanella
2014-11-03 21:42 ` Adhemerval Zanella
2014-11-03 23:51 ` Nathan Lynch
2014-11-05 12:51 ` Adhemerval Zanella
2014-11-05 16:22 ` Nathan Lynch
2014-11-14 19:19 ` Adhemerval Zanella
2014-11-27 17:38 ` Adhemerval Zanella
-- strict thread matches above, loose matches on Subject: below --
2014-11-19 7:53 Stefani Seibold
2014-06-27 21:21 Adhemerval Zanella
2014-06-27 21:58 ` Roland McGrath
2014-06-29 15:57 ` Adhemerval Zanella
2014-07-07 18:01 ` Adhemerval Zanella
2014-07-09 20:02 ` Roland McGrath
2014-07-10 14:33 ` Adhemerval Zanella
2014-07-22 17:32 ` Adhemerval Zanella
2014-07-23 0:40 ` Allan McRae
2014-07-23 13:56 ` Adhemerval Zanella
2014-09-10 14:20 ` Adhemerval Zanella
2014-09-22 15:01 ` Adhemerval Zanella
2014-10-07 6:57 ` Stefani Seibold
2014-10-08 21:56 ` Roland McGrath
2014-10-08 22:02 ` Adhemerval Zanella
2014-10-08 22:15 ` Roland McGrath
2014-10-08 22:31 ` Adhemerval Zanella
2014-08-02 16:48 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5436F50C.9070002@codesourcery.com \
--to=nathan_lynch@codesourcery.com \
--cc=azanella@linux.vnet.ibm.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).