diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2006-08-27 07:38:34 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-09-20 09:58:35 -0400 |
commit | 681a4991f83742a0d2325afbf7b7f22045ad5b30 (patch) | |
tree | 8665ef5bba53d53759c34e6e8c0fa08c98c8e4f2 /arch | |
parent | b36e4758dc1b9ff1f6d97e951edba22366230d11 (diff) |
[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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/vfp/vfpmodule.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 4178f6cc3d37..dedbb449632e 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c | |||
@@ -40,10 +40,19 @@ unsigned int VFP_arch; | |||
40 | static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) | 40 | static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) |
41 | { | 41 | { |
42 | struct thread_info *thread = v; | 42 | struct thread_info *thread = v; |
43 | union vfp_state *vfp = &thread->vfpstate; | 43 | union vfp_state *vfp; |
44 | 44 | ||
45 | switch (cmd) { | 45 | if (likely(cmd == THREAD_NOTIFY_SWITCH)) { |
46 | case THREAD_NOTIFY_FLUSH: | 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) { | ||
47 | /* | 56 | /* |
48 | * Per-thread VFP initialisation. | 57 | * Per-thread VFP initialisation. |
49 | */ | 58 | */ |
@@ -56,29 +65,12 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) | |||
56 | * Disable VFP to ensure we initialise it first. | 65 | * Disable VFP to ensure we initialise it first. |
57 | */ | 66 | */ |
58 | fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE); | 67 | 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; | ||
80 | } | 68 | } |
81 | 69 | ||
70 | /* flush and release case: Per-thread VFP cleanup. */ | ||
71 | if (last_VFP_context == vfp) | ||
72 | last_VFP_context = NULL; | ||
73 | |||
82 | return NOTIFY_DONE; | 74 | return NOTIFY_DONE; |
83 | } | 75 | } |
84 | 76 | ||