Skip to content

Commit 681a499

Browse files
Russell KingRussell King
authored andcommitted
[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: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent b36e475 commit 681a499

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

arch/arm/vfp/vfpmodule.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ unsigned int VFP_arch;
4040
static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
4141
{
4242
struct thread_info *thread = v;
43-
union vfp_state *vfp = &thread->vfpstate;
43+
union vfp_state *vfp;
4444

45-
switch (cmd) {
46-
case THREAD_NOTIFY_FLUSH:
45+
if (likely(cmd == THREAD_NOTIFY_SWITCH)) {
46+
/*
47+
* Always disable VFP so we can lazily save/restore the
48+
* old state.
49+
*/
50+
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
51+
return NOTIFY_DONE;
52+
}
53+
54+
vfp = &thread->vfpstate;
55+
if (cmd == THREAD_NOTIFY_FLUSH) {
4756
/*
4857
* Per-thread VFP initialisation.
4958
*/
@@ -56,29 +65,12 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
5665
* Disable VFP to ensure we initialise it first.
5766
*/
5867
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
59-
60-
/*
61-
* FALLTHROUGH: Ensure we don't try to overwrite our newly
62-
* initialised state information on the first fault.
63-
*/
64-
65-
case THREAD_NOTIFY_RELEASE:
66-
/*
67-
* Per-thread VFP cleanup.
68-
*/
69-
if (last_VFP_context == vfp)
70-
last_VFP_context = NULL;
71-
break;
72-
73-
case THREAD_NOTIFY_SWITCH:
74-
/*
75-
* Always disable VFP so we can lazily save/restore the
76-
* old state.
77-
*/
78-
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE);
79-
break;
8068
}
8169

70+
/* flush and release case: Per-thread VFP cleanup. */
71+
if (last_VFP_context == vfp)
72+
last_VFP_context = NULL;
73+
8274
return NOTIFY_DONE;
8375
}
8476

0 commit comments

Comments
 (0)