From: Andy Lutomirski <luto@MIT.EDU>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andi Kleen <andi@firstfloor.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <eric.dumazet@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@amd64.org>, Andy Lutomirski <luto@MIT.EDU>
Subject: [PATCH v4 0/6] Micro-optimize vclock_gettime
Date: Mon, 16 May 2011 12:00:57 -0400 [thread overview]
Message-ID: <cover.1305560561.git.luto@mit.edu> (raw)
This series speeds up vclock_gettime(CLOCK_MONOTONIC) on by almost
30% (tested on Sandy Bridge). These patches are intended for
2.6.40, and if I'm feeling really ambitious I'll try to shave a few
more ns off for 2.6.41. (There are lots more optimization
opportunities in there.)
x86-64: Clean up vdso/kernel shared variables
Because vsyscall_gtod_data's address isn't known until load time,
the code contains unnecessary address calculations. The code is
also rather complicated. Clean it up and use addresses that are
known at compile time.
x86-64: Remove unnecessary barrier in vread_tsc
A fair amount of testing on lots of machines has failed to find a
single example in which the barrier *after* rdtsc is needed. So
remove it. (The manuals give no real justification for it, and
rdtsc has no dependencies so there's no sensible reason for a CPU to
delay it.)
x86-64: Don't generate cmov in vread_tsc
GCC likes to generate a cmov on a branch that's almost completely
predictable. Force it to generate a real branch instead.
x86-64: vclock_gettime(CLOCK_MONOTONIC) can't ever see nsec < 0
vset_normalize_timespec was more general than necessary. Open-code
the appropriate normalization loops. This is a big win for
CLOCK_MONOTONIC_COARSE.
x86-64: Move vread_tsc into a new file with sensible options
This way vread_tsc doesn't have a frame pointer, with saves about
0.3ns. I guess that the CPU's stack frame optimizations aren't quite
as good as I thought.
x86-64: Turn off -pg and turn on -foptimize-sibling-calls for vDSO
We're building the vDSO with optimizations disabled that were meant
for kernel code. Override that, except for -fno-omit-frame-pointers,
which might make userspace debugging harder.
Changes from v3:
- Put jiffies and vgetcpu_mode into the same cacheline. I folded it
into the vsyscall cleanup patch because it's literally just changing
a number. (In theory one more cacheline could be saved by putting
jiffies and vgetcpu_mode at the end of gtod_data, but that would be
annoying to maintain and would, I think, have little benefit.
- Don't turn off frame pointers in vDSO code.
Changes from v2:
- Just remove the second barrier instead of hacking it. Tests
still pass.
Changes from v1:
- Redo the vsyscall_gtod_data address patch to make the code
cleaner instead of uglier and to make it work for all the
vsyscall variables.
- Improve the comments for clarity and formatting.
- Fix up the changelog for the nsec < 0 tweak (the normalization
code can't be inline because the two callers are different).
- Move vread_tsc into its own file, removing a GCC version
dependence and making it more maintainable.
Andy Lutomirski (6):
x86-64: Clean up vdso/kernel shared variables
x86-64: Remove unnecessary barrier in vread_tsc
x86-64: Don't generate cmov in vread_tsc
x86-64: vclock_gettime(CLOCK_MONOTONIC) can't ever see nsec < 0
x86-64: Move vread_tsc into a new file with sensible options
x86-64: Turn off -pg and turn on -foptimize-sibling-calls for vDSO
arch/x86/include/asm/tsc.h | 4 +++
arch/x86/include/asm/vdso.h | 14 ----------
arch/x86/include/asm/vgtod.h | 2 -
arch/x86/include/asm/vsyscall.h | 12 +-------
arch/x86/include/asm/vvar.h | 52 +++++++++++++++++++++++++++++++++++++++
arch/x86/kernel/Makefile | 8 +++--
arch/x86/kernel/time.c | 2 +-
arch/x86/kernel/tsc.c | 19 --------------
arch/x86/kernel/vmlinux.lds.S | 34 ++++++++-----------------
arch/x86/kernel/vread_tsc_64.c | 36 +++++++++++++++++++++++++++
arch/x86/kernel/vsyscall_64.c | 46 +++++++++++++++-------------------
arch/x86/vdso/Makefile | 17 +++++++++++-
arch/x86/vdso/vclock_gettime.c | 43 +++++++++++++++++---------------
arch/x86/vdso/vdso.lds.S | 7 -----
arch/x86/vdso/vextern.h | 16 ------------
arch/x86/vdso/vgetcpu.c | 3 +-
arch/x86/vdso/vma.c | 27 --------------------
arch/x86/vdso/vvar.c | 12 ---------
18 files changed, 170 insertions(+), 184 deletions(-)
create mode 100644 arch/x86/include/asm/vvar.h
create mode 100644 arch/x86/kernel/vread_tsc_64.c
delete mode 100644 arch/x86/vdso/vextern.h
delete mode 100644 arch/x86/vdso/vvar.c
--
1.7.5.1
next reply other threads:[~2011-05-16 16:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 16:00 Andy Lutomirski [this message]
2011-05-16 16:00 ` [PATCH v4 1/6] x86-64: Clean up vdso/kernel shared variables Andy Lutomirski
2011-05-16 17:23 ` Borislav Petkov
2011-05-16 17:34 ` Andrew Lutomirski
2011-05-16 16:00 ` [PATCH v4 2/6] x86-64: Remove unnecessary barrier in vread_tsc Andy Lutomirski
2011-05-16 16:01 ` [PATCH v4 3/6] x86-64: Don't generate cmov " Andy Lutomirski
2011-05-16 16:01 ` [PATCH v4 4/6] x86-64: vclock_gettime(CLOCK_MONOTONIC) can't ever see nsec < 0 Andy Lutomirski
2011-05-16 16:01 ` [PATCH v4 5/6] x86-64: Move vread_tsc into a new file with sensible options Andy Lutomirski
2011-05-16 16:01 ` [PATCH v4 6/6] x86-64: Turn off -pg and turn on -foptimize-sibling-calls for vDSO Andy Lutomirski
2011-05-16 16:09 ` [PATCH v4 0/6] Micro-optimize vclock_gettime Andi Kleen
2011-05-16 16:25 ` Thomas Gleixner
2011-05-16 16:49 ` Andi Kleen
2011-05-16 17:05 ` Andrew Lutomirski
2011-05-16 20:22 ` Andi Kleen
2011-05-16 21:28 ` Andrew Lutomirski
2011-05-16 21:53 ` Thomas Gleixner
2011-05-16 22:17 ` Andrew Lutomirski
2011-05-16 22:40 ` Thomas Gleixner
2011-05-17 8:00 ` Ingo Molnar
2011-05-17 11:11 ` Andrew Lutomirski
2011-05-17 11:36 ` Ingo Molnar
2011-05-17 18:31 ` Andy Lutomirski
2011-05-17 19:27 ` Ingo Molnar
2011-05-17 21:31 ` Andi Kleen
2011-05-17 22:59 ` Thomas Gleixner
2011-05-18 3:18 ` Andrew Lutomirski
2011-05-18 7:30 ` Thomas Gleixner
2011-05-18 8:31 ` Ingo Molnar
2011-05-18 11:30 ` Andrew Lutomirski
2011-05-18 12:10 ` Ingo Molnar
2011-05-17 7:56 ` Ingo Molnar
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=cover.1305560561.git.luto@mit.edu \
--to=luto@mit.edu \
--cc=a.p.zijlstra@chello.nl \
--cc=andi@firstfloor.org \
--cc=bp@amd64.org \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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 NNTP newsgroup(s).