]> git.karo-electronics.de Git - linux-beck.git/commitdiff
x86/fpu: Remove 'cpu' argument from __cpu_invalidate_fpregs_state()
authorRik van Riel <riel@redhat.com>
Fri, 14 Oct 2016 12:15:30 +0000 (08:15 -0400)
committerIngo Molnar <mingo@kernel.org>
Sun, 16 Oct 2016 09:38:31 +0000 (11:38 +0200)
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>
arch/x86/include/asm/fpu/internal.h
arch/x86/kernel/fpu/core.c
arch/x86/kernel/smpboot.c

index 1dcb29e8d92c043cf7496c3439acfd69246ca971..590f27488fcaf68feb8b043264a46b6920606336 100644 (file)
@@ -488,15 +488,16 @@ DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
  *
  * Any code that clobbers the FPU registers or updates the in-memory
  * FPU state for a task MUST let the rest of the kernel know that the
- * FPU registers are no longer valid for this task. Calling either of
- * these two invalidate functions is enough, use whichever is convenient.
+ * FPU registers are no longer valid for this task.
  *
- * Must be run with preemption disabled: this clears the fpu_fpregs_owner_ctx,
- * on this CPU.
+ * Either one of these invalidation functions is enough. Invalidate
+ * a resource you control: CPU if using the CPU for something else
+ * (with preemption disabled), FPU for the current task, or a task that
+ * is prevented from running by the current task.
  */
-static inline void __cpu_invalidate_fpregs_state(unsigned int cpu)
+static inline void __cpu_invalidate_fpregs_state(void)
 {
-       per_cpu(fpu_fpregs_owner_ctx, cpu) = NULL;
+       __this_cpu_write(fpu_fpregs_owner_ctx, NULL);
 }
 
 static inline void __fpu_invalidate_fpregs_state(struct fpu *fpu)
index 25a45ddfdbcf798f8e64c6e8774d6578beddb78a..30f11ab6c07e37fa53c52841062f7d6962b5ae85 100644 (file)
@@ -106,7 +106,7 @@ void __kernel_fpu_begin(void)
                 */
                copy_fpregs_to_fpstate(fpu);
        } else {
-               this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+               __cpu_invalidate_fpregs_state();
        }
 }
 EXPORT_SYMBOL(__kernel_fpu_begin);
index ca4c4ca2f6af73c1fddcec2b4055ca76f34c8b4d..5cb801acc2e5ffb09664540b6026341c0c801c75 100644 (file)
@@ -1111,7 +1111,7 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
                return err;
 
        /* the FPU context is blank, nobody can own it */
-       __cpu_invalidate_fpregs_state(cpu);
+       per_cpu(fpu_fpregs_owner_ctx, cpu) = NULL;
 
        common_cpu_up(cpu, tidle);