Commit 681a4991 authored by Russell King's avatar Russell King Committed by Russell King

[ARM] Optimise VFP thread notify function a little

The common case for the thread notifier is a context switch.  Tell
gcc that this is the most likely condition so it can optimise the
function for this case.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent b36e4758
...@@ -40,10 +40,19 @@ unsigned int VFP_arch; ...@@ -40,10 +40,19 @@ unsigned int VFP_arch;
static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
{ {
struct thread_info *thread = v; struct thread_info *thread = v;
union vfp_state *vfp = &thread->vfpstate; union vfp_state *vfp;
switch (cmd) { if (likely(cmd == THREAD_NOTIFY_SWITCH)) {
case THREAD_NOTIFY_FLUSH: /*
* Always disable VFP so we can lazily save/restore the
* old state.
*/
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
return NOTIFY_DONE;
}
vfp = &thread->vfpstate;
if (cmd == THREAD_NOTIFY_FLUSH) {
/* /*
* Per-thread VFP initialisation. * Per-thread VFP initialisation.
*/ */
...@@ -56,29 +65,12 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) ...@@ -56,29 +65,12 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
* Disable VFP to ensure we initialise it first. * Disable VFP to ensure we initialise it first.
*/ */
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE); fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
/*
* FALLTHROUGH: Ensure we don't try to overwrite our newly
* initialised state information on the first fault.
*/
case THREAD_NOTIFY_RELEASE:
/*
* Per-thread VFP cleanup.
*/
if (last_VFP_context == vfp)
last_VFP_context = NULL;
break;
case THREAD_NOTIFY_SWITCH:
/*
* Always disable VFP so we can lazily save/restore the
* old state.
*/
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
break;
} }
/* flush and release case: Per-thread VFP cleanup. */
if (last_VFP_context == vfp)
last_VFP_context = NULL;
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment