aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2016-10-14 08:15:30 -0400
committerIngo Molnar <mingo@kernel.org>2016-10-16 05:38:31 -0400
commit317b622cb2fda1812d8646e211cdb23dce2564d0 (patch)
tree07762110cae03a11c03b31c13468d265cdb0f1f4
parent9ad93fe35aff616fca4e2b9581fdeed498605f9e (diff)
x86/fpu: Remove 'cpu' argument from __cpu_invalidate_fpregs_state()
The __{fpu,cpu}_invalidate_fpregs_state() functions can only be used to invalidate a resource they control. Document that, and change the API a little bit to reflect that. Go back to open coding the fpu_fpregs_owner_ctx write in the CPU hotplug code, which should be the exception, and move __kernel_fpu_begin() to this API. This patch has no functional changes to the current code. Signed-off-by: Rik van Riel <riel@redhat.com> Acked-by: Dave Hansen <dave.hansen@intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.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: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1476447331-21566-2-git-send-email-riel@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/fpu/internal.h13
-rw-r--r--arch/x86/kernel/fpu/core.c2
-rw-r--r--arch/x86/kernel/smpboot.c2
3 files changed, 9 insertions, 8 deletions
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index 1dcb29e8d92c..590f27488fca 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -488,15 +488,16 @@ DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
488 * 488 *
489 * Any code that clobbers the FPU registers or updates the in-memory 489 * Any code that clobbers the FPU registers or updates the in-memory
490 * FPU state for a task MUST let the rest of the kernel know that the 490 * FPU state for a task MUST let the rest of the kernel know that the
491 * FPU registers are no longer valid for this task. Calling either of 491 * FPU registers are no longer valid for this task.
492 * these two invalidate functions is enough, use whichever is convenient.
493 * 492 *
494 * Must be run with preemption disabled: this clears the fpu_fpregs_owner_ctx, 493 * Either one of these invalidation functions is enough. Invalidate
495 * on this CPU. 494 * a resource you control: CPU if using the CPU for something else
495 * (with preemption disabled), FPU for the current task, or a task that
496 * is prevented from running by the current task.
496 */ 497 */
497static inline void __cpu_invalidate_fpregs_state(unsigned int cpu) 498static inline void __cpu_invalidate_fpregs_state(void)
498{ 499{
499 per_cpu(fpu_fpregs_owner_ctx, cpu) = NULL; 500 __this_cpu_write(fpu_fpregs_owner_ctx, NULL);
500} 501}
501 502
502static inline void __fpu_invalidate_fpregs_state(struct fpu *fpu) 503static inline void __fpu_invalidate_fpregs_state(struct fpu *fpu)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 25a45ddfdbcf..30f11ab6c07e 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -106,7 +106,7 @@ void __kernel_fpu_begin(void)
106 */ 106 */
107 copy_fpregs_to_fpstate(fpu); 107 copy_fpregs_to_fpstate(fpu);
108 } else { 108 } else {
109 this_cpu_write(fpu_fpregs_owner_ctx, NULL); 109 __cpu_invalidate_fpregs_state();
110 } 110 }
111} 111}
112EXPORT_SYMBOL(__kernel_fpu_begin); 112EXPORT_SYMBOL(__kernel_fpu_begin);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index ca4c4ca2f6af..5cb801acc2e5 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1111,7 +1111,7 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1111 return err; 1111 return err;
1112 1112
1113 /* the FPU context is blank, nobody can own it */ 1113 /* the FPU context is blank, nobody can own it */
1114 __cpu_invalidate_fpregs_state(cpu); 1114 per_cpu(fpu_fpregs_owner_ctx, cpu) = NULL;
1115 1115
1116 common_cpu_up(cpu, tidle); 1116 common_cpu_up(cpu, tidle);
1117 1117