All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 035/208] x86/fpu: Factor out fpu__copy()
Date: Tue,  5 May 2015 18:24:15 +0200	[thread overview]
Message-ID: <1430843228-13749-36-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1430843228-13749-1-git-send-email-mingo@kernel.org>

Introduce fpu__copy() and use it in arch_dup_task_struct(),
thus moving another chunk of FPU logic to fpu/core.c.

Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
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: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/fpu-internal.h |  1 +
 arch/x86/kernel/fpu/core.c          | 18 ++++++++++++++++++
 arch/x86/kernel/process.c           | 12 +-----------
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index f41170c6d376..6c1ceb7c3f9a 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -567,6 +567,7 @@ static inline unsigned short get_fpu_mxcsr(struct task_struct *tsk)
 extern void fpstate_cache_init(void);
 
 extern int fpstate_alloc(struct fpu *fpu);
+extern int fpu__copy(struct task_struct *dst, struct task_struct *src);
 
 static inline void fpstate_free(struct fpu *fpu)
 {
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 9dc4bb3f6f5a..e02c42965f53 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -178,6 +178,24 @@ int fpstate_alloc(struct fpu *fpu)
 }
 EXPORT_SYMBOL_GPL(fpstate_alloc);
 
+int fpu__copy(struct task_struct *dst, struct task_struct *src)
+{
+	dst->thread.fpu.counter = 0;
+	dst->thread.fpu.has_fpu = 0;
+	dst->thread.fpu.state = NULL;
+
+	task_disable_lazy_fpu_restore(dst);
+
+	if (tsk_used_math(src)) {
+		int err = fpstate_alloc(&dst->thread.fpu);
+
+		if (err)
+			return err;
+		fpu_copy(dst, src);
+	}
+	return 0;
+}
+
 /*
  * Allocate the backing store for the current task's FPU registers
  * and initialize the registers themselves as well.
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index fda613eeeebd..1b4ea12e412d 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -83,17 +83,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
 	*dst = *src;
 
-	dst->thread.fpu.counter = 0;
-	dst->thread.fpu.has_fpu = 0;
-	dst->thread.fpu.state = NULL;
-	task_disable_lazy_fpu_restore(dst);
-	if (tsk_used_math(src)) {
-		int err = fpstate_alloc(&dst->thread.fpu);
-		if (err)
-			return err;
-		fpu_copy(dst, src);
-	}
-	return 0;
+	return fpu__copy(dst, src);
 }
 
 void arch_release_task_struct(struct task_struct *tsk)
-- 
2.1.0


  parent reply	other threads:[~2015-05-05 16:58 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05 16:23 [PATCH 000/208] big x86 FPU code rewrite Ingo Molnar
2015-05-05 16:23 ` [PATCH 001/208] x86/fpu: Rename unlazy_fpu() to fpu__save() Ingo Molnar
2015-05-05 16:23 ` [PATCH 002/208] x86/fpu: Add comments to fpu__save() and restrict its export Ingo Molnar
2015-05-05 16:23 ` [PATCH 003/208] x86/fpu: Add debugging check to fpu__save() Ingo Molnar
2015-05-05 16:23 ` [PATCH 004/208] x86/fpu: Rename fpu_detect() to fpu__detect() Ingo Molnar
2015-05-05 16:23 ` [PATCH 005/208] x86/fpu: Remove stale init_fpu() prototype Ingo Molnar
2015-05-05 16:23 ` [PATCH 006/208] x86/fpu: Split an fpstate_alloc_init() function out of init_fpu() Ingo Molnar
2015-05-05 16:23 ` [PATCH 007/208] x86/fpu: Make init_fpu() static Ingo Molnar
2015-05-05 16:23 ` [PATCH 008/208] x86/fpu: Rename init_fpu() to fpu__unlazy_stopped() and add debugging check Ingo Molnar
2015-05-05 16:23 ` [PATCH 009/208] x86/fpu: Optimize fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:23 ` [PATCH 010/208] x86/fpu: Simplify fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:23 ` [PATCH 011/208] x86/fpu: Remove fpu_allocated() Ingo Molnar
2015-05-05 16:23 ` [PATCH 012/208] x86/fpu: Move fpu_alloc() out of line Ingo Molnar
2015-05-05 16:23 ` [PATCH 013/208] x86/fpu: Rename fpu_alloc() to fpstate_alloc() Ingo Molnar
2015-05-05 16:23 ` [PATCH 014/208] x86/fpu: Rename fpu_free() to fpstate_free() Ingo Molnar
2015-05-05 16:23 ` [PATCH 015/208] x86/fpu: Rename fpu_finit() to fpstate_init() Ingo Molnar
2015-05-05 16:23 ` [PATCH 016/208] x86/fpu: Rename fpu_init() to fpu__cpu_init() Ingo Molnar
2015-05-05 16:23 ` [PATCH 017/208] x86/fpu: Rename init_thread_xstate() to fpstate_xstate_init_size() Ingo Molnar
2015-05-05 16:23 ` [PATCH 018/208] x86/fpu: Move thread_info::fpu_counter into thread_info::fpu.counter Ingo Molnar
2015-05-05 16:23 ` [PATCH 019/208] x86/fpu: Improve the comment for the fpu::counter field Ingo Molnar
2015-05-05 16:24 ` [PATCH 020/208] x86/fpu: Move FPU data structures to asm/fpu_types.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 021/208] x86/fpu: Clean up asm/fpu/types.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 022/208] x86/fpu: Move i387.c and xsave.c to arch/x86/kernel/fpu/ Ingo Molnar
2015-05-05 16:24 ` [PATCH 023/208] x86/fpu: Fix header file dependencies of fpu-internal.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 024/208] x86/fpu: Split out the boot time FPU init code into fpu/init.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 025/208] x86/fpu: Remove unnecessary includes from core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 026/208] x86/fpu: Move the no_387 handling and FPU detection code into init.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 027/208] x86/fpu: Remove the free_thread_xstate() complication Ingo Molnar
2015-05-05 16:24 ` [PATCH 028/208] x86/fpu: Factor out fpu__flush_thread() from flush_thread() Ingo Molnar
2015-05-05 16:24 ` [PATCH 029/208] x86/fpu: Move math_state_restore() to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 030/208] x86/fpu: Rename math_state_restore() to fpu__restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 031/208] x86/fpu: Factor out the FPU bug detection code into fpu__init_check_bugs() Ingo Molnar
2015-05-05 16:24 ` [PATCH 032/208] x86/fpu: Simplify the xsave_state*() methods Ingo Molnar
2015-05-05 16:24 ` [PATCH 033/208] x86/fpu: Remove fpu_xsave() Ingo Molnar
2015-05-05 16:24 ` [PATCH 034/208] x86/fpu: Move task_xstate_cachep handling to core.c Ingo Molnar
2015-05-05 16:24 ` Ingo Molnar [this message]
2015-05-05 16:24 ` [PATCH 036/208] x86/fpu: Uninline fpstate_free() and move it next to the allocation function Ingo Molnar
2015-05-05 16:24 ` [PATCH 037/208] x86/fpu: Make task_xstate_cachep static Ingo Molnar
2015-05-05 16:24 ` [PATCH 038/208] x86/fpu: Make kernel_fpu_disable/enable() static Ingo Molnar
2015-05-05 16:24 ` [PATCH 039/208] x86/fpu: Add debug check to kernel_fpu_disable() Ingo Molnar
2015-05-05 16:24 ` [PATCH 040/208] x86/fpu: Add kernel_fpu_disabled() Ingo Molnar
2015-05-05 16:24 ` [PATCH 041/208] x86/fpu: Remove __save_init_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 042/208] x86/fpu: Move fpu_copy() to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 043/208] x86/fpu: Add debugging check to fpu_copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 044/208] x86/fpu: Print out whether we are doing lazy/eager FPU context switches Ingo Molnar
2015-05-05 16:24 ` [PATCH 045/208] x86/fpu: Eliminate the __thread_has_fpu() wrapper Ingo Molnar
2015-05-05 16:24 ` [PATCH 046/208] x86/fpu: Change __thread_clear_has_fpu() to 'struct fpu' parameter Ingo Molnar
2015-05-05 16:24 ` [PATCH 047/208] x86/fpu: Move 'PER_CPU(fpu_owner_task)' to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 048/208] x86/fpu: Change fpu_owner_task to fpu_fpregs_owner_ctx Ingo Molnar
2015-05-05 16:24 ` [PATCH 049/208] x86/fpu: Remove 'struct task_struct' usage from __thread_set_has_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 050/208] x86/fpu: Remove 'struct task_struct' usage from __thread_fpu_end() Ingo Molnar
2015-05-05 16:24 ` [PATCH 051/208] x86/fpu: Remove 'struct task_struct' usage from __thread_fpu_begin() Ingo Molnar
2015-05-05 16:24 ` [PATCH 052/208] x86/fpu: Open code PF_USED_MATH usages Ingo Molnar
2015-05-05 16:24 ` [PATCH 053/208] x86/fpu: Document fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:24 ` [PATCH 054/208] x86/fpu: Get rid of PF_USED_MATH usage, convert it to fpu->fpstate_active Ingo Molnar
2015-05-06  0:51   ` Andy Lutomirski
2015-05-06  3:24     ` Ingo Molnar
2015-05-05 16:24 ` [PATCH 055/208] x86/fpu: Remove 'struct task_struct' usage from drop_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 056/208] x86/fpu: Remove task_disable_lazy_fpu_restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 057/208] x86/fpu: Use 'struct fpu' in fpu_lazy_restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 058/208] x86/fpu: Use 'struct fpu' in restore_fpu_checking() Ingo Molnar
2015-05-05 16:24 ` [PATCH 059/208] x86/fpu: Use 'struct fpu' in fpu_reset_state() Ingo Molnar
2015-05-05 16:24 ` [PATCH 060/208] x86/fpu: Use 'struct fpu' in switch_fpu_prepare() Ingo Molnar
2015-05-05 16:24 ` [PATCH 061/208] x86/fpu: Use 'struct fpu' in switch_fpu_finish() Ingo Molnar
2015-05-05 16:24 ` [PATCH 062/208] x86/fpu: Move __save_fpu() into fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 063/208] x86/fpu: Use 'struct fpu' in __fpu_save() Ingo Molnar
2015-05-05 16:24 ` [PATCH 064/208] x86/fpu: Use 'struct fpu' in fpu__save() Ingo Molnar
2015-05-05 16:24 ` [PATCH 065/208] x86/fpu: Use 'struct fpu' in fpu_copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 066/208] x86/fpu: Use 'struct fpu' in fpu__copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 067/208] x86/fpu: Use 'struct fpu' in fpstate_alloc_init() Ingo Molnar
2015-05-05 16:24 ` [PATCH 068/208] x86/fpu: Use 'struct fpu' in fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:24 ` [PATCH 069/208] x86/fpu: Rename fpu__flush_thread() to fpu__clear() Ingo Molnar
2015-05-05 16:24 ` [PATCH 070/208] x86/fpu: Clean up fpu__clear() a bit Ingo Molnar
2015-05-05 16:24 ` [PATCH 071/208] x86/fpu: Rename i387.h to fpu/api.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 072/208] x86/fpu: Move xsave.h to fpu/xsave.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 073/208] x86/fpu: Rename fpu-internal.h to fpu/internal.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 074/208] x86/fpu: Move MXCSR_DEFAULT " Ingo Molnar
2015-05-05 16:24 ` [PATCH 075/208] x86/fpu: Remove xsave_init() __init obfuscation Ingo Molnar
2015-05-05 16:24 ` [PATCH 076/208] x86/fpu: Remove assembly guard from asm/fpu/api.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 077/208] x86/fpu: Improve FPU detection kernel messages Ingo Molnar
2015-05-05 16:24 ` [PATCH 078/208] x86/fpu: Print supported xstate features in human readable way Ingo Molnar
2015-05-05 16:24 ` [PATCH 079/208] x86/fpu: Rename 'pcntxt_mask' to 'xfeatures_mask' Ingo Molnar
2015-05-05 17:14 ` [PATCH 000/208] big x86 FPU code rewrite Linus Torvalds
2015-05-05 17:50   ` Ingo Molnar
2015-07-17 23:52     ` Andy Lutomirski

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=1430843228-13749-36-git-send-email-mingo@kernel.org \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.