From: Oleg Nesterov <oleg@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Fenghua Yu <fenghua.yu@intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Bean Anderson <bean@azulsystems.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] x86, fpu: sanitize the usage of use_eager_fpu() in switch_fpu_prepare()
Date: Sun, 24 Aug 2014 21:47:47 +0200 [thread overview]
Message-ID: <20140824194747.GA27458@redhat.com> (raw)
In-Reply-To: <20140824194700.GA27281@redhat.com>
switch_fpu_prepare() calls use_eager_fpu() 3 times, and every call
is confusing.
1st: "tsk_used_math(new) && use_eager_fpu()" is pointless, eagerfpu
means that used_math() is also true.
2nd: !fpu.preload && use_eager_fpu() is not possible, we do not need
to check use_eager_fpu() before use_eager_fpu(). IOW, !preload
alway means !use_eager_fpu(), so this check only adds more
confusion.
3rd: If __thread_has_fpu(old) == F then use_eager_fpu() is false too,
no need to check it before fpu_lazy_restore(). IOW, the "else"
branch is simply impossible if use_eager_fpu().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
arch/x86/include/asm/fpu-internal.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index ae6bd35..7b95a87 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -424,8 +424,8 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta
* If the task has used the math, pre-load the FPU on xsave processors
* or if the past 5 consecutive context-switches used math.
*/
- fpu.preload = tsk_used_math(new) && (use_eager_fpu() ||
- new->thread.fpu_counter > 5);
+ fpu.preload = use_eager_fpu() ||
+ (tsk_used_math(new) && new->thread.fpu_counter > 5);
if (__thread_has_fpu(old)) {
if (!__save_init_fpu(old))
cpu = ~0;
@@ -437,14 +437,14 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta
new->thread.fpu_counter++;
__thread_set_has_fpu(new);
prefetch(new->thread.fpu.state);
- } else if (!use_eager_fpu())
+ } else
stts();
} else {
old->thread.fpu_counter = 0;
old->thread.fpu.last_cpu = ~0;
if (fpu.preload) {
new->thread.fpu_counter++;
- if (!use_eager_fpu() && fpu_lazy_restore(new, cpu))
+ if (fpu_lazy_restore(new, cpu))
fpu.preload = 0;
else
prefetch(new->thread.fpu.state);
--
1.5.5.1
next prev parent reply other threads:[~2014-08-24 19:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 17:11 [PATCH 0/1] x86, fpu: shift drop_init_fpu() from save_xstate_sig() to handle_signal() Oleg Nesterov
2014-08-22 17:12 ` [PATCH 1/1] " Oleg Nesterov
2014-08-24 19:47 ` [PATCH 0/5] x86, fpu: make use_eager_fpu() more eager Oleg Nesterov
2014-08-24 19:47 ` [PATCH 1/5] x86, fpu: change sanitize_restored_xstate() and convert_to_fxsr() to accept thread_xstate Oleg Nesterov
2014-08-24 19:47 ` [PATCH 2/5] x86, fpu: don't drop_fpu() in __restore_xstate_sig() if use_eager_fpu() Oleg Nesterov
2014-08-24 20:05 ` Linus Torvalds
2014-08-25 14:26 ` Oleg Nesterov
2014-08-25 14:41 ` Oleg Nesterov
2014-08-25 16:27 ` Linus Torvalds
2014-08-25 17:09 ` Oleg Nesterov
2014-08-25 17:26 ` Linus Torvalds
2014-08-25 17:39 ` Oleg Nesterov
2014-08-27 17:02 ` Oleg Nesterov
2014-08-24 19:47 ` [PATCH 3/5] x86, fpu: don't drop_fpu() in exit_thread() " Oleg Nesterov
2014-08-24 19:47 ` [PATCH 4/5] x86, fpu: shift init_fpu() from eager_fpu_init() to eager_fpu_init_bp() Oleg Nesterov
2014-08-24 19:47 ` Oleg Nesterov [this message]
2014-08-25 18:08 ` [PATCH] x86, fpu: __restore_xstate_sig()->math_state_restore() needs preempt_disable() Oleg Nesterov
2014-09-02 5:01 ` Suresh Siddha
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=20140824194747.GA27458@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bean@azulsystems.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.