linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Christoph Hellwig <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, hpa@zytor.com, hch@lst.de, bp@suse.de,
	bigeasy@linutronix.de, x86@kernel.org, riel@surriel.com,
	nstange@suse.de, tglx@linutronix.de, mingo@redhat.com,
	dave.hansen@intel.com, linux-kernel@vger.kernel.org
Subject: [tip:x86/fpu] x86/fpu: Simplify kernel_fpu_begin()
Date: Mon, 17 Jun 2019 03:31:49 -0700	[thread overview]
Message-ID: <tip-6d79d86f9600510e08ad45c72b9d7e664e439e62@git.kernel.org> (raw)
In-Reply-To: <20190604071524.12835-3-hch@lst.de>

Commit-ID:  6d79d86f9600510e08ad45c72b9d7e664e439e62
Gitweb:     https://git.kernel.org/tip/6d79d86f9600510e08ad45c72b9d7e664e439e62
Author:     Christoph Hellwig <hch@lst.de>
AuthorDate: Tue, 4 Jun 2019 09:15:23 +0200
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Mon, 17 Jun 2019 12:19:49 +0200

x86/fpu: Simplify kernel_fpu_begin()

Merge two helpers into the main function, remove a pointless local
variable and flatten a conditional.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Nicolai Stange <nstange@suse.de>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190604071524.12835-3-hch@lst.de
---
 arch/x86/kernel/fpu/core.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 8e046068d20f..3f92cfad88f0 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -43,12 +43,6 @@ static DEFINE_PER_CPU(bool, in_kernel_fpu);
  */
 DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
 
-static void kernel_fpu_disable(void)
-{
-	WARN_ON_FPU(this_cpu_read(in_kernel_fpu));
-	this_cpu_write(in_kernel_fpu, true);
-}
-
 static bool kernel_fpu_disabled(void)
 {
 	return this_cpu_read(in_kernel_fpu);
@@ -88,32 +82,26 @@ bool irq_fpu_usable(void)
 }
 EXPORT_SYMBOL(irq_fpu_usable);
 
-static void __kernel_fpu_begin(void)
+void kernel_fpu_begin(void)
 {
-	struct fpu *fpu = &current->thread.fpu;
+	preempt_disable();
 
 	WARN_ON_FPU(!irq_fpu_usable());
+	WARN_ON_FPU(this_cpu_read(in_kernel_fpu));
 
-	kernel_fpu_disable();
+	this_cpu_write(in_kernel_fpu, true);
 
-	if (!(current->flags & PF_KTHREAD)) {
-		if (!test_thread_flag(TIF_NEED_FPU_LOAD)) {
-			set_thread_flag(TIF_NEED_FPU_LOAD);
-			/*
-			 * Ignore return value -- we don't care if reg state
-			 * is clobbered.
-			 */
-			copy_fpregs_to_fpstate(fpu);
-		}
+	if (!(current->flags & PF_KTHREAD) &&
+	    !test_thread_flag(TIF_NEED_FPU_LOAD)) {
+		set_thread_flag(TIF_NEED_FPU_LOAD);
+		/*
+		 * Ignore return value -- we don't care if reg state
+		 * is clobbered.
+		 */
+		copy_fpregs_to_fpstate(&current->thread.fpu);
 	}
 	__cpu_invalidate_fpregs_state();
 }
-
-void kernel_fpu_begin(void)
-{
-	preempt_disable();
-	__kernel_fpu_begin();
-}
 EXPORT_SYMBOL_GPL(kernel_fpu_begin);
 
 void kernel_fpu_end(void)

  parent reply	other threads:[~2019-06-17 10:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  7:15 x86 fpu cleanups Christoph Hellwig
2019-06-04  7:15 ` [PATCH 1/3] x86/fpu: Simplify kernel_fpu_end Christoph Hellwig
2019-06-17 10:31   ` [tip:x86/fpu] x86/fpu: Simplify kernel_fpu_end() tip-bot for Christoph Hellwig
2019-06-04  7:15 ` [PATCH 2/3] x86/fpu: Simplify kernel_fpu_begin Christoph Hellwig
2019-06-04 11:47   ` Peter Zijlstra
2019-06-04 13:11     ` Christoph Hellwig
2019-06-04 13:34       ` Peter Zijlstra
2019-06-04 14:34         ` Christoph Hellwig
2019-06-17 10:31   ` tip-bot for Christoph Hellwig [this message]
2019-06-04  7:15 ` [PATCH 3/3] x86/fpu: remove the fpu__save export Christoph Hellwig
2019-06-17 10:32   ` [tip:x86/fpu] x86/fpu: Remove the fpu__save() export tip-bot for Christoph Hellwig
2019-06-04 17:54 ` [PATCH 4/3] x86/fpu: don't use current->mm to check for a kthread Christoph Hellwig
2019-06-11  7:52   ` Sebastian Andrzej Siewior
2019-06-13 19:03   ` Borislav Petkov
2019-06-13 19:07   ` [tip:x86/urgent] x86/fpu: Don't " tip-bot for Christoph Hellwig

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=tip-6d79d86f9600510e08ad45c72b9d7e664e439e62@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@intel.com \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nstange@suse.de \
    --cc=riel@surriel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).