Backport: FPU testing / switchtest issue to 3.2 stable
cover Backport: FPU testing / switchtest issue to 3.2 stable
Hi all,
this is the backport of the previously pulished FPU testing cleanup. As 3.2 stable branch still supports ipipe and ipipe allows us to use the FPU in kernel space (in user task context) we have to deal with the problem differently.
The x86 fpu test relied on getting a clean fpu state (created by fninit), but there was no guarantee that this initialization happened which was uncovered when stressing server grade hardware with stress-ng and running the xenomai testsuite in parallel.
3.1 stable is also affected. I'm currently working on an additional backport to that branch.
Best regards,
Florian
Florian Bezdeka (2):
x86: ipipe: Fix testing issue due to uninitialized FPU
x86: ipipe: Enable FPU tests unconditionally
.../arm/dovetail/include/asm/xenomai/fptest.h | 4 ++++ .../arm/ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../dovetail/include/asm/xenomai/fptest.h | 4 ++++ .../arm64/ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../x86/dovetail/include/asm/xenomai/fptest.h | 4 ++++ .../x86/ipipe/include/asm/xenomai/fptest.h | 20 ++++++------------- kernel/drivers/testing/switchtest.c | 4 +++- 8 files changed, 33 insertions(+), 15 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/2 x86: ipipe: Fix testing issue due to uninitialized FPU
On x86 fp_regs_set() expects that the FPU state was initialized by calling the fninit instruction. When running the tests in kernel space in task context there is no guarantee that the FPU was initialized so under heavy load / scheduling the test might fail and report a FPU register corruption.
The new introduced fp_init() takes care of the FPU initialization. We call it before fp_regs_set() in task context and re-use it for the kernel context as well.
As the affected fptest.h exists for every ipipe/dovetail architecture combination we have to touch all of those.
--- .../cobalt/arch/arm/dovetail/include/asm/xenomai/fptest.h | 4 ++++ kernel/cobalt/arch/arm/ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../arch/arm64/dovetail/include/asm/xenomai/fptest.h | 4 ++++ .../cobalt/arch/arm64/ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../cobalt/arch/powerpc/ipipe/include/asm/xenomai/fptest.h | 4 ++++ .../cobalt/arch/x86/dovetail/include/asm/xenomai/fptest.h | 4 ++++ kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h | 7 ++++++- kernel/drivers/testing/switchtest.c | 4 +++- 8 files changed, 33 insertions(+), 2 deletions(-)
kernel/cobalt/arch/arm/dovetail/include/asm/xenomai/fptest.h +4 -0
@@ -35,6 +35,10 @@ static inline int fp_kernel_supported(void)return 0 ; } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {return -ENOSYS ;
kernel/cobalt/arch/arm/ipipe/include/asm/xenomai/fptest.h +4 -0
@@ -35,6 +35,10 @@ static inline int fp_kernel_supported(void)return 1 ; } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {return -ENOSYS ;
kernel/cobalt/arch/arm64/dovetail/include/asm/xenomai/fptest.h +4 -0
@@ -18,6 +18,10 @@ static inline int fp_kernel_supported(void)return 0 ; } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {return -ENOSYS ;
kernel/cobalt/arch/arm64/ipipe/include/asm/xenomai/fptest.h +4 -0
@@ -30,6 +30,10 @@ static inline int fp_kernel_supported(void)return 0 ; } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {return -ENOSYS ;
kernel/cobalt/arch/powerpc/ipipe/include/asm/xenomai/fptest.h +4 -0
@@ -41,6 +41,10 @@ static inline int fp_kernel_supported(void)#endif /* !CONFIG_PPC_FPU */ } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {return -ENOSYS ;
kernel/cobalt/arch/x86/dovetail/include/asm/xenomai/fptest.h +4 -0
@@ -35,6 +35,10 @@ static inline int fp_kernel_supported(void)return 0 ; } +static inline void fp_init (void ) +{ +} +static inline int fp_linux_begin (void ) {kernel_fpu_begin ();
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +6 -1
@@ -29,6 +29,11 @@ static inline int fp_kernel_supported(void)return 1 ; } +static inline void fp_init (void ) +{ + __asm__ __volatile__("fninit" ); +} +static inline int fp_linux_begin (void ) {#if defined(CONFIG_X86_USE_3DNOW ) \
@@ -48,7 +53,7 @@ static inline int fp_linux_begin(void)/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so initialize it here. */ - __asm__ __volatile__("fninit" ); +fp_init ();return 0 ; }
kernel/drivers/testing/switchtest.c +3 -1
@@ -416,8 +416,10 @@ static void rtswitch_ktask(void *cookie)rtswitch_pend_rt (ctx, task->base.index);while (!rtdm_task_should_stop ()) { -if (task->base.flags &RTTST_SWTEST_USE_FPU ) +if (task->base.flags &RTTST_SWTEST_USE_FPU ) { +fp_init ();fp_regs_set (fp_features, task->base.index + i *1000 ); + }switch (i %3 ) {case 0 :
Signature · 1 line
2.35.3
PATCH 2/2 x86: ipipe: Enable FPU tests unconditionally
In reply to Florian BezdekaParts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
- CONFIG_X86_USE_3DNOW
- CONFIG_MD_RAID456
- CONFIG_MD_RAID456_MODULE
As the FPU initialization is fixed now, we can enable the tests unconditionally.
--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0 -13
@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ; -printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ; -#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so
Signature · 1 line
2.35.3
Re: [PATCH 2/2] x86: ipipe: Enable FPU tests unconditionally
Quoted 29 lines · Florian Bezdeka
Parts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
-CONFIG_X86_USE_3DNOW
-CONFIG_MD_RAID456
-CONFIG_MD_RAID456_MODULEAs the FPU initialization is fixed now, we can enable the tests unconditionally.
Signed-off-by Florian Bezdeka <[email protected]>--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-6@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ;
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h static inline void fp_init(void) · line 41
Quoted 10 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-7-printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ; -#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so
Hmm, I'm not yet fully convinced from reading both commit logs that the one fix actually obsoletes this check. Did it really only paper over a simple bug?
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Re: [PATCH 2/2] x86: ipipe: Enable FPU tests unconditionally
Quoted 36 lines · Jan Kiszka
Quoted 35 lines · Florian Bezdeka
Parts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
-CONFIG_X86_USE_3DNOW
-CONFIG_MD_RAID456
-CONFIG_MD_RAID456_MODULEAs the FPU initialization is fixed now, we can enable the tests unconditionally.
Signed-off-by Florian Bezdeka <[email protected]>--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-12@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ; -printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ;
Quoted 8 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h static inline void fp_init(void) · line 41
Quoted 4 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-1-#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so Hmm, I'm not yet fully convinced from reading both commit logs that the one fix actually obsoletes this check. Did it really only paper over a simple bug?
I don't have the full history here, but it seems that this was kind of double protection.
So far all tests did not bring up any further issues.
On systems with RAID (=systems with one of the mentioned options enabled) FPU usage is much more likely and bugs would trigger more likely. I would like to enable the FPU systems especially on such systems.
But: In case we have more undiscovered bugs in this area, it might happen that we damage a RAID based file system. It seems Gilles had such a system and tried to prevent FS damage this way.
Quoted 3 lines
Jan
Jan Kiszka
AppliedRe: [PATCH 2/2] x86: ipipe: Enable FPU tests unconditionally
Quoted 51 lines · Florian (T CED SES-DE)
Quoted 36 lines · Jan Kiszka
Quoted 35 lines · Florian Bezdeka
Parts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
-CONFIG_X86_USE_3DNOW
-CONFIG_MD_RAID456
-CONFIG_MD_RAID456_MODULEAs the FPU initialization is fixed now, we can enable the tests unconditionally.
Signed-off-by Florian Bezdeka <[email protected]>--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-12@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ; -printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ;Quoted 8 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h static inline void fp_init(void) · line 41
Quoted 4 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-1-#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so Hmm, I'm not yet fully convinced from reading both commit logs that the one fix actually obsoletes this check. Did it really only paper over a simple bug?
I don't have the full history here, but it seems that this was kind of double protection.
So far all tests did not bring up any further issues.
Quoted 9 lines
On systems with RAID (=systems with one of the mentioned options enabled) FPU usage is much more likely and bugs would trigger more likely. I would like to enable the FPU systems especially on such systems.
But: In case we have more undiscovered bugs in this area, it might happen that we damage a RAID based file system. It seems Gilles had such a system and tried to prevent FS damage this way.
OK, it's just a test setup in the end - let's dare it.
Applied both to stable/v3.2.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Re: [PATCH 2/2] x86: ipipe: Enable FPU tests unconditionally
Quoted 57 lines · Jan Kiszka
Quoted 56 lines · Florian (T CED SES-DE)
Quoted 36 lines · Jan Kiszka
Quoted 35 lines · Florian Bezdeka
Parts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
-CONFIG_X86_USE_3DNOW
-CONFIG_MD_RAID456
-CONFIG_MD_RAID456_MODULEAs the FPU initialization is fixed now, we can enable the tests unconditionally.
Signed-off-by Florian Bezdeka <[email protected]>--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-12@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ; -printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ;Quoted 8 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h static inline void fp_init(void) · line 41
Quoted 4 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-1-#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so Hmm, I'm not yet fully convinced from reading both commit logs that the one fix actually obsoletes this check. Did it really only paper over a simple bug?
I don't have the full history here, but it seems that this was kind of double protection.
So far all tests did not bring up any further issues.
On systems with RAID (=systems with one of the mentioned options enabled) FPU usage is much more likely and bugs would trigger more likely. I would like to enable the FPU systems especially on such systems.
Quoted 8 lines
Quoted 4 lines
But: In case we have more undiscovered bugs in this area, it might happen that we damage a RAID based file system. It seems Gilles had such a system and tried to prevent FS damage this way.
OK, it's just a test setup in the end - let's dare it.
Applied both to stable/v3.2.
I have prepared backports for stable/v3.1.x and stable/v3.0.x as well. If there is interest I could easily send them out. I was just waiting for feedback to avoid reworking them all.
Do we try to keep the stable branches "synchronized" even for testing issues?
Quoted 3 lines
Jan
Re: [PATCH 2/2] x86: ipipe: Enable FPU tests unconditionally
Quoted 63 lines · Florian (T CED SES-DE)
Quoted 62 lines · Jan Kiszka
Quoted 60 lines · Florian (T CED SES-DE)
Quoted 36 lines · Jan Kiszka
Quoted 35 lines · Florian Bezdeka
Parts of the FPU tests were skipped when one of the following config options was enabled, shadowing a real test issue that was triggered by high load on the system. The options:
-CONFIG_X86_USE_3DNOW
-CONFIG_MD_RAID456
-CONFIG_MD_RAID456_MODULEAs the FPU initialization is fixed now, we can enable the tests unconditionally.
Signed-off-by Florian Bezdeka <[email protected]>--- .../arch/x86/ipipe/include/asm/xenomai/fptest.h | 13 ------------- 1 file changed, 13 deletions(-)kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-12@@ -36,19 +36,6 @@ static inline void fp_init(void)static inline int fp_linux_begin (void ) { -#if defined(CONFIG_X86_USE_3DNOW ) \ - || defined(CONFIG_MD_RAID456 ) || defined(CONFIG_MD_RAID456_MODULE ) -/* Ther kernel uses x86 FPU, we can not also use it in our tests. */ -static int once =0 ; -if (!once) { - once =1 ; -printk ("%s:%d: Warning: Linux is compiled to use FPU in " -"kernel-space.\nFor this reason, switchtest can not " -"test using FPU in Linux kernel-space.\n" , - __FILE__, __LINE__); - } -return -EBUSY ;Quoted 8 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h static inline void fp_init(void) · line 41
Quoted 4 lines
kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/fptest.h +0
-1-#endif /* 3DNow or RAID 456 */ kernel_fpu_begin ();/* kernel_fpu_begin() does no re-initialize the fpu context, but fp_regs_set() implicitely expects an initialized fpu context, so Hmm, I'm not yet fully convinced from reading both commit logs that the one fix actually obsoletes this check. Did it really only paper over a simple bug?
I don't have the full history here, but it seems that this was kind of double protection.
So far all tests did not bring up any further issues.
On systems with RAID (=systems with one of the mentioned options enabled) FPU usage is much more likely and bugs would trigger more likely. I would like to enable the FPU systems especially on such systems.
But: In case we have more undiscovered bugs in this area, it might happen that we damage a RAID based file system. It seems Gilles had such a system and tried to prevent FS damage this way.
Quoted 7 lines
Quoted 3 lines
OK, it's just a test setup in the end - let's dare it.
Applied both to stable/v3.2.
I have prepared backports for stable/v3.1.x and stable/v3.0.x as well. If there is interest I could easily send them out. I was just waiting for feedback to avoid reworking them all.
Great, please share then.
Quoted 3 lines
Do we try to keep the stable branches "synchronized" even for testing issues?
More or less. In this case, 3.2 could rush forward first, though, as there is no testing on next.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux