From: riel@redhat.com
To: linux-kernel@vger.kernel.org
Cc: hpa@zytor.com, mingo@kernel.org, bp@alien8.de,
dave.hansen@linux.intel.com, luto@kernel.org, oleg@redhat.comm
Subject: [PATCH 1/2] x86/fpu: remove cpu argument to __cpu_invalidate_fpregs_state
Date: Fri, 14 Oct 2016 08:15:30 -0400 [thread overview]
Message-ID: <1476447331-21566-2-git-send-email-riel@redhat.com> (raw)
In-Reply-To: <1476447331-21566-1-git-send-email-riel@redhat.com>
From: Rik van Riel <riel@redhat.com>
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>
---
arch/x86/include/asm/fpu/internal.h | 13 +++++++------
arch/x86/kernel/fpu/core.c | 2 +-
arch/x86/kernel/smpboot.c | 2 +-
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 ef52935f8a17..a75324675311 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);
*
* 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)
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)
*/
copy_fpregs_to_fpstate(fpu);
} else {
- this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+ __cpu_invalidate_fpregs_state();
}
}
EXPORT_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)
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);
--
2.7.4
next prev parent reply other threads:[~2016-10-14 12:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-14 12:15 [PATCH 0/2] x86/fpu: two more FPU cleanups riel
2016-10-14 12:15 ` riel [this message]
2016-10-14 16:53 ` [PATCH 1/2] x86/fpu: remove cpu argument to __cpu_invalidate_fpregs_state Dave Hansen
2016-10-16 11:25 ` [tip:x86/fpu] x86/fpu: Remove 'cpu' argument from __cpu_invalidate_fpregs_state() tip-bot for Rik van Riel
2016-10-14 12:15 ` [PATCH 2/2] x86/fpu: split old & new fpu handling into separate functions riel
2016-10-14 17:14 ` Dave Hansen
2016-10-16 11:25 ` [tip:x86/fpu] x86/fpu: Split old_fpu & new_fpu " tip-bot for Rik van Riel
2017-01-24 12:13 ` you have a new message from... c92Y Izuchukwu Francis
2017-02-10 13:52 ` Izuchukwu Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476447331-21566-2-git-send-email-riel@redhat.com \
--to=riel@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.comm \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome