Rép. : Re: [Xenomai-help] Switch mode with x86
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR
(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)
Quoted 5 lines
and it seems to work better, one hour without blocking, it's a record for me.
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.
I'm not sure to understand how the prio boost work. Can someone explain ?
thanks
blanchard nicolas
Quoted 13 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 3 lines
and it seems to work better, one hour without blocking, it's a record for me.
Quoted 6 lines
Quoted 1 line
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.
Confirmed!
[email protected] :/root# cat /proc/xenomai/sched
CPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2
So far "only" on real hardware (P-I 133) with CONFIG_M586 and (this is likely also very important) CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.
Jan
Quoted 24 lines · Jan Kiszka
Quoted 13 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 3 lines
and it seems to work better, one hour without blocking, it's a record for me.
Quoted 6 lines
Quoted 1 line
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/sched
Quoted 9 lines
CPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.
Please also try moving task2 to the SCHED_FIFO class to see if things evolve.
Quoted 6 lines
Jan
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 28 lines · Philippe Gerum
Quoted 27 lines · Jan Kiszka
Quoted 10 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 8 lines
Quoted 4 lines
and it seems to work better, one hour without blocking, it's a record for me.
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/schedCPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2
Quoted 7 lines
Quoted 4 lines
So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.Please also try moving task2 to the
SCHED_FIFOclass to see if things evolve.
No difference:
[email protected] :/root# cat /proc/xenomai/sched
CPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 829 99 9999312 0 X TASK1 0 830 1 3002894 0 R TASK2
qemu over my notebook is somehow too fast to reproduce the race, I'm now instrumenting the target.
Jan
Quoted 24 lines · Jan Kiszka
Quoted 13 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 3 lines
and it seems to work better, one hour without blocking, it's a record for me.
Quoted 6 lines
Quoted 1 line
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/sched
Quoted 9 lines
CPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.
I did not jump on that initially, but if task2 is supposedly in ready state, then there must be a rescheduling missing somewhere, maybe task2 trying to migrate to primary mode, and for some reason, no rescheduling took place on behalf of the gatekeeper. It would be interesting to know the output of /proc/xenomai/stat, to get the full task states.
Quoted 6 lines
Jan
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 28 lines · Philippe Gerum
Quoted 27 lines · Jan Kiszka
Quoted 10 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 8 lines
Quoted 4 lines
and it seems to work better, one hour without blocking, it's a record for me.
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/schedCPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2
Quoted 8 lines
Quoted 4 lines
So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.Please also try moving task2 to the
SCHED_FIFOclass to see if things evolve.
Here is the Xenomai scheduling sequence that leads to the deadlock. I raised the frequency of TASK2 a bit, and this seems to accelerate the lock-up.
...
Quoted 5 lines
:| *+[ 844] TASK2 1 -5061+ 4.436 xnpod_resume_thread+0x48 (gatekeeper_thread+0xf7) :| *+[ 827] sshd -1 -5055+ 4.015 xnpod_schedule_runnable+0x45 (gatekeeper_thread+0x12e) :| # [ 827] sshd -1 -5015+ 6.646 xnpod_schedule+0x81 (xnpod_schedule_handler+0x17) :| # [ 844] TASK2 1 -4981+ 3.721 xnpod_schedule+0x81 (xnpod_suspend_thread+0x1e4) :| # [ 75] gatekee -1 -4971+ 6.451 xnpod_schedule+0x7a2 (xnpod_schedule_handler+0x17)
So far everything is fine. Now the thrilling parts start:
Quoted 9 lines
:| # [ 844] TASK2 1 -2992+ 9.954 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # [ 75] gatekee -1 -2978! 13.759 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # [ 844] TASK2 1 -2955+ 7.842 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # [ 843] TASK1 99 -2858+ 7.977 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # [ 844] TASK2 1 -2848+ 8.466 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # [ 843] TASK1 99 -2831+ 4.421 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # [ 843] TASK1 99 -2789+ 4.315 xnpod_schedule_runnable+0x45 (xnshadow_relax+0xd9) :| # [ 843] TASK1 99 -2777+ 6.932 xnpod_schedule+0x81 (xnpod_suspend_thread+0x1e4) :| # [ 827] sshd 99 -2762+ 4.917 xnpod_schedule+0x7a2 (xnintr_irq_handler+0xec)
The trace captured almost 200 further milliseconds, but no more switching takes place (full dump available on request).
So we have
TASK2 resume -> TASK2 relax -> TASK1 resume/TASK2 preempted -> TASK2 relax -> Lock-up
Gilles, are we able to produce such a sequence with the switchtest?
OK, it's time now to think a bit about what we see here. Any ideas welcome.
Jan
PS: Here are the stats you asked for, Philippe:
CPU PID MSW CSW PF STAT %CPU NAME 0 0 0 5493 0 01400080 99.1 ROOT 0 843 646 1294 0 00c00180 0.0 TASK1 0 844 2152 4337 0 00c00088 0.0 TASK2 0 0 0 689962 0 00000000 0.9 IRQ0: [timer]
Quoted 38 lines · Jan Kiszka
Quoted 28 lines · Philippe Gerum
Quoted 27 lines · Jan Kiszka
Quoted 10 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 8 lines
Quoted 4 lines
and it seems to work better, one hour without blocking, it's a record for me.
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/schedCPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2Quoted 8 lines
Quoted 4 lines
So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.Please also try moving task2 to the
SCHED_FIFOclass to see if things evolve.
Quoted 7 lines
Here is the Xenomai scheduling sequence that leads to the deadlock. I raised the frequency of TASK2 a bit, and this seems to accelerate the lock-up.
...
Quoted 2 lines
:| *+[ 844] TASK2 1 -5061+ 4.436 xnpod_resume_thread+0x48 (gatekeeper_thread+0xf7) :| *+[ 827] sshd -1 -5055+ 4.015 xnpod_schedule_runnable+0x45 (gatekeeper_thread+0x12e)
Damnit. What about this?
nucleus/shadow.c renamed from nucleus/shadow.c~ +0 -3
@@ -551,9 +551,6 @@ thread->sched =xnpod_sched_slot (cpu);#endif /* CONFIG_SMP */ xnpod_resume_thread (thread,XNRELAX ); -#ifndef CONFIG_XENO_OPT_RPIDISABLE -xnpod_renice_root (XNPOD_ROOT_PRIO_BASE ); -#endif /* CONFIG_XENO_OPT_RPIDISABLE */ #ifdef CONFIG_XENO_OPT_ISHIELD disengage_irq_shield ();#endif /* CONFIG_XENO_OPT_ISHIELD */
Signature · 1 line
Philippe.
Quoted 51 lines · Philippe Gerum
Quoted 33 lines · Jan Kiszka
Quoted 32 lines · Philippe Gerum
Quoted 31 lines · Jan Kiszka
Quoted 10 lines · Nicolas BLANCHARD
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 8 lines
Quoted 4 lines
and it seems to work better, one hour without blocking, it's a record for me.
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/schedCPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK1 0 838 0 10999998 0 R TASK2So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.Quoted 10 lines
Quoted 3 lines
Please also try moving task2 to the
SCHED_FIFOclass to see if things evolve.Here is the Xenomai scheduling sequence that leads to the deadlock. I raised the frequency of TASK2 a bit, and this seems to accelerate the lock-up.
...
Quoted 2 lines
:| *+[ 844] TASK2 1 -5061+ 4.436 xnpod_resume_thread+0x48 (gatekeeper_thread+0xf7) :| *+[ 827] sshd -1 -5055+ 4.015 xnpod_schedule_runnable+0x45 (gatekeeper_thread+0x12e)Damnit. What about this?
nucleus/shadow.c line 556
Quoted 9 lines
nucleus/shadow.c renamed from nucleus/shadow.c~ +0
-3@@ -551,9 +551,6 @@ thread->sched =xnpod_sched_slot (cpu);#endif /* CONFIG_SMP */ xnpod_resume_thread (thread,XNRELAX ); -#ifndef CONFIG_XENO_OPT_RPIDISABLE -xnpod_renice_root (XNPOD_ROOT_PRIO_BASE ); -#endif /* CONFIG_XENO_OPT_RPIDISABLE */ #ifdef CONFIG_XENO_OPT_ISHIELD disengage_irq_shield ();#endif /* CONFIG_XENO_OPT_ISHIELD */
Stalls on relaxing TASK1:
CPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 831 99 10000000 0 R TASK1 0 832 1 11000000 0 R TASK2
My excerpt may have suggested a priority adjustment bug, but there is non. When TASK2 is resumed, the currently running root thread still has prio -1, all correct.
But here is the full trace of the problematic path:
Quoted 45 lines
:| # [ 844] TASK2 1 -2992+ 9.954 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # func -2982+ 3.368 xnpod_schedule+0xe (xnintr_irq_handler+0xec) :| # [ 75] gatekee -1 -2978! 13.759 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # func -2965+ 2.285 __switch_to+0xb (xnpod_schedule+0x6ce) :| # func -2962+ 7.879 debug_smp_processor_id+0x9 (__switch_to+0x1e) :| # [ 844] TASK2 1 -2955+ 7.842 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # func -2947! 39.947 __ipipe_restore_pipeline_head+0x8 (xnpod_wait_thread_period+0x1a8) : + func -2907+ 2.406 __ipipe_syscall_root+0x9 (system_call+0x20) : + func -2904+ 2.857 __ipipe_dispatch_event+0xe (__ipipe_syscall_root+0x73) : + func -2902+ 4.375 hisyscall_event+0xe (__ipipe_dispatch_event+0x82) : + func -2897+ 2.225 xnshadow_relax+0xe (hisyscall_event+0x1ed) : + func -2895+ 2.330 schedule_linux_call+0xe (xnshadow_relax+0x7d) :| # func -2893+ 2.962 __ipipe_restore_pipeline_head+0x8 (schedule_linux_call+0xaf) : + func -2890+ 2.323 rthal_apc_schedule+0x8 (schedule_linux_call+0xb9) : + func -2887+ 3.511 __ipipe_schedule_irq+0xa (rthal_apc_schedule+0x31) :| + func -2884+ 2.240 __ipipe_handle_irq+0xe (common_interrupt+0x18) :| + func -2882+ 1.639 __ipipe_ack_common_irq+0xa (__ipipe_handle_irq+0x80) :| + func -2880+ 2.067 ipipe_test_and_stall_pipeline_from+0x8 (__ipipe_ack_common_irq+0x16) :| # func -2878+ 2.879 mask_and_ack_8259A+0xb (__ipipe_ack_common_irq+0x3e) :| + func -2875+ 2.812 __ipipe_dispatch_wired+0xe (__ipipe_handle_irq+0x8a) :| # func -2872+ 1.759 xnintr_clock_handler+0x8 (__ipipe_dispatch_wired+0x7d) :| # func -2870+ 1.969 xnintr_irq_handler+0xe (xnintr_clock_handler+0x17) :| # func -2868+ 1.864 xnpod_announce_tick+0x8 (xnintr_irq_handler+0x39) :| # func -2867+ 3.052 xntimer_do_tick_aperiodic+0xe (xnpod_announce_tick+0xf) :| # func -2863+ 2.511 xnthread_periodic_handler+0x8 (xntimer_do_tick_aperiodic+0x7b) :| # func -2861+ 2.789 xnpod_resume_thread+0xe (xnthread_periodic_handler+0x28) :| # [ 843] TASK1 99 -2858+ 7.977 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # func -2850+ 2.270 xnpod_schedule+0xe (xnintr_irq_handler+0xec) :| # [ 844] TASK2 1 -2848+ 8.466 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # func -2839+ 1.751 __switch_to+0xb (xnpod_schedule+0x6ce) :| # func -2838+ 6.593 debug_smp_processor_id+0x9 (__switch_to+0x1e) :| # [ 843] TASK1 99 -2831+ 4.421 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # func -2827! 17.894 __ipipe_restore_pipeline_head+0x8 (xnpod_wait_thread_period+0x1a8) : + func -2809+ 2.360 __ipipe_syscall_root+0x9 (system_call+0x20) : + func -2806+ 2.210 __ipipe_dispatch_event+0xe (__ipipe_syscall_root+0x73) : + func -2804+ 3.458 hisyscall_event+0xe (__ipipe_dispatch_event+0x82) : + func -2801+ 2.421 xnshadow_relax+0xe (hisyscall_event+0x1ed) : + func -2798+ 2.691 schedule_linux_call+0xe (xnshadow_relax+0x7d) :| # func -2796+ 1.984 __ipipe_restore_pipeline_head+0x8 (schedule_linux_call+0xaf) : + func -2794+ 2.631 rthal_apc_schedule+0x8 (schedule_linux_call+0xb9) :| # func -2791+ 2.180 xnpod_schedule_runnable+0xe (xnshadow_relax+0xd9) :| # [ 843] TASK1 99 -2789+ 4.315 xnpod_schedule_runnable+0x45 (xnshadow_relax+0xd9) :| # func -2785+ 5.593 xnpod_suspend_thread+0xe (xnshadow_relax+0x104) :| # func -2779+ 2.045 xnpod_schedule+0xe (xnpod_suspend_thread+0x1e4) :| # [ 843] TASK1 99 -2777+ 6.932 xnpod_schedule+0x81 (xnpod_suspend_thread+0x1e4)
Quoted 8 lines
:| # func -2770+ 2.368 __switch_to+0xb (xnpod_schedule+0x6ce) :| # func -2768+ 5.736 debug_smp_processor_id+0x9 (__switch_to+0x1e) :| # [ 827] sshd 99 -2762+ 4.917 xnpod_schedule+0x7a2 (xnintr_irq_handler+0xec) :| +func -2757+ 3.744 __ipipe_walk_pipeline+0xe (__ipipe_handle_irq+0x182) :| +func -2753+ 2.135 __ipipe_unstall_iret_root+0x8 (restore_raw+0x0) : +func -2751+ 2.360 tcp_cong_avoid+0xa (tcp_ack+0x14d3) : +func -2749+ 5.909 bictcp_cong_avoid+0xb (tcp_cong_avoid+0x1b) : +func -2743+ 2.496 __kfree_skb+0xa (tcp_rcv_established+0x109)
This indicates that we face an I-pipe bug: the scheduled Linux call on relaxation of TASK2 and then later TASK1 somehow gets lost (there is no rthal_apc_handler in the remaining trace).
Jan
Quoted 79 lines · Jan Kiszka
Quoted 37 lines · Philippe Gerum
Quoted 35 lines · Jan Kiszka
Quoted 18 lines · Nicolas BLANCHARD
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Nicolas BLANCHARD" <[email protected]> 29.11 11:25 >>>
Hello,
I've tested wiith Xenomai 2.3-rc2 (adeos 1.5-02)
and change the config :
-CONFIG_M586
- disableCONFIG_INPUT_PCSPKR(it was on module)
Quoted 1 line
- disable prio boosting (check
CONFIG_XENO_OPT_RPDISALBLE)Quoted 3 lines
and it seems to work better, one hour without blocking, it's a record for me.
Quoted 6 lines
Quoted 1 line
So, i will investigate to find which modification improve my problem.
After somes tests (kernel compil), it seems that prio boost is responsable of my
problem. When it's disable (kernel option checked) my program run correctly.Confirmed!
[email protected] :/root# cat
/proc/xenomai/schedCPU PID PRI PERIOD TIMEOUT STAT NAME 0 0 99 0 0 R ROOT 0 837 99 9999312 0 X TASK10 838 0 10999998 0 R TASK2
Quoted 8 lines
Quoted 4 lines
So far "only" on real hardware (P-I 133) with
CONFIG_M586and (this is likely also very important)CONFIG_PREEMPT. I'm now about to check if I can migrate this problem into qemu and/or capture it with the I-pipe tracer.Please also try moving task2 to the
SCHED_FIFOclass to see if things evolve.Here is the Xenomai scheduling sequence that leads to the deadlock. I raised the frequency of TASK2 a bit, and this seems to accelerate the lock-up.
...
Quoted 5 lines
:| *+[ 844] TASK2 1 -5061+ 4.436 xnpod_resume_thread+0x48 (gatekeeper_thread+0xf7) :| *+[ 827] sshd -1 -5055+ 4.015 xnpod_schedule_runnable+0x45 (gatekeeper_thread+0x12e) :| # [ 827] sshd -1 -5015+ 6.646 xnpod_schedule+0x81 (xnpod_schedule_handler+0x17) :| # [ 844] TASK2 1 -4981+ 3.721 xnpod_schedule+0x81 (xnpod_suspend_thread+0x1e4) :| # [ 75] gatekee -1 -4971+ 6.451 xnpod_schedule+0x7a2 (xnpod_schedule_handler+0x17)So far everything is fine. Now the thrilling parts start:
Quoted 9 lines
:| # [ 844] TASK2 1 -2992+ 9.954 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # [ 75] gatekee -1 -2978! 13.759 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # [ 844] TASK2 1 -2955+ 7.842 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # [ 843] TASK1 99 -2858+ 7.977 xnpod_resume_thread+0x48 (xnthread_periodic_handler+0x28) :| # [ 844] TASK2 1 -2848+ 8.466 xnpod_schedule+0x81 (xnintr_irq_handler+0xec) :| # [ 843] TASK1 99 -2831+ 4.421 xnpod_schedule+0x7a2 (xnpod_suspend_thread+0x1e4) :| # [ 843] TASK1 99 -2789+ 4.315 xnpod_schedule_runnable+0x45 (xnshadow_relax+0xd9) :| # [ 843] TASK1 99 -2777+ 6.932 xnpod_schedule+0x81 (xnpod_suspend_thread+0x1e4) :| # [ 827] sshd 99 -2762+ 4.917 xnpod_schedule+0x7a2 (xnintr_irq_handler+0xec)The trace captured almost 200 further milliseconds, but no more switching takes place (full dump available on request).
Quoted 6 lines
So we have
TASK2 resume -> TASK2 relax -> TASK1 resume/TASK2 preempted -> TASK2 relax -> Lock-up
Gilles, are we able to produce such a sequence with the switchtest?
Probably not, with switchtest, only the task that is currently switching is running, all other tasks are suspended.
Signature · 1 line
Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
...
This indicates that we face an I-pipe bug: the scheduled Linux call on relaxation of TASK2 and then later TASK1 somehow gets lost (there is northal_apc_handlerin the remaining trace).
I think I got it. No I-pipe bug, but one in the HAL.
What happened? A weird race caused by the unprotected optimisation to only call rthal_schedule_irq() if there is no APC pending yet. This is the constellation I finally worked out via instrumenting and tracing:
PRIO 1:rthal_apc_schedule()
test&set rthal_apc_pending
(but no rthal_schedule_irq() yet)
-PREEMPTION-
PRIO 99:
...
rthal_apc_schedule()
test rthal_apc_pending
(already set => no
rthal_schedule_irq()!)So, no one reported the ACP to I-pipe, and no one ever will in Nicolas scenario - soft lock-up!
Nicolas, please give the attached patch a try. Your test is running fine for me now.
At this chance: do we need rthal_apc_schedule() returning the previous state at all? No current caller checks the return value. If it's OK to clean this up, I will post a combined patch.
Jan
arch/generic/hal.c +6 -5
@@ -596,18 +596,19 @@ int rthal_apc_free(int apc)int rthal_apc_schedule (int apc) { rthal_declare_cpuid; +int ret =1 ;if (apc <0 || apc >=RTHAL_NR_APCS )return -EINVAL ;rthal_load_cpuid ();/* Migration would be harmless here. */ -if (!test_and_set_bit (apc, &rthal_apc_pending[cpuid])) { -rthal_schedule_irq (rthal_apc_virq); -return 1 ; - } +if (test_and_set_bit (apc, &rthal_apc_pending[cpuid])) + ret =0 ;/* Already pending. */ + +rthal_schedule_irq (rthal_apc_virq); -return 0 ;/* Already pending. */ +return ret; }#ifdef CONFIG_PROC_FS
Quoted 29 lines · Jan Kiszka
Quoted 4 lines · Jan Kiszka
...
This indicates that we face an I-pipe bug: the scheduled Linux call on relaxation of TASK2 and then later TASK1 somehow gets lost (there is northal_apc_handlerin the remaining trace).I think I got it. No I-pipe bug, but one in the HAL.
What happened? A weird race caused by the unprotected optimisation to only call
rthal_schedule_irq()if there is no APC pending yet. This is the constellation I finally worked out via instrumenting and tracing:PRIO 1:
rthal_apc_schedule()
test&setrthal_apc_pending
(but northal_schedule_irq()yet)-PREEMPTION- PRIO 99: ... rthal_apc_schedule() test rthal_apc_pending (already set => no rthal_schedule_irq()!)So, no one reported the ACP to I-pipe, and no one ever will in Nicolas scenario - soft lock-up!
Quoted 7 lines
Nicolas, please give the attached patch a try. Your test is running fine for me now.
At this chance: do we need
rthal_apc_schedule()returning the previous state at all? No current caller checks the return value. If it's OK to clean this up, I will post a combined patch.
It's pointless to return this info, the caller would not be able to exploit it in any way.
Could you please try this other form of your fix? This would prevent the virq to be fired twice (or more) uselessly, with no request pending. Masking interrupts to enforce atomicity is ok here, since rthal_schedule_irq() will run this way in any case. Additionally, my comment about migration was suspicious, I do see a case where CPU migration would leave this code in limbos. But to get the cpuid properly, we need the local interrupts to be masked first. TIA,
generic/hal.c +13 -7
@@ -596,18 +596,24 @@int rthal_apc_schedule (int apc) { rthal_declare_cpuid; +unsigned long flags; +int ret =0 ;if (apc <0 || apc >=RTHAL_NR_APCS ) -return -EINVAL ; +return -EINVAL ; -rthal_load_cpuid ();/* Migration would be harmless here. */ +rthal_local_irq_save (flags); -if (!test_and_set_bit (apc, &rthal_apc_pending[cpuid])) { -rthal_schedule_irq (rthal_apc_virq); -return 1 ; - } +rthal_load_cpuid (); -return 0 ;/* Already pending. */ +if (__test_and_set_bit (apc, &rthal_apc_pending[cpuid])) + ret =1 ; +else +rthal_schedule_irq (rthal_apc_virq); + +rthal_local_irq_restore (flags); + +return ret; }#ifdef CONFIG_PROC_FS
Signature · 1 line
Philippe.
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Jan Kiszka
...
This indicates that we face an I-pipe bug: the scheduled Linux call on relaxation of TASK2 and then later TASK1 somehow gets lost (there is northal_apc_handlerin the remaining trace).
Quoted 6 lines
I think I got it. No I-pipe bug, but one in the HAL.
What happened? A weird race caused by the unprotected optimisation to only call
rthal_schedule_irq()if there is no APC pending yet. This is the constellation I finally worked out via instrumenting and tracing:
Btw, really nice spot. This one was really bad to the bone. Thanks.
Signature · 1 line
Philippe.
Quoted 40 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 4 lines · Jan Kiszka
...
This indicates that we face an I-pipe bug: the scheduled Linux call on relaxation of TASK2 and then later TASK1 somehow gets lost (there is northal_apc_handlerin the remaining trace).I think I got it. No I-pipe bug, but one in the HAL.
What happened? A weird race caused by the unprotected optimisation to only call
rthal_schedule_irq()if there is no APC pending yet. This is the constellation I finally worked out via instrumenting and tracing:PRIO 1:
rthal_apc_schedule()
test&setrthal_apc_pending
(but northal_schedule_irq()yet)-PREEMPTION- PRIO 99: ... rthal_apc_schedule() test rthal_apc_pending (already set => no rthal_schedule_irq()!)So, no one reported the ACP to I-pipe, and no one ever will in Nicolas scenario - soft lock-up!
Quoted 7 lines
Nicolas, please give the attached patch a try. Your test is running fine for me now.
At this chance: do we need
rthal_apc_schedule()returning the previous state at all? No current caller checks the return value. If it's OK to clean this up, I will post a combined patch.It's pointless to return this info, the caller would not be able to exploit it in any way.
Quoted 7 lines
Could you please try this other form of your fix? This would prevent the virq to be fired twice (or more) uselessly, with no request pending. Masking interrupts to enforce atomicity is ok here, since
rthal_schedule_irq()will run this way in any case. Additionally, my comment about migration was suspicious, I do see a case where CPU migration would leave this code in limbos. But to get the cpuid properly, we need the local interrupts to be masked first. TIA,
Yes, works fine as well.
Then go for the attached fix+cleanup?
Jan
arch/generic/hal.c +10 -8
@@ -565,7 +565,7 @@ int rthal_apc_free(int apc)/** * @fn int rthal_apc_schedule (int apc) -* +* * @brief Schedule an APC invocation. * * This service marks the APC as pending for the Linux domain, so that
@@ -580,8 +580,7 @@ int rthal_apc_free(int apc)* * @param apc The APC id. to schedule. * -* @return 0 or 1 are returned upon success, the former meaning that -* the APC was already pending. Otherwise: +* @return 0 is returned upon success. Otherwise: * * - -EINVAL is returned if @a apc is invalid. *
@@ -596,18 +595,21 @@ int rthal_apc_free(int apc)int rthal_apc_schedule (int apc) { rthal_declare_cpuid; +unsigned long flags;if (apc <0 || apc >=RTHAL_NR_APCS )return -EINVAL ; -rthal_load_cpuid ();/* Migration would be harmless here. */ +rthal_local_irq_save (flags); + +rthal_load_cpuid (); -if (!test_and_set_bit (apc, &rthal_apc_pending[cpuid])) { +if (!__test_and_set_bit (apc, &rthal_apc_pending[cpuid]))rthal_schedule_irq (rthal_apc_virq); -return 1 ; - } -return 0 ;/* Already pending. */ +rthal_local_irq_restore (flags); + +return 0 ; }#ifdef CONFIG_PROC_FS
Quoted 3 lines · Jan Kiszka
Yes, works fine as well.
Then go for the attached fix+cleanup?
Yes, please apply to both v2.2.x maintenance and trunk. TIA,
Signature · 1 line
Philippe.