NMI watchdog: Loading of xeno_native leads to reboot of PC
Subsystems (2)
Hi!
Before digging deeper into the issue I have mailed yesterday (see below), I have to solve and to understand the NMI watchdog feature.
I have enabled the NMI watchdog in the kernel configuration and set the time value to 100 now (100us). Also, I passed the nmi_watchdog=1 kernel parameter to GRUB.
In dmesg's output I see the line:
Testing NMI watchdog ... OK.
The Xenomai functionality is compiled as modules (as far as it is possible).
Now, I do a
modprobe xeno_nucleus
This looks fine.
Now, I do a
modprobe xeno_native
to load the native skin (I need it for my application to run). Then the PC reboots directly.
This means I have no chance to start my application as the PC reboots before I can start it...
I have the impression that some important thing is missing in my test. The xeno timer is not started after modprobe xenu_nucleus The contents of /proc/timer is:
status=off:setup=120:tickval=0:jiffies=0
Could this be a reason for the behaviour?
Can I start the timer before loading xeno_native to avoid the NMIs?
Thanks for all help on this topic as without this feature it seems to be impossible to detect the bug/issue with a freezing system with the latest Xenomai/rtnet and kernel 2.6.19.1. (see https://mail.gna.org/public/xenomai-help/2006-12/msg00109.html)
Regards
Mathias
----- Original Nachricht ----
Von: Gilles Chanteperdrix <[email protected]> An: "M. Koehrer" <[email protected]> Datum: 18.12.2006 16:32 Betreff: Re: Aw: Re: Aw: Re: [RTnet-users] [Xenomai-help] rtnet / Xenomai:
Kernel
Quoted 36 lines
Quoted 7 lines · M. Koehrer
O.k,
I tried once more with the NMI watchdog stuff.
However, it looks as if I do not understand the NMI watchdog correctly... I passed nmi_watchdog=1 as kernel parameter.
Now, the NMI watchdog seems to be o.k.
I have set the kernel parameter "NMI watchdog latency threshold (us)" to1000000 (1 second).
Quoted 9 lines
Now I do a modprobe
xeno_nucleus.
This is o.k.
Then I do a modprobexeno_native.
This leads to a watchdog NMI on the console after 1s. "NMI watchdog detected timer latency above 100000us" CPU 1
EIP is atmwait_idle0x23/0x37When I compile the Xenomai functionality directly into the kernel (no
modules), I never reach
Quoted 3 lines
the login prompt at my PC as the NMI watchdog from above came first...
Well, somehow the NMI stuff seems to work. However, I am not able to start
my application
Quoted 1 line
as my systems gets the NMI before I have the chance to start the
application...
Quoted 3 lines
What is wrong here? I think, I miss one piece in the puzzle...
Thanks for any support on that strange behaviour.
1 second is probably way to much and overflow a 32 bits value when converted to a processor ticks count. The defaults of 100 us is more reasonable.
Signature · 1 line
Gilles Chanteperdrix
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 22 lines · M. Koehrer
Hi!
Before digging deeper into the issue I have mailed yesterday (see below), I have to solve and to understand the NMI watchdog feature.
I have enabled the NMI watchdog in the kernel configuration and set the time value to 100 now (100us). Also, I passed the nmi_watchdog=1 kernel parameter to GRUB.
In dmesg's output I see the line:
Testing NMI watchdog ... OK.The Xenomai functionality is compiled as modules (as far as it is possible).
Now, I do a
modprobexeno_nucleus
This looks fine.Now, I do a
modprobexeno_native
to load the native skin (I need it for my application to run). Then the PC reboots directly.
This means I have no chance to start my application as the PC reboots before I can start it...
Quoted 6 lines
I have the impression that some important thing is missing in my test. The xeno timer is not started after modprobe
xenu_nucleusThe contents of/proc/timeris:
status=off:setup=120:tickval=0:jiffies=0Could this be a reason for the behaviour?
That's normal, it is started on loading the first skin.
Quoted 1 line
Can I start the timer before loading
xeno_nativeto avoid the NMIs?
Nope, the NMI must work as you tried to use it. I have basically the same setup here (all modular, NMI on by default), but even with latest kernel/ipipe everything is fine.
Could you post your .config to compare details? Also the output of /proc/interrupts over .19 would be interesting.
Jan
Re: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to
Hi Jan,
here is my /proc/interrupts
CPU0
0: 331260 IO-APIC-edge timer 1: 8 IO-APIC-edge i8042 7: 0 IO-APIC-edge parport0 9: 0 IO-APIC-fasteoi acpi 14: 12 IO-APIC-edge ide0 16: 1022 IO-APIC-fasteoi eth0 19: 2358 IO-APIC-fasteoi libata NMI: 331248 LOC: 331233 ERR: 0 MIS: 0
I have enclosed a config.gz file of my 2.6.19.1 kernel.
Mathias
Quoted 44 lines
Quoted 1 line
Before digging deeper into the issue I have mailed yesterday (see below),
I have to solve and
Quoted 2 lines
to understand the NMI watchdog feature.
I have enabled the NMI watchdog in the kernel configuration and set thetime value to 100 now (100us).
Quoted 5 lines
Also, I passed the nmi_watchdog=1 kernel parameter to GRUB. In dmesg's output I see the line:
Testing NMI watchdog ... OK.The Xenomai functionality is compiled as modules (as far as it is
possible).
Quoted 10 lines
Now, I do a
modprobexeno_nucleus
This looks fine.Now, I do a
modprobexeno_native
to load the native skin (I need it for my application to run). Then the PC reboots directly.
This means I have no chance to start my application as the PC rebootsbefore
Quoted 8 lines
I can start it...
I have the impression that some important thing is missing in my test. The xeno timer is not started after modprobe
xenu_nucleusThe contents of/proc/timeris:
status=off:setup=120:tickval=0:jiffies=0Could this be a reason for the behaviour?
That's normal, it is started on loading the first skin.
Quoted 1 line
Can I start the timer before loading
xeno_nativeto avoid the NMIs?Nope, the NMI must work as you tried to use it. I have basically the same setup here (all modular, NMI on by default), but even with latest kernel/ipipe everything is fine.
Could you post your .config to compare details? Also the output of
/proc/interruptsover .19 would be interesting.Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to
Quoted 5 lines · M. Koehrer
Hi Jan,
here is my
/proc/interruptsCPU0
Quoted 11 lines
0: 331260 IO-APIC-edge timer 1: 8 IO-APIC-edge i8042 7: 0 IO-APIC-edge parport0 9: 0 IO-APIC-fasteoi acpi 14: 12 IO-APIC-edge ide0 16: 1022 IO-APIC-fasteoi eth0 19: 2358 IO-APIC-fasteoi libata NMI: 331248 LOC: 331233 ERR: 0 MIS: 0
Nothing unusual on first sight.
Quoted 2 lines
I have enclosed a config.gz file of my 2.6.19.1 kernel.
Two things to try:
- CONFIG_XENO_HW_NMI_DEBUG_LATENCY_MAX=100 (i.e. default again)
- CONFIG_PROFILING=y (I'm not sure ATM if it may interfere with Xenomai's watchdog)
Jan
Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to
Hi!
I have modified the configuration to disable profiling and to set the NMI time value to 100. However, there is no difference.
Could this be a compiler issue?
I am using gcc 4.1.2 (debian etch prerelease)
I try to recompile the kernel using an older gcc-3.3 to see if this helps.
Regards
Mathias
Quoted 28 lines
Quoted 14 lines
here is my
/proc/interruptsCPU0
0: 331260 IO-APIC-edge timer 1: 8 IO-APIC-edge i8042 7: 0 IO-APIC-edge parport0 9: 0 IO-APIC-fasteoi acpi 14: 12 IO-APIC-edge ide0 16: 1022 IO-APIC-fasteoi eth0 19: 2358 IO-APIC-fasteoi libata NMI: 331248 LOC: 331233 ERR: 0 MIS: 0Nothing unusual on first sight.
Quoted 2 lines
I have enclosed a config.gz file of my 2.6.19.1 kernel.
Two things to try:
-CONFIG_XENO_HW_NMI_DEBUG_LATENCY_MAX=100(i.e. default again)
-CONFIG_PROFILING=y(I'm not sure ATM if it may interfere with Xenomai's watchdog)Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
Hi!
It was the compiler!!! Using gcc-3.3 solved the issue.
That means, that somehow gcc-4.1.2 must not be used with Xenomai currently...
This allowed me to catch the system hang I was hunting for since yesterday...
And I got it.
I write the information I found on the console (I have not tried with console redirection yet...). CPU 0, eip c010122d
EIP 0060:[<c010122d>]
EFLAGS 00000246
EIP is at mwait_idle_with_hints+0x2c/0x2e
eax:0 ebx:c0498000 ecx:0 edx:0
Call Trace
mwait_idle+0x0/0x2e mwait_idle+0x1d/0x2e cpu_idle+0x44/0x86 start_kernel+0x1f1/0x1f5 unknown_bootoption+0x0/0x191
I'll try to reproduce the same with console redirection, however, I hope this could help already!
Regards
Mathias
Quoted 52 lines
Hi!
I have modified the configuration to disable profiling and to set the NMI time value to 100.
However, there is no difference.
Could this be a compiler issue?
I am using gcc 4.1.2 (debian etch prerelease)
I try to recompile the kernel using an older gcc-3.3 to see if this helps.Regards
Mathias
Quoted 28 lines
Quoted 14 lines
here is my
/proc/interruptsCPU0
0: 331260 IO-APIC-edge timer 1: 8 IO-APIC-edge i8042 7: 0 IO-APIC-edge parport0 9: 0 IO-APIC-fasteoi acpi 14: 12 IO-APIC-edge ide0 16: 1022 IO-APIC-fasteoi eth0 19: 2358 IO-APIC-fasteoi libata NMI: 331248 LOC: 331233 ERR: 0 MIS: 0Nothing unusual on first sight.
Quoted 2 lines
I have enclosed a config.gz file of my 2.6.19.1 kernel.
Two things to try:
-CONFIG_XENO_HW_NMI_DEBUG_LATENCY_MAX=100(i.e. default again)
-CONFIG_PROFILING=y(I'm not sure ATM if it may interfere with Xenomai's watchdog)Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to
In reply to M. KoehrerQuoted 6 lines · M. Koehrer
Hi!
I have modified the configuration to disable profiling and to set the NMI time value to 100. However, there is no difference.
Could this be a compiler issue?
I am using gcc 4.1.2 (debian etch prerelease)
My feeling is no (I'm using 4.1 here, .2 should only fix regressions in theory).
Quoted 1 line
I try to recompile the kernel using an older gcc-3.3 to see if this helps.
After that let us forget about the NMI for a while and check if the soft watchdog + CONFIG_XENO_OPT_DEBUG_NUCLEUS may already reveal some detail of the RTnet issue.
Jan
Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
In reply to M. KoehrerQuoted 4 lines · M. Koehrer
Hi!
It was the compiler!!! Using gcc-3.3 solved the issue.
That means, that somehow gcc-4.1.2 must not be used with Xenomai currently...
OK, this needs some examination then. Can anyone reproduce this issue? /me is currently lacking the compiler.
Quoted 10 lines
This allowed me to catch the system hang I was hunting for since yesterday...
And I got it.
I write the information I found on the console (I have not tried with console redirection yet...). CPU 0, eipc010122d
EIP 0060:[<c010122d>]
EFLAGS 00000246
EIP is atmwait_idle_with_hints+0x2c/0x2e
eax:0 ebx:c0498000 ecx:0 edx:0
Quoted 6 lines
Call Trace
mwait_idle+0x0/0x2e mwait_idle+0x1d/0x2e cpu_idle+0x44/0x86 start_kernel+0x1f1/0x1f5 unknown_bootoption+0x0/0x191
Well, this caught your box in the idle loop - not that informative yet. We must probably look beyond the last context switch. Please switch on the I-pipe tracer (kernel hacking -> I-pipe debugging) and configure back_trace_points to, hmm, say 200. On NMI alarm, we should then see a function call trace.
Quoted 6 lines
I'll try to reproduce the same with console redirection, however, I hope this could help already!
Regards
Mathias
Thanks for your effort,
Jan
Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
Hi Jan,
I tried to enable the kernel hacking parameters you proposed. However, now I get a "NMI early shots: 0" message many times per second. These seems to slow down everything dramatically, it is hard to work with the system. What are the early shots messages and how can I avoid them?
Regards
Mathias
Quoted 45 lines
Quoted 2 lines
It was the compiler!!! Using gcc-3.3 solved the issue. That means, that somehow gcc-4.1.2 must not be used with Xenomai
currently...
OK, this needs some examination then. Can anyone reproduce this issue? /me is currently lacking the compiler.
Quoted 2 lines
This allowed me to catch the system hang I was hunting for since
yesterday...
Quoted 2 lines
And I got it.
I write the information I found on the console (I have not tried withconsole redirection yet...).
Quoted 6 lines
CPU 0, eip
c010122d
EIP 0060:[<c010122d>]
EFLAGS 00000246
EIP is atmwait_idle_with_hints+0x2c/0x2e
eax:0 ebx:c0498000 ecx:0 edx:0Quoted 6 lines
Call Trace
mwait_idle+0x0/0x2e mwait_idle+0x1d/0x2e cpu_idle+0x44/0x86 start_kernel+0x1f1/0x1f5 unknown_bootoption+0x0/0x191Well, this caught your box in the idle loop - not that informative yet. We must probably look beyond the last context switch. Please switch on the I-pipe tracer (kernel hacking -> I-pipe debugging) and configure
back_trace_pointsto, hmm, say 200. On NMI alarm, we should then see a function call trace.Quoted 2 lines
I'll try to reproduce the same with console redirection, however, I hope
this could help already!
Quoted 4 lines
Regards
Mathias
Thanks for your effort,
Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
Quoted 6 lines · M. Koehrer
Hi Jan,
I tried to enable the kernel hacking parameters you proposed. However, now I get a "NMI early shots: 0" message many times per second. These seems to slow down everything dramatically, it is hard to work with the system. What are the early shots messages and how can I avoid them?
Normally, when you see "NMI early shots: 0", your system is about to panic. I guess the reason why your system is able to recover from this situation is because you enabled the watchdog. What would be interesting would be to know what is printed right after "NMI early shots: 0", it may be significant, if not, simply disable the NMI watchdog, maybe it does not work properly on your machine.
Signature · 1 line
Gilles Chanteperdrix
Re: Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
In reply to M. KoehrerQuoted 6 lines · M. Koehrer
Hi Jan,
I tried to enable the kernel hacking parameters you proposed. However, now I get a "NMI early shots: 0" message many times per second. These seems to slow down everything dramatically, it is hard to work with the system. What are the early shots messages and how can I avoid them?
My feeling is that the issue you saw with gcc-4.1.2 is still unsolved, just the recompilation made some stuff move around. Now, with additional features activated, the issue seems to pop up again in a different way.
So again my suggestion: forget about the NMI for a while, check if we can make progress with other debugging switches.
Further question to tighten the test case: do the basic Xenomai testsuite programs run without noticeable problems on your box?
Jan
Aw: Re: Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads...
Hi Jan,
I think you are right.
The NMI watchdog (Realtime) kernel parameter in the kernel configuration was accidentally disabled (perhaps because I tried in between with a non-APIC IRQ). Now I have again the error situation of this morning:
Even with gcc-3.3 I am not able to load the xeno_native module when NMI watchdog is enabled, the system directly reboots (without printing to the serial console) The printout I have sent before was the printout of the standard linux NMI but not of the Xenomai NMI.
I.e., it seems _not_ to be the reason of the compiler that leads to the behaviour!
Regards
Mathias
Quoted 22 lines
Quoted 5 lines · M. Koehrer
Hi Jan,
I tried to enable the kernel hacking parameters you proposed. However, now I get a "NMI early shots: 0" message many times per second. These seems to slow down everything dramatically, it is hard to work with
the
Quoted 1 line
system. What are the early shots messages and how can I avoid them?
My feeling is that the issue you saw with gcc-4.1.2 is still unsolved, just the recompilation made some stuff move around. Now, with additional features activated, the issue seems to pop up again in a different way.
So again my suggestion: forget about the NMI for a while, check if we can make progress with other debugging switches.
Further question to tighten the test case: do the basic Xenomai testsuite programs run without noticeable problems on your box?
Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] A fairly small rtnet/Xenomai application that freezes the PC
In reply to Jan KiszkaHi Jan and Gilles,
after a long debug-reboot-try-again-session I was able to reduce the problem I had to a very short application that leads to a complete system freeze on a 2.6.19.1 kernel. As with my PC I am not able to run the NMI stuff within Xenomai, I forward the application to you and the list. Perhaps somebody can try out the enclosed application with the latest Xenomai version on 2.6.19.1.
Please adjust the IP settings in the C file and in the xenorun script to your setup. It is sufficient to send out UDP frames, if the remote device does not answer this does not hurt. However the remote device should listen on a specified port to avoid ICMP complains about no-opened UDP ports...
Using Ethereal I monitored the traffic.
Here is the summary of it:
ARP request/response (from the xenorun script)
ARP request/response (from the applicaion)
UDP message to port 18765 (no answer)
2 seconds later: UDP message to port 18765 (no answer)
2+5=7 seconds later: ARP request/response (from the application)
2 seconds later: UDP message to port 18765
Here the system freezes. I do not see the message "Step A".
One important piece is the system() call out of the realtime application to do a rtroute. When I remove this call, there is no error...
I am using Xenomai SVN #1969 and the included 2.6.19.1 patch. Pentium 4 UP.
Any feedback on this is highly welcome!
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the PC
Quoted 7 lines · M. Koehrer
Hi Jan and Gilles,
after a long debug-reboot-try-again-session I was able to reduce the problem I had to a very short application that leads to a complete system freeze on a 2.6.19.1 kernel. As with my PC I am not able to run the NMI stuff within Xenomai, I forward the application to you and the list. Perhaps somebody can try out the enclosed application with the latest Xenomai version on 2.6.19.1.
Thanks for the test case, I will give this a try ASAP.
Quoted 5 lines
Please adjust the IP settings in the C file and in the xenorun script to your setup. It is sufficient to send out UDP frames, if the remote device does not answer this does not hurt. However the remote device should listen on a specified port to avoid ICMP complains about no-opened UDP ports...
Using Ethereal I monitored the traffic.
Quoted 8 lines
Here is the summary of it:
ARP request/response (from the xenorun script)
ARP request/response (from the applicaion)
UDP message to port 18765 (no answer)
2 seconds later: UDP message to port 18765 (no answer) 2+5=7 seconds later: ARP request/response (from the application) 2 seconds later: UDP message to port 18765
Here the system freezes. I do not see the message "Step A".
Could you set me the Ethereal dump for reference? Just in case the test does not kick immediately for me and I need to check the event flow.
Quoted 6 lines
One important piece is the
system()call out of the realtime application to do a rtroute. When I remove this call, there is no error...I am using Xenomai SVN #1969 and the included 2.6.19.1 patch. Pentium 4 UP.
Do you have a different (slower) execution platform at hand to check if the CPU speed as influence on the lock-up? I hope it is not the case - makes tracking easier. But it wouldn't be the first time.
Quoted 3 lines
Any feedback on this is highly welcome!
You will get it.
Thanks again,
Jan
[Xenomai-help] Aw: Re: A fairly small rtnet/Xenomai application that freezes the PC
Hi Jan,
enclosed is the ethereal dump file.
Unfortunately I do not have a slow machine... (We try to get the fastest machines running...).
Thanks for checking the application.
Mathias
Quoted 55 lines
Quoted 1 line
after a long debug-reboot-try-again-session I was able to reduce the
problem I had
Quoted 1 line
to a very short application that leads to a complete system freeze on a
2.6.19.1 kernel.
Quoted 1 line
As with my PC I am not able to run the NMI stuff within Xenomai, I forward
the application to you
Quoted 1 line
and the list. Perhaps somebody can try out the enclosed application with
the latest Xenomai version
Quoted 1 line
on 2.6.19.1.
Thanks for the test case, I will give this a try ASAP.
Quoted 1 line
Please adjust the IP settings in the C file and in the xenorun script to
your setup.
Quoted 1 line
It is sufficient to send out UDP frames, if the remote device does not
answer this does not hurt.
Quoted 1 line
However the remote device should listen on a specified port to avoid ICMP
complains about
Quoted 10 lines
no-opened UDP ports...
Using Ethereal I monitored the traffic.
Here is the summary of it:
ARP request/response (from the xenorun script)
ARP request/response (from the applicaion)
UDP message to port 18765 (no answer)
2 seconds later: UDP message to port 18765 (no answer) 2+5=7 seconds later: ARP request/response (from the application) 2 seconds later: UDP message to port 18765
Here the system freezes. I do not see the message "Step A".Could you set me the Ethereal dump for reference? Just in case the test does not kick immediately for me and I need to check the event flow.
Quoted 2 lines
One important piece is the
system()call out of the realtime applicationto do a rtroute.
Quoted 4 lines
When I remove this call, there is no error...
I am using Xenomai SVN #1969 and the included 2.6.19.1 patch. Pentium 4
UP.
Do you have a different (slower) execution platform at hand to check if the CPU speed as influence on the lock-up? I hope it is not the case - makes tracking easier. But it wouldn't be the first time.
Quoted 3 lines
Any feedback on this is highly welcome!
You will get it.
Thanks again,
Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the
Hi Jan,
meanwhile I have done a couple of additional tests.
With one of the PCs I have, I have disabled the Memory Cache to slow it down.
The effect was the very same.
I have reproduced the behaviour on another PC (also P4, but different mainboard).
The system freezes as well.
And finally, I have found out that printing out a line with printf() directly after the system() call provides a workaround.Then the system is stable.
I have replaced the system() call where I called rtroute with a simple call to "ls -l" (i.e system("ls -l") ). Then the system freezes as well.
It looks to me as if a system() call out of the realtime task is not properly handled.
An printf() after the system() call seems to move the system back on track...
Hope that helps a little bit to identify the issue...
Regards
Mathias
Quoted 74 lines
Hi Jan,
enclosed is the ethereal dump file.
Unfortunately I do not have a slow machine... (We try to get the fastest machines running...).Thanks for checking the application.
Mathias
Quoted 5 lines
Quoted 1 line
after a long debug-reboot-try-again-session I was able to reduce the
problem I had
Quoted 1 line
to a very short application that leads to a complete system freeze on a
2.6.19.1 kernel.
Quoted 1 line
As with my PC I am not able to run the NMI stuff within Xenomai, I
forward
Quoted 2 lines
the application to you
Quoted 1 line
and the list. Perhaps somebody can try out the enclosed application
with
Quoted 6 lines
the latest Xenomai version
Quoted 1 line
on 2.6.19.1.
Thanks for the test case, I will give this a try ASAP.
Quoted 1 line
Please adjust the IP settings in the C file and in the xenorun script
to
Quoted 4 lines
your setup.
Quoted 1 line
It is sufficient to send out UDP frames, if the remote device does not
answer this does not hurt.
Quoted 1 line
However the remote device should listen on a specified port to avoid
ICMP
Quoted 12 lines
complains about
Quoted 10 lines
no-opened UDP ports...
Using Ethereal I monitored the traffic.
Here is the summary of it:
ARP request/response (from the xenorun script)
ARP request/response (from the applicaion)
UDP message to port 18765 (no answer)
2 seconds later: UDP message to port 18765 (no answer) 2+5=7 seconds later: ARP request/response (from the application) 2 seconds later: UDP message to port 18765
Here the system freezes. I do not see the message "Step A".Quoted 5 lines
Could you set me the Ethereal dump for reference? Just in case the test does not kick immediately for me and I need to check the event flow.
Quoted 2 lines
One important piece is the
system()call out of the realtimeapplication
Quoted 21 lines
to do a rtroute.
Quoted 4 lines
When I remove this call, there is no error...
I am using Xenomai SVN #1969 and the included 2.6.19.1 patch. Pentium 4
UP.
Do you have a different (slower) execution platform at hand to check if the CPU speed as influence on the lock-up? I hope it is not the case - makes tracking easier. But it wouldn't be the first time.
Quoted 3 lines
Any feedback on this is highly welcome!
You will get it.
Thanks again,
JanSignature · 2 lines
Mathias Koehrer [email protected]
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
Quoted 10 lines · M. Koehrer
Hi Jan,
meanwhile I have done a couple of additional tests.
With one of the PCs I have, I have disabled the Memory Cache to slow it down.
The effect was the very same.
I have reproduced the behaviour on another PC (also P4, but different mainboard).
The system freezes as well.
And finally, I have found out that printing out a line withprintf()directly after thesystem()call provides a workaround.Then the system is stable.
Quoted 6 lines
I have replaced the
system()call where I called rtroute with a simple call to "ls -l" (i.esystem("ls -l")). Then the system freezes as well.
It looks to me as if asystem()call out of the realtime task is not properly handled.
Anprintf()after thesystem()call seems to move the system back on track...Hope that helps a little bit to identify the issue...
Unfortunately not yet. I tried with exactly the same configuration you once mailed on a Pentium M 1.3 GHz - but all worked fine. The obvious differences are the CPU speed (I may have access to a crash box with more GHz next week) and the NIC (rt_eepro100 in my case).
As my hope of being able to reproduce it on my own is not that high, I would like to ask you to try nailing down the lock-up on kernel level. That means trying to identify (via printk e.g. - if this doesn't make the bug jump around) which function is still executed and where we do not get.
TIA,
Jan
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:
static void realtimetask(void *arg)
{
system("ls -l");
rt_task_sleep(1000000000ULL);
printf("rt_task_sleep done...\n");
}This leads to a complete freeze of the PC on a 2.6.19.1 kernel using the latest Xenomai (from SVN) and the included adeos-patch.
I never had this issue on 2.6.17.* kernel.
Unfortunately this seems to occur only on fast Pentium 4 machines... Is there anybody out there that can reproduce it?
Thanks for all feedback on this!
Mathias
Quoted 34 lines
Quoted 2 lines
meanwhile I have done a couple of additional tests.
With one of the PCs I have, I have disabled the Memory Cache to slow itdown.
Quoted 2 lines
The effect was the very same.
I have reproduced the behaviour on another PC (also P4, but differentmainboard).
Quoted 2 lines
The system freezes as well.
And finally, I have found out that printing out a line withprintf()directly after the
system()call providesQuoted 3 lines
a workaround.Then the system is stable.
I have replaced the
system()call where I called rtroute with a simplecall to "ls -l" (i.e
system("ls -l")).Quoted 2 lines
Then the system freezes as well.
It looks to me as if asystem()call out of the realtime task is notproperly handled.
Quoted 1 line
An
printf()after thesystem()call seems to move the system back ontrack...
Quoted 2 lines
Hope that helps a little bit to identify the issue...
Unfortunately not yet. I tried with exactly the same configuration you once mailed on a Pentium M 1.3 GHz - but all worked fine. The obvious differences are the CPU speed (I may have access to a crash box with more GHz next week) and the NIC (
rt_eepro100in my case).As my hope of being able to reproduce it on my own is not that high, I would like to ask you to try nailing down the lock-up on kernel level. That means trying to identify (via printk e.g. - if this doesn't make the bug jump around) which function is still executed and where we do not get.
TIA,
Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
Quoted 7 lines · M. Koehrer
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:
Quoted 6 lines
static void
realtimetask(void *arg){ system("ls -l"); rt_task_sleep(1000000000ULL); printf("rt_task_sleep done...\n"); }
Is it still true that when you place printf() right after the system() call, it works?
What happens when you try different sleep intervals : 0, say 1000 ?
Just to be sure where we are stuck. Insert exit() (or rt_task_delete(NULL)) :
(0) after system() --- if said above about printf() is not true;
(1) after rt_task_sleep();
(2) after printf("rt_task_sleep done...\n").
At which step does a hang start occuring?
Quoted 3 lines
This leads to a complete freeze of the PC on a 2.6.19.1 kernel using the latest Xenomai (from SVN) and the included adeos-patch.
I have almost the same config (only 2.6.19) at home, although it's p3 750 so I'll try if it won't be solved by this everning (or we are sure that only high-end machines are involved).
Signature · 2 lines
Best regards, Dmitry Adamushko
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to M. KoehrerQuoted 10 lines · M. Koehrer
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:static void
realtimetask(void *arg){ system("ls -l");
If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
static void fault_vm(void)
{
FILE *maps = fopen("/proc/self/maps", "r");
unsigned begin, end, pagesize=getpagesize();
char buffer[128];
int rc;
if (!maps) {
perror("fopen");
exit(EXIT_FAILURE);
}
while ((rc = fscanf(maps, "%x-%x",&begin, &end) == 2)) {
fgets(buffer, 128, maps);
if(buffer[2] != 'w')
continue;
for (; begin != end; begin += pagesize)
*(volatile int *) begin = *(volatile int *) begin;
}
fclose(maps);
}Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Dmitry AdamushkoHi Dmitry,
thanks for your response.
Quoted 4 lines
Is it still true that when you place
printf()right after thesystem()call, it works?
Yes, a printf() directly after the system() fixes the issue.
Quoted 9 lines
What happens when you try different sleep intervals : 0, say 1000 ?
Just to be sure where we are stuck. Insert
exit()(orrt_task_delete(NULL)) :(0) after
system()--- if said above aboutprintf()is not true;
(1) afterrt_task_sleep();
(2) afterprintf("rt_task_sleep done...\n").
I have added a hacky trace mechanism in the kernel to see what's happening (whenever the nmi_watchdog with the kernel oops appears).
What I can see is that rt_task_sleep(); is completely passed.
If I modify my application to add a second rt_task_sleep() directly after the existing one, I see the both rt_task_sleep() calls are passed. The freeze seems to happen with the printf() call after the rt_task_sleep. Unfortunately, I do not know where I can trace here...
Best regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the
Quoted 14 lines · M. Koehrer
Hi Dmitry,
thanks for your response.
Quoted 4 lines
Is it still true that when you place
printf()right after thesystem()call, it works?Yes, a
printf()directly after thesystem()fixes the issue.Quoted 5 lines
What happens when you try different sleep intervals : 0, say 1000 ?
Just to be sure where we are stuck. Insert
exit()(orrt_task_delete(NULL)) :
The important issue to check is the above one. Please try calling rt_task_delete(NULL), and in a second test, rt_task_suspend(NULL), instead of letting the thread routine return. TIA,
Signature · 1 line
Philippe.
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Gilles ChanteperdrixHi Gilles,
thanks for your answer.
That is quite interesting.
I have added your function and placed at call to it directly after the system() call. Then, everything works fine. However, a couple of questions come up:
1.) Why does a printf() directly after the system() seems to help aswell? I do not think, that printf cares about write protection of pages...
2.) I think, I never saw this behaviour with the 2.6.17.* kernel, only with the 2.6.19.1. Is there any difference related to that?
I will doublecheck this.
3) On Jan's PC, the issue never appears, as he has a slower PC. How can that be related to that?
4.) Could this somehow be handled by Xenomai? Well, adding the function is - in my eyes - a workaround around the issue, but I expect Xenomai to do this things for me. It needs a lot of "magic knowledge" to get this running... Another approach could be to encapsulate this somehow in the native library (and in the other libraries) and to document clearly, that fork and related functions should not be called out of the realtime task without additional cleanup code.
Anyway, this seems to be the right track!
Regards
Mathias
Quoted 16 lines
Quoted 8 lines
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:static void
realtimetask(void *arg){ system("ls -l");If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Gilles ChanteperdrixQuoted 12 lines · Gilles Chanteperdrix
Quoted 10 lines · M. Koehrer
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:static void
realtimetask(void *arg){ system("ls -l");
Quoted 6 lines
If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
Let me check if I got this correctly: fork calls mark all pages write-protected - also those of the father process, or only those of the new child? That would mean we see unexpected page faults, right? Anything more (probably not a lock-up)?
I think we should document this special property somewhere, e.g. in the wiki, maybe also a demo program in the examples repos.
Jan
[Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai
In reply to Philippe GerumHello Philippe,
Quoted 3 lines
The important issue to check is the above one. Please try calling
rt_task_delete(NULL), and in a second test,rt_task_suspend(NULL), instead of letting the thread routine return. TIA,
O.K, here are the results:
I have placed rt_task_delete() at all possible positions in realtimetask(). The system freezes when I place rt_task_delete() after the printf() statement. At all other positions (after system(), after rt_task_sleep()) the system does not freeze. I get the very same results when I use rt_task_suspend() instead of rt_task_delete().
It means, that the printf() call causes the freeze.
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the
In reply to M. KoehrerHi all,
I have doublechecked the behaviour for the 2.6.17.14 kernel. With this kernel (and the related Adeos patch provided by Xenomai) my xeno_crash application works fine without any modification or additional workaround.
Thus, I think this is an issue that is related to 2.6.19.* kernel only.
Regards
Mathias
Quoted 5 lines
2.) I think, I never saw this behaviour with the 2.6.17.* kernel, only with the
2.6.19.1. Is there any difference related to that?
I will doublecheck this.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to M. KoehrerQuoted 7 lines · M. Koehrer
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:
Quoted 6 lines
static void
realtimetask(void *arg){ system("ls -l"); rt_task_sleep(1000000000ULL); printf("rt_task_sleep done...\n"); }
Does this code freeze your box as well:
#include <native/task.h>
#include <sys/mman.h>
main()
{
RT_TASK task;
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_task_shadow(&task, "crash", 1, 0);
rt_task_sleep(1000000000ULL);
system("ls -l");
rt_task_sleep(1000000000ULL);
printf("rt_task_sleep done...\n");
}Or what is different with your test case? I got hold of P4 2.8 GHz meanwhile, but the box still prefers to run the code without troubles.
Jan
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Jan KiszkaQuoted 1 line · Jan Kiszka
Gilles Chanteperdrix wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
static void
realtimetask(void *arg){ system("ls -l");If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
Quoted 3 lines
Let me check if I got this correctly: fork calls mark all pages write-protected - also those of the father process, or only those of the new child?
It's copy-on-write policy. fork() creates a separate address space for a child (vm_struct, vm_area(s), all the page tables) but it still points to the same physical pages as parent's address space. Now what if either a child or parent want to modify writeable pages? That's why copy-on-write. A new page will be allocated when a write request is commited. And yep, to address this issue, the vm areas of (in fact, related areas in page tables) both parent and child are marked as copy-on-write.
But I don't think this is an issue here :
1) by the moment system() returns -> the child has finished and there is no need to allocate new pages on parent's write requests (not sure how linux handles it - have to check);
2) (I'd expect logically) the parent did mlockall() in advance for even future allocations, so I'd expect copy-on-write is not applicable fot it -> all the pages should have been duplicated for a child. Well, it's a brief idea. Have to check.
so it's likely that it's just a side - effect.
Mathias: if printf() helps (after system()) so could you try e.g. fopen(), fclose() instead? Also, please, do what previously was suggested with rt_task_delete(NULL) at the end.
Another situation would be if one does fork() in real-time app. and then both parent and child continue their execution (worth checking).
p.s. vfork() is a different beast. Here a child is supposed to call exec*() rigth after fork() so it's allowed to "borrow" parent's address space (vm_struct -> all vm_area(s)) and the parent is blocked in the mean time. As a result, no need for copy-on-write.
Signature · 2 lines
Best regards, Dmitry Adamushko
[Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai
In reply to M. KoehrerQuoted 5 lines · M. Koehrer
Hello Philippe,
Quoted 3 lines
The important issue to check is the above one. Please try calling
rt_task_delete(NULL), and in a second test,rt_task_suspend(NULL), instead of letting the thread routine return. TIA,
Quoted 7 lines
O.K, here are the results:
I have placedrt_task_delete()at all possible positions inrealtimetask(). The system freezes when I placert_task_delete()after theprintf()statement. At all other positions (aftersystem(), afterrt_task_sleep()) the system does not freeze. I get the very same results when I usert_task_suspend()instead ofrt_task_delete().It means, that the
printf()call causes the freeze.
just to be sure.
Could you try with other secondary domain calls (instead of printf() ) : write() (open/close as I suggested before) or even getpid() ?
(1) instead of the last code line (printf() after rt_task_sleep() ) ;
(2) put it after system(). Does it still prevent a PC from hanging?
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Dmitry AdamushkoQuoted 31 lines · Dmitry Adamushko
Quoted 1 line · Jan Kiszka
Gilles Chanteperdrix wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
static void
realtimetask(void *arg){ system("ls -l");If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
Quoted 3 lines
Let me check if I got this correctly: fork calls mark all pages write-protected - also those of the father process, or only those of the new child?
It's copy-on-write policy.
fork()creates a separate address space for a child (vm_struct,vm_area(s), all the page tables) but it still points to the same physical pages as parent's address space. Now what if either a child or parent want to modify writeable pages? That's why copy-on-write. A new page will be allocated when a write request is commited. And yep, to address this issue, the vm areas of (in fact, related areas in page tables) both parent and child are marked as copy-on-write.
Quoted 5 lines
But I don't think this is an issue here :
1) by the moment
system()returns -> the child has finished and there is no need to allocate new pages on parent's write requests (not sure how linux handles it - have to check);
After the fork and the child has returned, the pages remain write protected. A fault that would occur after that would do almost nothing, but still causes a migration to secondary mode.
Quoted 5 lines
2) (I'd expect logically) the parent did
mlockall()in advance for even future allocations, so I'd expect copy-on-write is not applicable fot it -> all the pages should have been duplicated for a child. Well, it's a brief idea. Have to check.
I have checked, mlockall has no effect on copy-on-write.
Quoted 7 lines
so it's likely that it's just a side - effect.
Mathias: if
printf()helps (aftersystem()) so could you try e.g.fopen(),fclose()instead? Also, please, do what previously was suggested withrt_task_delete(NULL)at the end.
Quoted 7 lines
Another situation would be if one does
fork()in real-time app. and then both parent and child continue their execution (worth checking).p.s.
vfork()is a different beast. Here a child is supposed to call exec*() rigth afterfork()so it's allowed to "borrow" parent's address space (vm_struct-> allvm_area(s)) and the parent is blocked in the mean time. As a result, no need for copy-on-write.
I think to remember that glibc vfork is just fork.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to Dmitry AdamushkoHi all,
some more interesing measurements:
1) Even when I remove the printf() completely, the system freezes. My realtimetask is then
static void realtimetask(void *arg)
{
system("ls -l");
rt_task_sleep(1000000000ULL);}
2) When I replace the printf() by a gepid() the behaviour is the same.
3) Jan, your application using the rt_task_shadow behaves the very same (it freezes)!
4) A getpid() directly after system does not help - however, a printf at this position helps to prevent the freeze.
But now, I found one very interesting thing:
When I rename my /lib/tls to /lib/tls.disabled, it works!!!!
It seems to be (once more) a ugly thread local storage stuff. The ldd dependency of xeno_crash show libc and libpthread that are take from /lib/tls/i686/cmov directory.
Perhaps that could give a hint!
Regards
Mathias
Quoted 31 lines
Hello Philippe,
Quoted 6 lines
Quoted 4 lines
The important issue to check is the above one. Please try calling
rt_task_delete(NULL), and in a second test,rt_task_suspend(NULL), instead of letting the thread routine return. TIA,O.K, here are the results:
I have placedrt_task_delete()at all possible positions in
realtimetask().Quoted 1 line
The system freezes when I place
rt_task_delete()after theprintf()statement.
Quoted 1 line
At all other positions (after
system(), afterrt_task_sleep()) the systemdoes not freeze.
Quoted 1 line
I get the very same results when I use
rt_task_suspend()instead of
rt_task_delete().Quoted 2 lines
It means, that the
printf()call causes the freeze.just to be sure.
Could you try with other secondary domain calls (instead of
printf()) :write()(open/close as I suggested before) or evengetpid()?(1) instead of the last code line (
printf()afterrt_task_sleep()) ;(2) put it after
system(). Does it still prevent a PC from hanging?Signature · 2 lines
Best regards, Dmitry Adamushko
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: Re: Re: A fairly small rtnet/Xenomai
Quoted 19 lines · M. Koehrer
Hi all,
some more interesing measurements:
1) Even when I remove theprintf()completely, the system freezes. My realtimetask is then
static voidrealtimetask(void *arg){ system("ls -l"); rt_task_sleep(1000000000ULL);}
2) When I replace the
printf()by agepid()the behaviour is the same.3) Jan, your application using the
rt_task_shadowbehaves the very same (it freezes)!4) A
getpid()directly after system does not help - however, a printf at this position helps to prevent the freeze.
Quoted 6 lines
But now, I found one very interesting thing:
When I rename my/lib/tlsto/lib/tls.disabled, it works!!!!
It seems to be (once more) a ugly thread local storage stuff. The ldd dependency ofxeno_crashshow libc and libpthread that are take from/lib/tls/i686/cmovdirectory.
Perhaps that could give a hint!
Please check the following assertions on your setup:
- does enabling the debug option for the Xenomai nucleus cause Xenomai warnings to appear (messages about forced switches of the crashtest task to secondary mode), even over 2.6.17 with the very same test code?
- does enabling CONFIG_DEBUG_SPINLOCK and CONFIG_DEBUG_SPINLOCK_SLEEP in the kernel hacking section cause Linux warnings to appear while the test code runs over 2.6.19, before the box crashes?
- does the bug still occurs after the call to the system() routine has been replaced by the following frag?
if (vfork() == 0)
execlp("/bin/ls", "ls", "-l", NULL);
else
wait(NULL);Signature · 1 line
Philippe.
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Gilles ChanteperdrixQuoted 8 lines · Gilles Chanteperdrix
Quoted 4 lines · Dmitry Adamushko
p.s.
vfork()is a different beast. Here a child is supposed to call exec*() rigth afterfork()so it's allowed to "borrow" parent's address space (vm_struct-> allvm_area(s)) and the parent is blocked in the mean time. As a result, no need for copy-on-write.I think to remember that glibc vfork is just fork.
At least, linuxthread's vfork is the same as linuxthread's fork.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to Philippe GerumHi Philippe,
here are some of the results:
Quoted 5 lines
Please check the following assertions on your setup:
- does enabling the debug option for the Xenomai nucleus cause Xenomai warnings to appear (messages about forced switches of the crashtest task to secondary mode), even over 2.6.17 with the very same test code?
Yes, on 2.6.17 I get the line
Xenomai: Switching crashtest to secondary mode after exception #14 from user-space at 0xb7ff2c7c (pid 1616) On 2.6.19.1, the system freezes, i.e. I cannot see any message.
Quoted 4 lines
- does enabling
CONFIG_DEBUG_SPINLOCKandCONFIG_DEBUG_SPINLOCK_SLEEPin the kernel hacking section cause Linux warnings to appear while the test code runs over 2.6.19, before the box crashes?
I am about to recompile the kernel, this takes a while...
Quoted 8 lines
- does the bug still occurs after the call to the
system()routine has been replaced by the following frag?if (vfork() == 0) execlp("/bin/ls", "ls", "-l", NULL); else wait(NULL);
I have replaced the system() call by your code fragement. And yes, this works! No freeze!
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Gilles ChanteperdrixQuoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Gilles Chanteperdrix
Quoted 4 lines · Dmitry Adamushko
p.s.
vfork()is a different beast. Here a child is supposed to call exec*() rigth afterfork()so it's allowed to "borrow" parent's address space (vm_struct-> allvm_area(s)) and the parent is blocked in the mean time. As a result, no need for copy-on-write.
Quoted 4 lines
Quoted 1 line
I think to remember that glibc vfork is just fork.
At least, linuxthread's vfork is the same as linuxthread's fork.
Well, I'm looking at glibc-2.3 :
1) ./sysdeps/unix/sysv/linux/i386/vfork.S
- if there is a vfork syscall - it's used, otherwise - fork.
- If per-arch code doesn't provide an implementation, the generic (
== notmal fork() ) is used.
2) linux (I'm looking at 2.6.12.6) does provide a separate vfork() (sys_vfork => do_fork() with additional flags CLONE_VFORK | CLONE_VM).
And it looks like it works as it should be in theory (at least briefly following the CLONE_VFORK logic in do_fork() and knowing that CLONE_VM is used for threads to share a vm_struct).
Anyway, I was refering to vfork() as it should be in theory in the context of copy-on-write policy.
Indeed, your remarks make sense. We should know when Markus conducts the tests suggested by Philippe. Although, the use of fork() in multi-threaded applications is sometimes tricky. I do remember once I had a problem but just can't recall any details (just that it was memory leaks :)
Quoted 2 lines
--
Gilles Chanteperdrix
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-help] Re: Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to M. KoehrerQuoted 11 lines · M. Koehrer
Quoted 9 lines
- does the bug still occurs after the call to the
system()routine has been replaced by the following frag?if (vfork() == 0) execlp("/bin/ls", "ls", "-l", NULL); else wait(NULL);I have replaced the
system()call by your code fragement. And yes, this works! No freeze!
Ok, could you let me know what happens if you use fork() instead of vfork()?
system() is the same thing : fork -> exec + but it also deals with signals.
Signature · 2 lines
Best regards, Dmitry Adamushko
[Xenomai-help] Re: Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to Philippe GerumHi Philippe,
Quoted 3 lines
- does enabling
CONFIG_DEBUG_SPINLOCKandCONFIG_DEBUG_SPINLOCK_SLEEPin the kernel hacking section cause Linux warnings to appear while the test code runs over 2.6.19, before the box crashes?
Unfortunately, I am not able to get the xeno_nucleus compiled when I have the kernel hacking configuration set as proposed.
The kernel linker complains about an undefined "tasklist_lock" in xeno_nucleus.ko Thus, I am not able to perform this test.
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
In reply to Dmitry AdamushkoHi Dmitry,
when I use fork() instead of vfork() I have the freeze again. I.e. using vfork() it works fine, using fork() freezes the system.
Regards
Mathias
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
- does the bug still occurs after the call to the
system()routine has been replaced by the following frag?if (vfork() == 0) execlp("/bin/ls", "ls", "-l", NULL); else wait(NULL);I have replaced the
system()call by your code fragement. And yes, thisworks!
Quoted 1 line
No freeze!
Ok, could you let me know what happens if you use
fork()instead ofvfork()?
system()is the same thing : fork -> exec + but it also deals with signals.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
Quoted 2 lines
when I use
fork()instead ofvfork()I have the freeze again. I.e. usingvfork()it works fine, usingfork()freezes the system.
Gilles: is this not the end point of the fork vs. vfork epopee ? :)
Anyway, it looks your remarks about fork() make sense. But if it's true indeed, a more nicer solution would be required.
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-help] Re: Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to M. KoehrerQuoted 10 lines · M. Koehrer
Hi Philippe,
Quoted 3 lines
- does enabling
CONFIG_DEBUG_SPINLOCKandCONFIG_DEBUG_SPINLOCK_SLEEPin the kernel hacking section cause Linux warnings to appear while the test code runs over 2.6.19, before the box crashes?Unfortunately, I am not able to get the
xeno_nucleuscompiled when I have the kernel hacking configuration set as proposed.
The kernel linker complains about an undefined "tasklist_lock" in xeno_nucleus.ko Thus, I am not able to perform this test.
Since 2.6.18, tasklist_lock is no longer exported. Either i-pipe has to take care for this or some other wakeup/locking mechanism in xnshadow_signal_completion needs to be found. Building the nucleus non-modular works around this.
Jan
[Xenomai-help] Re: Re: Re: Re: Re: A fairly small rtnet/Xenomai
In reply to M. KoehrerQuoted 11 lines · M. Koehrer
Hi Philippe,
Quoted 3 lines
- does enabling
CONFIG_DEBUG_SPINLOCKandCONFIG_DEBUG_SPINLOCK_SLEEPin the kernel hacking section cause Linux warnings to appear while the test code runs over 2.6.19, before the box crashes?Unfortunately, I am not able to get the
xeno_nucleuscompiled when I have the kernel hacking configuration set as proposed.
The kernel linker complains about an undefined "tasklist_lock" in xeno_nucleus.ko Thus, I am not able to perform this test.
This patch against the linux tree fixes the issue:
i386/kernel/ipipe.c renamed from i386/kernel/ipipe.c~ +1 -0
@@ -901,6 +901,7 @@EXPORT_SYMBOL_GPL (show_stack);EXPORT_PER_CPU_SYMBOL_GPL (init_tss);#ifdef CONFIG_SMP +EXPORT_SYMBOL (tasklist_lock);EXPORT_SYMBOL (__ipipe_logical_cpuid);EXPORT_PER_CPU_SYMBOL_GPL (cpu_tlbstate);#endif /* CONFIG_SMP */
Quoted 3 lines
Regards
Mathias
Signature · 1 line
Philippe.
[Xenomai-help] Re: A fairly small rtnet/Xenomai
In reply to M. KoehrerQuoted 6 lines · M. Koehrer
Hi all,
some more interesing measurements:
1) Even when I remove theprintf()completely, the system freezes. My realtimetask is then
static voidrealtimetask(void *arg)
Quoted 7 lines
{ system("ls -l"); rt_task_sleep(1000000000ULL);}
2) When I replace the
printf()by agepid()the behaviour is the same.
Hah, it finally oopses! Hurray!! Now the funny part begins...
Jan
[Xenomai-help] Re: A fairly small rtnet/Xenomai
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · M. Koehrer
Hi all,
some more interesing measurements:
1) Even when I remove theprintf()completely, the system freezes. My realtimetask is then
static voidrealtimetask(void *arg){ system("ls -l"); rt_task_sleep(1000000000ULL);
Quoted 6 lines
Quoted 3 lines
}
2) When I replace the
printf()by agepid()the behaviour is the same.Hah, it finally oopses! Hurray!! Now the funny part begins...
It must be a tight race window. My oops disappears once logging goes to serial console, so I only caught the following from the stalled console:
BUG: sleeping function called from invalid context at
include/asm/semaphore.h
in_atomic():0, irqs_disabled():1
[...] lock_kernel+0x28
default_llseek+0x15
sys_llseek+0x4e
sysenter_past_esp+0x65This all happens shortly after the test case terminated. I'm able scroll for a short while up in the log, but then the box goes South. With the serial console attached I only get that trap-#14 reports by Xenomai that the test program got switched to secondary mode.
I'm not able to continue my test on this particular system for the rest of the year. I will try to reproduce it again elsewhere (the SPINLOCK debugging switches seem to reveal something - sometime), but there is no guarantee that I can do anything about it.
Jan
[Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Dmitry AdamushkoQuoted 5 lines · Dmitry Adamushko
Quoted 2 lines
when I use
fork()instead ofvfork()I have the freeze again. I.e. usingvfork()it works fine, usingfork()freezes the system.Gilles: is this not the end point of the fork vs. vfork epopee ? :)
Right. I am currently using linuxthreads pthread implementation, that is why I had a look at it.
Quoted 3 lines
Anyway, it looks your remarks about
fork()make sense. But if it's true indeed, a more nicer solution would be required.
The simple solution is to only use fork in non time-critical part of code (like initializations and cleanup) and to fault the pages after the fork. It make sense to limit fork use to non time-critical code, I mean, I would already not recommend to create threads in time-critical code, creating a process is even worse.
A more complex solution would be to really duplicate the mlocked pages at fork time.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
Good morning everybody,
here are some more news concerning the Xenomai crash issue.
1) I have tried to enable the CONFIG_DEBUG_SPINLOCK and CONFIG_DEBUG_SPINLOCK_SLEEP kernel config parameters. But I did not get any messages before the kernel freezes.
2) I have tried to link a static application (using -lstatic). When I pass
the -L/usr/lib/nptl option to force the linker to use the nptl libs, the effect is the same. Well, I have now a static binary that freezes the system.
I can mails you the binary file (about 280kByte bz2 file) if you like.
I think this file is too large to be posted to the list.
One additional question comes in my mind:
As I learned from all that things that are related to the issue, it seems to be fairly critical to fork out of a real time task or to create new processes out of it. My question is now:
Is it possible to force a real time task back to standard linux task behaviour, in this state the critical calls can be made. After it a move back to the origin real time state would be nice. In the native skin there is the rt_task_shadow() call that allows to move a standard linux task to a real time task.
For moving a real time task to a standard task (and back) something like rt_task_movetostandard(&state) that saves the real time state in a variable and a rt_task_movebacktorealtime(&state) would be helpful.
Quoted 1 line
From the user point all that would be something like a critical region,
I enter a region where I can do really everything and then I move back to the real time domain.
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
In reply to Jan KiszkaQuoted 23 lines · Jan Kiszka
Quoted 13 lines · Gilles Chanteperdrix
Quoted 10 lines · M. Koehrer
Hi Jan, hi everybody,
I have stripped down my program that is crashing Xenomai even further. (I have attached the complete source code).
No rtnet is required.
Now I have the following real time task:static void
realtimetask(void *arg){ system("ls -l");Quoted 6 lines
If you want to use system (or any function calling fork, eg popen or vfork) with Xenomai, you have to make sure to fault all pages mapped with write permission after the fork before trying to use services in priimary mode, because fork write protects all pages with write permission and notably the threads stacks. A piece of code that faults all pages follows.
Quoted 4 lines
Let me check if I got this correctly: fork calls mark all pages write-protected - also those of the father process, or only those of the new child? That would mean we see unexpected page faults, right? Anything more (probably not a lock-up)?
Not all page faults are inocuous. I discovered this behaviour of fork when chasing a lock-up that was caused by an xnshadow_relax that did not work. It turned out that a page fault occured because of the thread stack page protection in an xn_copy_to_user, after the calling thread had been kicked. Trying to relax a kicked thread can not work, and triggers a nucleus panic.
There may be other pathes where a page fault may be deadly.
Now, in Mathias case, the fact that printf helps is probably the sign that the deadly fault occurs on the thread stack, because printf touches the thread stack (remember?, printf segfaults when the thread stack is too small).
The fact that the bug only occurs with 2.6.19 shows that maybe 2.6.19 is accessing the thread stack whereas previous versions did not.
Quoted 3 lines
I think we should document this special property somewhere, e.g. in the wiki, maybe also a demo program in the examples repos.
I agree.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
In reply to M. KoehrerQuoted 7 lines
One additional question comes in my mind:
As I learned from all that things that are related to the issue, it seems to be fairly critical to fork out of a real time task or to create new processes out of it. My question is now:
Is it possible to force a real time task back to standard linux task behaviour, in this state the critical calls can be made. After it a move back to the origin real time state would be nice.
A switch is done automatically when you make a call to any secondary-domain sys call, and the vice-versa. Nevertheless, rt_task_set_mode() does it excplicitly. Look for the T_PRIMARY flag.
But, well, it's not something that might help you in this particular case (I mean a problem with fork() :)
So far, I would suggest to use a separate (preliminary) forked context (and make some communication channel to it from your application) to send arp requests in your scenario (or anything else that requires fork()).
Signature · 2 lines
Best regards, Dmitry Adamushko
[Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to M. KoehrerQuoted 12 lines · M. Koehrer
Good morning everybody,
here are some more news concerning the Xenomai crash issue.
1) I have tried to enable theCONFIG_DEBUG_SPINLOCKandCONFIG_DEBUG_SPINLOCK_SLEEPkernel config parameters. But I did not get any messages before the kernel freezes.2) I have tried to link a static application (using -lstatic). When I pass
the -L/usr/lib/nptl option to force the linker to use the nptl libs, the effect is the same. Well, I have now a static binary that freezes the system.
I can mails you the binary file (about 280kByte bz2 file) if you like.
I think this file is too large to be posted to the list.
Quoted 3 lines
One additional question comes in my mind:
As I learned from all that things that are related to the issue, it seems to be fairly critical to fork out of a real time task or to create new processes out of it.
In absence of a better solution, I would recommend to use the "fault_vm"
function after each fork.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
Hi Gilles and Dmitry,
I actually prefer Gilles proposal to add the fault_vm() function after calling a forking function.
Dmitry's idea with a different context and inter process communication will surely work but it makes the code less transparent as when using the fault_vm() function. Are there situations where the fault_vm() could fail or is this fine in all situations?
Regards
Mathias
Quoted 26 lines
Quoted 4 lines · M. Koehrer
Good morning everybody,
here are some more news concerning the Xenomai crash issue.
1) I have tried to enable theCONFIG_DEBUG_SPINLOCKand
CONFIG_DEBUG_SPINLOCK_SLEEPQuoted 1 line
kernel config parameters. But I did not get any messages before the kernel
freezes.
Quoted 2 lines
2) I have tried to link a static application (using -lstatic). When I
pass
Quoted 1 line
the -L/usr/lib/nptl option to force the linker to use the nptl libs, the
effect is the same.
Quoted 6 lines
Well, I have now a static binary that freezes the system.
I can mails you the binary file (about 280kByte bz2 file) if you like. I think this file is too large to be posted to the list.One additional question comes in my mind:
As I learned from all that things that are related to the issue, it seemsto be fairly
Quoted 1 line
critical to fork out of a real time task or to create new processes out of
it.
In absence of a better solution, I would recommend to use the "
fault_vm"
function after each fork.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Gilles ChanteperdrixQuoted 3 lines · Gilles Chanteperdrix
In absence of a better solution, I would recommend to use the "
fault_vm"
function after each fork.
But it's not safe. It doesn't stop any other rt threads (if there are a few in this app.) from touching the wp-pages (it's not only about stacks after all) in the mean time. So fault_vm() only increases the probability of not-crashing but doesn't eliminate it completely.
So all the contextes have to be blocked starting from the moment fork() is about to be called and till the moment a subsequent fault_vm() is done.
It's ugly and that suggests fork() is not ok here at all.
And btw, vfork() should be a funny thing being called from multi-threaded app. It blocks a calling context and borrows its address space while other threads are continuing to run, well, with the same context (maybe it's handled somehow, have to check).
Quoted 4 lines
--
Gilles Chanteperdrix
Signature · 2 lines
Best regards, Dmitry Adamushko
[Xenomai-help] Re: A fairly small rtnet/Xenomai...
Quoted 16 lines · Dmitry Adamushko
Quoted 2 lines · Gilles Chanteperdrix
In absence of a better solution, I would recommend to use the "
fault_vm" function after each fork.But it's not safe. It doesn't stop any other rt threads (if there are a few in this app.) from touching the wp-pages (it's not only about stacks after all) in the mean time. So
fault_vm()only increases the probability of not-crashing but doesn't eliminate it completely.So all the contextes have to be blocked starting from the moment
fork()is about to be called and till the moment a subsequentfault_vm()is done.
It's ugly and that suggestsfork()is not ok here at all.
Quoted 4 lines
And btw,
vfork()should be a funny thing being called from multi-threaded app. It blocks a calling context and borrows its address space while other threads are continuing to run, well, with the same context (maybe it's handled somehow, have to check).
fault_vm is safe to use only if you are calling fork at a time when there is only one thread. So, if your application is forking at init, it should be OK.
Signature · 1 line
Gilles Chanteperdrix
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
Hi Gilles,
Quoted 3 lines
fault_vmis safe to use only if you are calling fork at a time when there is only one thread. So, if your application is forking at init, it should be OK.
Do you mean there must be only one real time thread?
That means, when I have an application that creates multiple real time threads, I can not rely on fault_vm() ?
In this case I have to do the "hard" way by using a different (non real time) context to do the forks and system() calls.
As this is hard to understand, I strongly recommend that there is Xenomai support for this! I.e. a Xenomai API that can be called with a (callback-)function pointer and a user data pointer.
When a (realtime) thread calls this function, the real time thread is blocked. The callback function is then called from a safe context and
after exit of the callback function the real time thread is resumed.
Regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
Quoted 8 lines · M. Koehrer
Hi Gilles,
Quoted 3 lines
fault_vmis safe to use only if you are calling fork at a time when there is only one thread. So, if your application is forking at init, it should be OK.Do you mean there must be only one real time thread?
That means, when I have an application that creates multiple real time threads, I can not rely onfault_vm()?
Yes, read my previous mail.
Quoted 2 lines
In this case I have to do the "hard" way by using a different (non real time) context to do the forks and
system()calls.
That's much safer indeed. Both in respect of this particular problem and others that may be encountered using fork() from a multithreaded application.
e.g. look here
http://www.gnu.org/software/libc/manual/html_node/Threads-and-Fork.html#Threads%20and%20Fork
Quoted 6 lines
As this is hard to understand, I strongly recommend that there is Xenomai support for this! I.e. a Xenomai API that can be called with a (callback-)function pointer and a user data pointer.
When a (realtime) thread calls this function, the real time thread is blocked. The callback function is then called from a safe context and
after exit of the callback function the real time thread is resumed.
I haven't got your idea. Did you get the cause of the problem with fork() ?
Quoted 4 lines
Regards
Mathias
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Gilles ChanteperdrixQuoted 16 lines · Gilles Chanteperdrix
Quoted 15 lines · Dmitry Adamushko
Quoted 2 lines · Gilles Chanteperdrix
In absence of a better solution, I would recommend to use the "
fault_vm" function after each fork.But it's not safe. It doesn't stop any other rt threads (if there are a few in this app.) from touching the wp-pages (it's not only about stacks after all) in the mean time. So
fault_vm()only increases the probability of not-crashing but doesn't eliminate it completely.So all the contextes have to be blocked starting from the moment
fork()is about to be called and till the moment a subsequentfault_vm()is done.
It's ugly and that suggestsfork()is not ok here at all.
Quoted 9 lines
Quoted 4 lines
And btw,
vfork()should be a funny thing being called from multi-threaded app. It blocks a calling context and borrows its address space while other threads are continuing to run, well, with the same context (maybe it's handled somehow, have to check).
fault_vmis safe to use only if you are calling fork at a time when there is only one thread. So, if your application is forking at init, it should be OK.
Isn't there something to do about it at kernel level, i.e. on cloning the mm-context of a process? Could we somehow force an immediate copy of a real-time process's mm?
[Xenomai-help] Re: Re: A fairly small rtnet/Xenomai...
In reply to M. KoehrerQuoted 5 lines · M. Koehrer
Hi Gilles,
Quoted 3 lines
fault_vmis safe to use only if you are calling fork at a time when there is only one thread. So, if your application is forking at init, it should be OK.
Quoted 12 lines
Do you mean there must be only one real time thread?
That means, when I have an application that creates multiple real time threads, I can not rely onfault_vm()?
In this case I have to do the "hard" way by using a different (non real time) context to do the forks andsystem()calls.
As this is hard to understand, I strongly recommend that there is Xenomai support for this! I.e. a Xenomai API that can be called with a (callback-)function pointer and a user data pointer.
When a (realtime) thread calls this function, the real time thread is blocked. The callback function is then called from a safe context and
after exit of the callback function the real time thread is resumed.
Sorry, but no, no way, I won't merge anything like this, ever. This is the wrong way to go. The right way is to fix the COW issue at kernel level - probably the I-pipe has to provide the required support - because this is where those dirty details belong to. This is definitely not an API issue, because you just cannot tell application developers to care about arch-specific VM issues when using a so-called generic API that has to work the same way on all archs (e.g. MMU-less platforms don't care about this, others would). What could be considered as a bearable limitation right now must not have any impact on long-term principles, and the API stuff belongs to that category of issues.
Quoted 7 lines
Regards
Mathias
Signature · 1 line
Philippe.
[Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai...
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Regards
Mathias
Quoted 11 lines
Sorry, but no, no way, I won't merge anything like this, ever. This is the wrong way to go. The right way is to fix the COW issue at kernel level - probably the I-pipe has to provide the required support - because this is where those dirty details belong to. This is definitely not an API issue, because you just cannot tell application developers to care about arch-specific VM issues when using a so-called generic API that has to work the same way on all archs (e.g. MMU-less platforms don't care about this, others would). What could be considered as a bearable limitation right now must not have any impact on long-term principles, and the API stuff belongs to that category of issues.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
[Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai...
Quoted 4 lines · M. Koehrer
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Definitely, yes. The point is that once you go down the "rt_task_system()" path, you end up being trapped into API proliferation, which would continue with rt_task_fork, rt_task_vfork and so on. This would a dead end, unfortunately.
Asking people to use rt_task_system() is already asking them to understand why they should not use system() in the first place, so this can't solve the root issue. The problem comes entirely from the fact that we don't expect any more faults after mlockall, and COW proved us wrong. The fact that the machine freezes is only a side-effect due to the co-kernel constraints, the first and foremost problem is that gracefully handling a page fault would induce uncontrolable latencies anyway.
IOW, the problem has to be fixed at kernel level, because it's fundamentally an arch-dependent core issue.
Quoted 18 lines
Regards
Mathias
Quoted 11 lines
Sorry, but no, no way, I won't merge anything like this, ever. This is the wrong way to go. The right way is to fix the COW issue at kernel level - probably the I-pipe has to provide the required support - because this is where those dirty details belong to. This is definitely not an API issue, because you just cannot tell application developers to care about arch-specific VM issues when using a so-called generic API that has to work the same way on all archs (e.g. MMU-less platforms don't care about this, others would). What could be considered as a bearable limitation right now must not have any impact on long-term principles, and the API stuff belongs to that category of issues.
Signature · 1 line
Philippe.
[Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to M. KoehrerQuoted 8 lines · M. Koehrer
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Regards
Mathias
Hi Mathias,
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new VM_NOCOW flag which should be set for real-time application if you use Xenomai trunk.
It would be nice if you could test it.
Thanks in advance.
Signature · 1 line
Gilles Chanteperdrix
include/linux/mm.h +1 -0
@@ -166,6 +166,7 @@ extern unsigned int kobjsize(const void#define VM_NONLINEAR 0x00800000/* Is non-linear (remap_file_pages) */ #define VM_MAPPED_COPY 0x01000000/* T if mapped copy of data (nommu mmap) */ #define VM_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ +#define VM_NOCOW 0x10000000/* Disable COW mapping for the vma */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
mm/memory.c +52 -30
118 lines not on this page · raw message
[Xenomai-help] Aw: Re: A fairly small rtnet/Xenomai...
HI Gilles,
thanks for the patch.
However, as I am not in the office until 2nd of january, I will do the tests early next year.
Regards
Mathias
Quoted 24 lines
Quoted 8 lines · M. Koehrer
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Regards
Mathias
Hi Mathias,
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
Thanks in advance.
Signature · 1 line
Gilles Chanteperdrix
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Gilles ChanteperdrixQuoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · M. Koehrer
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Regards
Mathias
Quoted 8 lines
Hi Mathias,
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
nucleus/shadow.c renamed from nucleus/shadow.c.orig +2 -0
@@ -839,6 +839,8 @@#ifdef CONFIG_MMU if (!(current->mm->def_flags &VM_LOCKED ))send_sig (SIGXCPU , current,1 ); +else + current->mm->def_flags |=VM_NOCOW ;#endif /* CONFIG_MMU */ current->cap_effective |=
Signature · 1 line
Philippe.
[Xenomai-help] COW-disable patch
In reply to Gilles ChanteperdrixQuoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · M. Koehrer
Hi Philippe,
I agree. To fix the root cause is actually the very best to do! This eases the life of users and developers.
Regards
Mathias
Quoted 8 lines
Hi Mathias,
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
Here is the same patch backported to 2.6.14 for the ppc people who experienced the same kind of issues. When enabling the nucleus debug option (full, with queue checks), no more warning should appear in the kernel log about threads being switched to secondary mode while the latency test runs. The last patch is to be applied against a Xenomai 2.3.x tree to activate the feature. Feedback highly recommended if you want this patch to be merged in. TIA,
include/linux/mm.h +1 -0
@@ -162,6 +162,7 @@#define VM_HUGETLB 0x00400000/* Huge TLB Page VM */ #define VM_NONLINEAR 0x00800000/* Is non-linear (remap_file_pages) */ #define VM_MAPPED_COPY 0x01000000/* T if mapped copy of data (nommu mmap) */ +#define VM_NOCOW 0x10000000/* Disable COW mapping for the vma */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
mm/memory.c +30 -6
@@ -341,10 +341,10 @@* but may be dropped within p[mg]d_alloc() and pte_alloc_map(). */ -static inline void +static inline int copy_one_pte (struct mm_struct *dst_mm,struct mm_struct *src_mm, -pte_t *dst_pte,pte_t *src_pte,unsigned long vm_flags, -unsigned long addr) +pte_t *dst_pte,pte_t *src_pte,unsigned long vm_flags, +unsigned long addr,struct vm_area_struct *vma) {pte_t pte = *src_pte;struct page *page;
@@ -362,7 +362,7 @@ } }set_pte_at (dst_mm, addr, dst_pte, pte); -return ; +return 0 ; } pfn =pte_pfn (pte);
@@ -377,7 +377,7 @@if (!page ||PageReserved (page)) {set_pte_at (dst_mm, addr, dst_pte, pte); -return ; +return 0 ; }/*
@@ -385,6 +385,27 @@* in the parent and the child */ if ((vm_flags & (VM_SHARED |VM_MAYWRITE )) ==VM_MAYWRITE ) { +#ifdef CONFIG_IPIPE +if (((vm_flags|src_mm->def_flags) & (VM_NOCOW |VM_LOCKED )) == (VM_NOCOW |VM_LOCKED )) { +struct page *old_page = page; + page =alloc_page_vma (GFP_HIGHUSER , vma, addr); +if (!page) +return -ENOMEM ; + +copy_user_highpage (page, old_page, addr); + pte =mk_pte (page, vma->vm_page_prot); + +if (vm_flags &VM_SHARED ) + pte =pte_mkclean (pte); + pte =pte_mkold (pte); +inc_mm_counter (dst_mm, rss); +if (PageAnon (page)) +inc_mm_counter (dst_mm, anon_rss); +set_pte_at (dst_mm, addr, dst_pte, pte); +page_dup_rmap (page); +return 0 ; + } +#endif /* CONFIG_IPIPE */ ptep_set_wrprotect (src_mm, addr, src_pte); pte = *src_pte; }
@@ -402,6 +423,8 @@inc_mm_counter (dst_mm, anon_rss);set_pte_at (dst_mm, addr, dst_pte, pte);page_dup_rmap (page); + +return 0 ; } static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
@@ -433,7 +456,8 @@ progress++;continue ; } -copy_one_pte (dst_mm, src_mm, dst_pte, src_pte, vm_flags, addr); +if (copy_one_pte (dst_mm, src_mm, dst_pte, src_pte, vm_flags, addr, vma)) +return -ENOMEM ; progress +=8 ; }while (dst_pte++, src_pte++, addr +=PAGE_SIZE , addr != end);spin_unlock (&src_mm->page_table_lock);
nucleus/shadow.c 2006-12-27 11:42:55.000000000 +0100 renamed from nucleus/shadow.c.orig 2006-12-27 11:42:50.000000000 +0100 +2 -0
@@ -839,6 +839,8 @@ #ifdef CONFIG_MMU if (!(current->mm->def_flags & VM_LOCKED)) send_sig(SIGXCPU, current, 1); + else + current->mm->def_flags |= VM_NOCOW; #endif /* CONFIG_MMU */ current->cap_effective |=
Signature · 1 line
Philippe.
Re: Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Philippe GerumHappy new year to all!
Back in the office, I tried out the patches from Chilles and Philippe.
And yes, it is working now! No crash!
Using these patches, I can now call a system() call out of a rea ltime task that is followed by a rt_task_sleep() and a printf() without crash on a 2.6.19 kernel.
Thanks for the support!
Best regards
Mathias
Quoted 9 lines
Quoted 6 lines
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Re: Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
Quoted 7 lines · M. Koehrer
Happy new year to all!
Back in the office, I tried out the patches from Chilles and Philippe.
And yes, it is working now! No crash!
Using these patches, I can now call asystem()call out of a rea ltime task that is followed by art_task_sleep()and aprintf()without crash on a 2.6.19 kernel.
Quoted 16 lines
Thanks for the support!
Best regards
Mathias
Quoted 9 lines
Quoted 6 lines
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
Great, thanks. Niklaus, could you check the vm-nocow patch for 2.6.14 on the ppc board (the hcu, IIRC) that exhibited strange faults in user-space while running the latency test, especially when enabling the nucleus debug option (the one which also used to cause secondary switch warnings being sent by Xenomai to the kernel log)? TIA,
Signature · 1 line
Philippe.
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
Am Dienstag, 2. Januar 2007 10:53 schrieb Philippe Gerum:
Quoted 21 lines · M. Koehrer
Quoted 20 lines
Happy new year to all!
Back in the office, I tried out the patches from Chilles and Philippe. And yes, it is working now! No crash!
Using these patches, I can now call asystem()call out of a rea ltime task that is followed by art_task_sleep()and aprintf()without crash on a 2.6.19 kernel.Thanks for the support!
Best regards
Mathias
Quoted 6 lines
Quoted 5 lines
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
Great, thanks. Niklaus, could you check the vm-nocow patch for 2.6.14 on the ppc board (the hcu, IIRC) that exhibited strange faults in user-space while running the latency test, especially when enabling the nucleus debug option (the one which also used to cause secondary switch warnings being sent by Xenomai to the kernel log)? TIA,
I will check it, but I must first upgrade my board specific patch from Linux 2.6.17 to 2.6.19. Don't know how much time it will take me.
Best regards
Signature · 1 line
Niklaus Giger
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
In reply to Philippe GerumAm Dienstag, 2. Januar 2007 10:53 schrieb Philippe Gerum:
Quoted 21 lines · M. Koehrer
Quoted 20 lines
Happy new year to all!
Back in the office, I tried out the patches from Chilles and Philippe. And yes, it is working now! No crash!
Using these patches, I can now call asystem()call out of a rea ltime task that is followed by art_task_sleep()and aprintf()without crash on a 2.6.19 kernel.Thanks for the support!
Best regards
Mathias
Quoted 6 lines
Quoted 5 lines
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
Great, thanks. Niklaus, could you check the vm-nocow patch for 2.6.14 on the ppc board (the hcu, IIRC) that exhibited strange faults in user-space while running the latency test, especially when enabling the nucleus debug option (the one which also used to cause secondary switch warnings being sent by Xenomai to the kernel log)? TIA,
Here the results. I had no problems running xeno-test.
I did set in my .configCONFIG_XENO_OPT_DEBUG=yCONFIG_XENO_OPT_DEBUG_NUCLEUS=y
Attached is my .config and the output of xeno-test.
If you need the results of another combination just let me know.
Best regards
Signature · 1 line
Niklaus Giger
Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai...
Quoted 25 lines · Niklaus Giger
Am Dienstag, 2. Januar 2007 10:53 schrieb Philippe Gerum:
Quoted 24 lines · M. Koehrer
Quoted 22 lines
Happy new year to all!
Back in the office, I tried out the patches from Chilles and Philippe. And yes, it is working now! No crash!
Using these patches, I can now call asystem()call out of a rea ltime task that is followed by art_task_sleep()and aprintf()without crash on a 2.6.19 kernel.Thanks for the support!
Best regards
Mathias
Quoted 8 lines
Quoted 5 lines
here comes a workaround for the COW issue on Linux 2.6.19. The patch relies on a new
VM_NOCOWflag which should be set for real-time application if you use Xenomai trunk.It would be nice if you could test it.
You will additionally need to apply this patch to the Xenomai tree in order to activate the COW-disable feature:
Quoted 7 lines
Quoted 5 lines
Great, thanks. Niklaus, could you check the vm-nocow patch for 2.6.14 on the ppc board (the hcu, IIRC) that exhibited strange faults in user-space while running the latency test, especially when enabling the nucleus debug option (the one which also used to cause secondary switch warnings being sent by Xenomai to the kernel log)? TIA,
Here the results. I had no problems running xeno-test.
Nice.
Quoted 7 lines
I did set in my .config
CONFIG_XENO_OPT_DEBUG=yCONFIG_XENO_OPT_DEBUG_NUCLEUS=yAttached is my .config and the output of xeno-test.
If you need the results of another combination just let me know.
That's fine, thanks.
Signature · 1 line
Philippe.