[PATCH v1 4/4] x86/fpu: Remove the unnecessary fpstate_reset() invocation

Chang S. Bae posted 4 patches 2 years, 7 months ago
[PATCH v1 4/4] x86/fpu: Remove the unnecessary fpstate_reset() invocation
Posted by Chang S. Bae 2 years, 7 months ago
fpstate_reset() initializes the fpstate container. But, when no state
has been established yet, calling this is not meaningful. In the
fpu__init_system() function, it is called immediately after the legacy
FPU size is determined. So, remove it as not causing any issues.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
---

The change made by fpstate_reset() can be measured with this:

static struct fpstate fps;

void __init fpu__init_system(struct cpuinfo_x86 *c)
{
	memcpy(&fps, &current->thread.fpu.__fpstate, sizeof(struct fpstate));
	fpstate_reset(&current->thread.fpu);
	if (memcmp(&fps, &current->thread.fpu.__fpstate, sizeof(struct fpstate)))
		pr_info("fpstate has reason to be inited at %s\n", __func__);
	else
		pr_info("fpstate has no reason to be inited at %s\n", __func__);
	...
}

Although it looks to be a no-op, there might be some unknown
intention behind it. If there is a specific reason for invoking
fpstate_reset() at that point, this should be documented properly
instead of removing it.
---
 arch/x86/kernel/fpu/init.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 998a08f17e33..95af3084c4cf 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -213,7 +213,6 @@ static void __init fpu__init_system_xstate_size_legacy(void)
  */
 void __init fpu__init_system(void)
 {
-	fpstate_reset(&current->thread.fpu);
 	fpu__init_system_early_generic();
 
 	/*
-- 
2.34.1