From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, torvalds@linux-foundation.org
Subject: Re-tune x86 uaccess code for PREEMPT_VOLUNTARY v2
Date: Tue, 13 Aug 2013 17:07:08 -0700 [thread overview]
Message-ID: <1376438836-13339-1-git-send-email-andi@firstfloor.org> (raw)
The x86 user access functions (*_user) were originally very well tuned,
with partial inline code and other optimizations.
Then over time various new checks -- particularly the sleep checks for
a voluntary preempt kernel -- destroyed a lot of the tunings
A typical user access operation is now doing multiple useless
function calls. Also the without force inline gcc's inlining
policy makes it even worse, with adding more unnecessary calls.
Here's a typical example from ftrace:
10) | might_fault() {
10) | _cond_resched() {
10) | should_resched() {
10) | need_resched() {
10) 0.063 us | test_ti_thread_flag();
10) 0.643 us | }
10) 1.238 us | }
10) 1.845 us | }
10) 2.438 us | }
So we spent 2.5us doing nothing (ok it's a bit less without
ftrace, but still pretty bad)
Then in other cases we would have an out of line function,
but would actually do the might_sleep() checks in the inlined
caller. This doesn't make any sense at all.
There were also a few other problems, for example the x86-64 uaccess
code regularly falls back to string functions, even though a simple
mov would be enough. For example every futex access to the lock
variable would actually use string instructions, even though
it's just 4 bytes.
This patch kit is an attempt to get us back to sane code,
mostly by doing proper inlining and doing sleep checks in the right
place. Unfortunately I had to add one tree sweep to avoid an nasty
include loop.
v2: Now completely remove reschedule checks for uaccess functions.
next reply other threads:[~2013-08-14 0:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 0:07 Andi Kleen [this message]
2013-08-14 0:07 ` [PATCH 1/8] x86: Add 1/2/4/8 byte optimization to 64bit __copy_{from,to}_user_inatomic Andi Kleen
2013-08-14 0:17 ` Linus Torvalds
2013-08-14 0:07 ` [PATCH 2/8] x86: Include linux/sched.h in asm/uaccess.h Andi Kleen
2013-08-14 0:07 ` [PATCH 3/8] tree-sweep: Include linux/sched.h for might_sleep users Andi Kleen
2013-08-14 0:07 ` [PATCH 4/8] Move might_sleep and friends from kernel.h to sched.h Andi Kleen
2013-08-14 0:07 ` [PATCH 5/8] sched: mark should_resched() __always_inline Andi Kleen
2013-08-14 0:07 ` [PATCH 6/8] Add might_fault_debug_only() Andi Kleen
2013-08-14 0:07 ` [PATCH 7/8] x86: Remove cond_resched() from uaccess code Andi Kleen
2013-08-14 0:07 ` [PATCH 8/8] sched: Inline the need_resched test into the caller for _cond_resched Andi Kleen
2013-08-14 9:56 ` Re-tune x86 uaccess code for PREEMPT_VOLUNTARY v2 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=1376438836-13339-1-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--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
Powered by JetHome