Skip to contentSkip to conversation

cobalt/x86: fix condition in eager fpu code for kernels < 4.14

PATCH Superseded Henning Schild 3 participants 8 messages Dec 21, 2018 – Jan 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cobalt/x86: fix condition in eager fpu code for kernels < 4.14

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
 kernel/cobalt/arch/x86/thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +1 -1
index a09560075..0c6054338 100644
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
 	switch_fpu_finish(&current->thread.fpu, smp_processor_id());
 #else
 	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (&current->thread.fpu.fpregs_active)
 		fpregs_deactivate(&current->thread.fpu);
 #endif
 }
Signature · 1 line
2.19.2
#1 lore raw
Quoted 18 lines · Henning Schild via Xenomai

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
  kernel/cobalt/arch/x86/thread.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..0c6054338 100644

kernel/cobalt/arch/x86/thread.c void xnarch_leave_root(struct xnthread *root) · line 478

Quoted 5 lines
kernel/cobalt/arch/x86/thread.c +1 -1
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
  	switch_fpu_finish(&current->thread.fpu, smp_processor_id());
  #else
  	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (&current->thread.fpu.fpregs_active)

Well, if you had used fpregs_active() here, you would have resolved also the second bug of that line (which I only spotted now):
"if (&something)" is always true...

Jan

Quoted 4 lines
kernel/cobalt/arch/x86/thread.c +0 -0
  		fpregs_deactivate(&current->thread.fpu);
  #endif
  }
#2 lore raw
Quoted 24 lines · Jan Kiszka via Xenomai
Quoted 23 lines · Henning Schild via Xenomai

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does
actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
  kernel/cobalt/arch/x86/thread.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..0c6054338 100644
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
   	switch_fpu_finish(&current->thread.fpu,
 smp_processor_id());
   #else
Quoted 8 lines

kernel/cobalt/arch/x86/thread.c void xnarch_leave_root(struct xnthread *root) · line 478

Quoted 3 lines
kernel/cobalt/arch/x86/thread.c +1 -1
   	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (&current->thread.fpu.fpregs_active)

Well, if you had used fpregs_active() here, you would have resolved also the
second bug of that line (which I only spotted now):
"if (&something)" is always true...

Hi,

I'm trying this fix, I'll report results.

Regards
Mauro

Quoted 9 lines

Jan

Quoted 4 lines
kernel/cobalt/arch/x86/thread.c +0 -0
   		fpregs_deactivate(&current->thread.fpu);
   #endif

  }

#3 lore raw

PATCH v2 1/1 cobalt/x86: fix condition in eager fpu code for kernels < 4.14

In reply to Henning Schild

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
 kernel/cobalt/arch/x86/thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +1 -1
index a09560075..ba807ac1e 100644
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
 	switch_fpu_finish(&current->thread.fpu, smp_processor_id());
 #else
 	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (fpregs_active())
 		fpregs_deactivate(&current->thread.fpu);
 #endif
 }
Signature · 1 line
2.19.2
#4 lore raw
Quoted 20 lines · Henning Schild

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does
actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
 kernel/cobalt/arch/x86/thread.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..ba807ac1e 100644

kernel/cobalt/arch/x86/thread.c void xnarch_leave_root(struct xnthread *root) · line 481

Quoted 8 lines
kernel/cobalt/arch/x86/thread.c +1 -1
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
  	switch_fpu_finish(&current->thread.fpu, smp_processor_id());
  #else
  	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (fpregs_active())
  		fpregs_deactivate(&current->thread.fpu);
  #endif
  }

Hi all,

I tried to launch xeno-test several times under same previous conditions and I confirm that this patch fixes the bug.

A side note: would not #include in kernel/cobalt/arch/x86/thread.c lines 47,48 and 54 be redundant with same includes in kernel/cobalt/arch/x86/include/asm/xenomai/thread.h (that is indirectly included in thread.c)?

Thanks, regards
Mauro

#5 lore raw

Am Tue, 8 Jan 2019 15:17:11 +0100
schrieb Mauro Salvini <[email protected]>:

Quoted 32 lines · Henning Schild
Quoted 25 lines

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does
actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
 kernel/cobalt/arch/x86/thread.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..ba807ac1e 100644
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
  	switch_fpu_finish(&current->thread.fpu,

smp_processor_id()); #else
  /* mark current thread as not owning the FPU anymore */

kernel/cobalt/arch/x86/thread.c +1 -1
-	if (&current->thread.fpu.fpstate_active)
+	if (fpregs_active())
Quoted 3 lines

  fpregs_deactivate(&current->thread.fpu); #endif
 }

Hi all,

Quoted 2 lines

I tried to launch xeno-test several times under same previous conditions and I confirm that this patch fixes the bug.

Good to hear, thanks!

Quoted 4 lines

A side note: would not #include in kernel/cobalt/arch/x86/thread.c lines 47,48 and 54 be redundant with same includes in kernel/cobalt/arch/x86/include/asm/xenomai/thread.h (that is indirectly included in thread.c)?

The latter does not have those includes. It is still very possible that there are a few too many but that is what you have inclusion guards for. And the code you are looking at 47,48 and 54 is all to support legacy/old kernels. You are in the IPIPE_X86_FPU_EAGER case.

Henning

Quoted 2 lines

Thanks, regards
Mauro

#6 lore raw
Quoted 48 lines · Henning Schild

Am Tue, 8 Jan 2019 15:17:11 +0100
schrieb Mauro Salvini <[email protected]>:

Quoted 33 lines · Henning Schild
Quoted 26 lines

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it
does
actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
 kernel/cobalt/arch/x86/thread.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..ba807ac1e 100644
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
  	switch_fpu_finish(&current->thread.fpu,

smp_processor_id()); #else
  /* mark current thread as not owning the FPU anymore */

kernel/cobalt/arch/x86/thread.c +1 -1
-	if (&current->thread.fpu.fpstate_active)
+	if (fpregs_active())
Quoted 3 lines

  fpregs_deactivate(&current->thread.fpu); #endif
 }

Hi all,

Quoted 2 lines

I tried to launch xeno-test several times under same previous conditions and I confirm that this patch fixes the bug.

Good to hear, thanks!

Quoted 6 lines

A side note: would not #include in kernel/cobalt/arch/x86/thread.c lines 47,48 and 54 be redundant with
same includes in kernel/cobalt/arch/x86/include/asm/xenomai/thread.h (that is indirectly included in thread.c)?

Quoted 5 lines

The latter does not have those includes. It is still very possible that there are a few too many but that is what you have inclusion guards
for. And the code you are looking at 47,48 and 54 is all to support legacy/old kernels. You are in the IPIPE_X86_FPU_EAGER case.

Yes, sorry, I wanted to write kernel/cobalt/arch/x86/include/asm/xenomai/wrappers.h

Anyway no problem to have them in both files.

Regards
Mauro

Quoted 7 lines

Henning

Quoted 2 lines

Thanks, regards
Mauro

Applied
#7 lore raw
In reply to Henning Schild
Quoted 19 lines · Henning Schild via Xenomai

From: Henning Schild <[email protected]>

We should mark the current task as not owning the fpu anymore if it does actually own the fpu, not if the fpu itself is active.

Fixes cb52e6c7438fa

---
  kernel/cobalt/arch/x86/thread.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/arch/x86/thread.c +0 -0
index a09560075..ba807ac1e 100644

kernel/cobalt/arch/x86/thread.c void xnarch_leave_root(struct xnthread *root) · line 481

Quoted 8 lines
kernel/cobalt/arch/x86/thread.c +1 -1
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)
  	switch_fpu_finish(&current->thread.fpu, smp_processor_id());
  #else
  	/* mark current thread as not owning the FPU anymore */
-	if (&current->thread.fpu.fpstate_active)
+	if (fpregs_active())
  		fpregs_deactivate(&current->thread.fpu);
  #endif
  }

Thanks, applied it next.

Jan