cobalt/x86: fix condition in eager fpu code for kernels < 4.14
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
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)switch_fpu_finish (¤t->thread.fpu,smp_processor_id ());#else /* mark current thread as not owning the FPU anymore */ -if (¤t->thread.fpu.fpstate_active) +if (¤t->thread.fpu.fpregs_active)fpregs_deactivate (¤t->thread.fpu);#endif }
Signature · 1 line
2.19.2
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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>--- kernel/cobalt/arch/x86/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0
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 (¤t->thread.fpu,smp_processor_id ());#else /* mark current thread as not owning the FPU anymore */ -if (¤t->thread.fpu.fpstate_active) +if (¤t->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
-0fpregs_deactivate (¤t->thread.fpu);#endif }
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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>---
kernel/cobalt/arch/x86/thread.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root) switch_fpu_finish(¤t->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 (¤t->thread.fpu.fpstate_active) +if (¤t->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
-0fpregs_deactivate(¤t->thread.fpu); #endif}
PATCH v2 1/1 cobalt/x86: fix condition in eager fpu code for kernels < 4.14
In reply to Henning SchildFrom: 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
@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root)switch_fpu_finish (¤t->thread.fpu,smp_processor_id ());#else /* mark current thread as not owning the FPU anymore */ -if (¤t->thread.fpu.fpstate_active) +if (fpregs_active ())fpregs_deactivate (¤t->thread.fpu);#endif }
Signature · 1 line
2.19.2
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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>---
kernel/cobalt/arch/x86/thread.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0
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(¤t->thread.fpu, smp_processor_id()); #else /* mark current thread as not owning the FPU anymore */ -if (¤t->thread.fpu.fpstate_active) +if (fpregs_active ()) fpregs_deactivate(¤t->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
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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>---
kernel/cobalt/arch/x86/thread.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root) switch_fpu_finish(¤t->thread.fpu,
smp_processor_id()); #else
/* mark current thread as not owning the FPU anymore */kernel/cobalt/arch/x86/thread.c +1
-1-if (¤t->thread.fpu.fpstate_active) +if (fpregs_active ())Quoted 3 lines
fpregs_deactivate(¤t->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 inthread.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
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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>---
kernel/cobalt/arch/x86/thread.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0@@ -475,7 +475,7 @@ void xnarch_leave_root(struct xnthread *root) switch_fpu_finish(¤t->thread.fpu,
smp_processor_id()); #else
/* mark current thread as not owning the FPU anymore */kernel/cobalt/arch/x86/thread.c +1
-1-if (¤t->thread.fpu.fpstate_active) +if (fpregs_active ())Quoted 3 lines
fpregs_deactivate(¤t->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 inkernel/cobalt/arch/x86/include/asm/xenomai/thread.h(that is indirectly included inthread.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 theIPIPE_X86_FPU_EAGERcase.
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
Jan Kiszka
AppliedQuoted 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
cb52e6c7438faReported-by Mauro Salvini <[email protected]>Signed-off-by Henning Schild <[email protected]>--- kernel/cobalt/arch/x86/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/cobalt/arch/x86/thread.c +0
-0
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 (¤t->thread.fpu,smp_processor_id ());#else /* mark current thread as not owning the FPU anymore */ -if (¤t->thread.fpu.fpstate_active) +if (fpregs_active ())fpregs_deactivate (¤t->thread.fpu);#endif }
Thanks, applied it next.
Jan