diff options
author | Andy Lutomirski <luto@kernel.org> | 2016-01-24 17:38:08 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-02-09 09:42:55 -0500 |
commit | a20d7297045f7fdcd676c15243192eb0e95a4306 (patch) | |
tree | eb278a36d802bd6d56852ef90e6aeae76a48de15 | |
parent | 5ed73f40735c68d8a656b46d09b1885d3b8740ae (diff) |
x86/fpu: Fold fpu_copy() into fpu__copy()
Splitting it into two functions needlessly obfuscated the code.
While we're at it, improve the comment slightly.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: yu-cheng yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/3eb5a63a9c5c84077b2677a7dfe684eef96fe59e.1453675014.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/fpu/core.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 7a9244df33e2..299b58bb975b 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c | |||
@@ -231,14 +231,15 @@ void fpstate_init(union fpregs_state *state) | |||
231 | } | 231 | } |
232 | EXPORT_SYMBOL_GPL(fpstate_init); | 232 | EXPORT_SYMBOL_GPL(fpstate_init); |
233 | 233 | ||
234 | /* | 234 | int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) |
235 | * Copy the current task's FPU state to a new task's FPU context. | ||
236 | * | ||
237 | * In both the 'eager' and the 'lazy' case we save hardware registers | ||
238 | * directly to the destination buffer. | ||
239 | */ | ||
240 | static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu) | ||
241 | { | 235 | { |
236 | dst_fpu->counter = 0; | ||
237 | dst_fpu->fpregs_active = 0; | ||
238 | dst_fpu->last_cpu = -1; | ||
239 | |||
240 | if (!src_fpu->fpstate_active || !cpu_has_fpu) | ||
241 | return 0; | ||
242 | |||
242 | WARN_ON_FPU(src_fpu != ¤t->thread.fpu); | 243 | WARN_ON_FPU(src_fpu != ¤t->thread.fpu); |
243 | 244 | ||
244 | /* | 245 | /* |
@@ -251,10 +252,9 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu) | |||
251 | /* | 252 | /* |
252 | * Save current FPU registers directly into the child | 253 | * Save current FPU registers directly into the child |
253 | * FPU context, without any memory-to-memory copying. | 254 | * FPU context, without any memory-to-memory copying. |
254 | * | 255 | * In lazy mode, if the FPU context isn't loaded into |
255 | * If the FPU context got destroyed in the process (FNSAVE | 256 | * fpregs, CR0.TS will be set and do_device_not_available |
256 | * done on old CPUs) then copy it back into the source | 257 | * will load the FPU context. |
257 | * context and mark the current task for lazy restore. | ||
258 | * | 258 | * |
259 | * We have to do all this with preemption disabled, | 259 | * We have to do all this with preemption disabled, |
260 | * mostly because of the FNSAVE case, because in that | 260 | * mostly because of the FNSAVE case, because in that |
@@ -274,16 +274,6 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu) | |||
274 | fpregs_deactivate(src_fpu); | 274 | fpregs_deactivate(src_fpu); |
275 | } | 275 | } |
276 | preempt_enable(); | 276 | preempt_enable(); |
277 | } | ||
278 | |||
279 | int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) | ||
280 | { | ||
281 | dst_fpu->counter = 0; | ||
282 | dst_fpu->fpregs_active = 0; | ||
283 | dst_fpu->last_cpu = -1; | ||
284 | |||
285 | if (src_fpu->fpstate_active && cpu_has_fpu) | ||
286 | fpu_copy(dst_fpu, src_fpu); | ||
287 | 277 | ||
288 | return 0; | 278 | return 0; |
289 | } | 279 | } |