From: Carlos O'Donell <codonell@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Carlos O'Donell <carlos@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
Joseph Myers <joseph@codesourcery.com>,
Szabolcs Nagy <szabolcs.nagy@arm.com>,
libc-alpha@sourceware.org, Thomas Gleixner <tglx@linutronix.de>,
Ben Maurer <bmaurer@fb.com>,
Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Boqun Feng <boqun.feng@gmail.com>,
Will Deacon <will.deacon@arm.com>,
Dave Watson <davejwatson@fb.com>, Paul Turner <pjt@google.com>,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org
Subject: Re: [PATCH 2/4] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux
Date: Fri, 22 Mar 2019 20:14:00 -0000 [thread overview]
Message-ID: <fc431a95-789a-6c02-13d0-d0d01916ee99@redhat.com> (raw)
In-Reply-To: <20190212194253.1951-3-mathieu.desnoyers@efficios.com>
On 2/12/19 2:42 PM, Mathieu Desnoyers wrote:
> When available, use the cpu_id field from __rseq_abi on Linux to
> implement sched_getcpu(). Fall-back on the vgetcpu vDSO if unavailable.
>
> Benchmarks:
>
> x86-64: Intel E5-2630 v3@2.40GHz, 16-core, hyperthreading
This patch looks good to me for master, but is blocked on patch 1/4
being reworked.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> glibc sched_getcpu(): 13.7 ns (baseline)
> glibc sched_getcpu() using rseq: 2.5 ns (speedup: 5.5x)
> inline load cpuid from __rseq_abi TLS: 0.8 ns (speedup: 17.1x)
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> CC: Carlos O'Donell <carlos@redhat.com>
> CC: Florian Weimer <fweimer@redhat.com>
> CC: Joseph Myers <joseph@codesourcery.com>
> CC: Szabolcs Nagy <szabolcs.nagy@arm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ben Maurer <bmaurer@fb.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> CC: Boqun Feng <boqun.feng@gmail.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Dave Watson <davejwatson@fb.com>
> CC: Paul Turner <pjt@google.com>
> CC: libc-alpha@sourceware.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-api@vger.kernel.org
> ---
> sysdeps/unix/sysv/linux/sched_getcpu.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c
> index fb0d317f83..8bfb03778b 100644
> --- a/sysdeps/unix/sysv/linux/sched_getcpu.c
> +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c
> @@ -24,8 +24,8 @@
> #endif
> #include <sysdep-vdso.h>
>
> -int
> -sched_getcpu (void)
> +static int
> +vsyscall_sched_getcpu (void)
OK.
> {
> #ifdef __NR_getcpu
> unsigned int cpu;
> @@ -37,3 +37,24 @@ sched_getcpu (void)
> return -1;
> #endif
> }
> +
> +#ifdef __NR_rseq
> +#include <linux/rseq.h>
> +
> +extern __attribute__ ((tls_model ("initial-exec")))
> +__thread volatile struct rseq __rseq_abi;
OK.
> +
> +int
> +sched_getcpu (void)
> +{
> + int cpu_id = __rseq_abi.cpu_id;
> +
> + return cpu_id >= 0 ? cpu_id : vsyscall_sched_getcpu ();
OK. Impressive :-)
> +}
> +#else
> +int
> +sched_getcpu (void)
> +{
> + return vsyscall_sched_getcpu ();
OK.
> +}
> +#endif
>
--
Cheers,
Carlos.
next prev parent reply other threads:[~2019-03-22 20:14 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 19:43 [PATCH 0/4] Restartable Sequences support for glibc 2.30 Mathieu Desnoyers
2019-02-12 19:43 ` [PATCH 1/4] glibc: Perform rseq(2) registration at C startup and thread creation (v7) Mathieu Desnoyers
2019-03-22 20:09 ` Carlos O'Donell
2019-03-25 15:54 ` Mathieu Desnoyers
2019-03-27 9:16 ` Martin Schwidefsky
2019-03-27 20:01 ` Mathieu Desnoyers
2019-03-27 20:38 ` Carlos O'Donell
2019-03-28 7:50 ` Martin Schwidefsky
2019-03-28 15:43 ` Mathieu Desnoyers
2019-04-02 6:02 ` Michael Ellerman
2019-04-02 7:08 ` Florian Weimer
2019-04-04 20:33 ` Carlos O'Donell
2019-04-05 9:16 ` Florian Weimer
2019-04-05 15:40 ` Carlos O'Donell
2019-04-08 21:45 ` Tulio Magno Quites Machado Filho
2019-04-08 22:06 ` Carlos O'Donell
2019-04-09 4:28 ` Michael Ellerman
2019-04-09 9:52 ` Alan Modra
2019-04-09 14:13 ` Tulio Magno Quites Machado Filho
2019-04-09 14:58 ` Carlos O'Donell
2019-04-09 15:58 ` Mathieu Desnoyers
2019-04-18 15:33 ` Mathieu Desnoyers
2019-04-09 16:34 ` Mathieu Desnoyers
2019-04-04 20:16 ` Carlos O'Donell
2019-04-04 20:50 ` Carlos O'Donell
[not found] ` <20190404214151.6ogrm34dok52az4h@pburton-laptop>
2019-04-09 17:24 ` Mathieu Desnoyers
2019-04-18 22:42 ` Mathieu Desnoyers
2019-04-24 15:28 ` Mathieu Desnoyers
[not found] ` <20190424231303.zu2irxd5g3v7yqey@pburton-laptop>
2019-04-25 1:57 ` Maciej W. Rozycki
2019-02-12 19:43 ` [PATCH 2/4] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux Mathieu Desnoyers
2019-03-22 20:14 ` Carlos O'Donell [this message]
2019-02-12 19:43 ` [PATCH 3/4] support record failure: allow use from constructor Mathieu Desnoyers
2019-03-22 20:30 ` Carlos O'Donell
2019-02-12 19:51 ` [PATCH 4/4] rseq registration tests (v2) Mathieu Desnoyers
2019-03-27 21:21 ` Carlos O'Donell
2019-04-04 20:04 ` Mathieu Desnoyers
2019-04-04 20:11 ` Carlos O'Donell
2019-04-04 20:23 ` Mathieu Desnoyers
2019-04-05 10:01 ` Florian Weimer
2019-04-05 13:50 ` Carlos O'Donell
2019-04-05 15:27 ` Florian Weimer
2019-04-05 17:38 ` Carlos O'Donell
2019-04-05 19:43 ` Florian Weimer
2019-04-08 22:07 ` Carlos O'Donell
2019-03-22 17:34 ` [PATCH 0/4] Restartable Sequences support for glibc 2.30 Carlos O'Donell
2019-03-22 17:55 ` Mathieu Desnoyers
2019-03-22 18:04 ` Carlos O'Donell
2019-03-22 17:39 ` Florian Weimer
2019-03-22 17:47 ` Carlos O'Donell
2019-03-22 17:51 ` Florian Weimer
2019-03-22 19:46 ` Carlos O'Donell
2019-03-22 20:14 ` Mathieu Desnoyers
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=fc431a95-789a-6c02-13d0-d0d01916ee99@redhat.com \
--to=codonell@redhat.com \
--cc=bmaurer@fb.com \
--cc=boqun.feng@gmail.com \
--cc=carlos@redhat.com \
--cc=davejwatson@fb.com \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=szabolcs.nagy@arm.com \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
/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).