hal/x86: update I-pipe patches
[xenomai-head.git] / TROUBLESHOOTING
blob787238eedc1a4480bc1c011380d1980f4aa3016f
1 Troubleshooting guide
3 -------------------------------------------------------------------------------
5 Table of Contents
7  
8 1. Kernel configuration
9 2. Xenomai or I-pipe error in the kernel log
11     2.1. Kernel stops after "Uncompressing Linux… done, booting the kernel."
12     2.2. Kernel stops with an OOPS
13     2.3. Kernel boots but does not print any message
14     2.4. Xenomai: compiled for TSC, but CPU has no TSC
15     2.5. Xenomai has detected a CPU frequency of 0
16     2.6. I-pipe: could not find timer for cpu #x
17     2.7. Xenomai: Local APIC absent or disabled!
18     2.8. Xenomai: SMI-enabled chipset found, but SMI workaround disabled
19     2.9. Xenomai: system init failed, code -19
21         2.9.1. On x86
22         2.9.2. On AMD x86_64
23         2.9.3. On ARM
24         2.9.4. On other supported platforms
25         2.9.5. On a new I-pipe port
27     2.10. Xenomai: system init failed, code -22
29 3. Problems when running the latency test
31     3.1. Xenomai: binding failed: Operation not permitted
32     3.2. Xenomai: --enable-x86-sep needs NPTL and Linux 2.6.x or higher
33     3.3. latency: failed to open benchmark device
34     3.4. Hardware tsc is not a fast wrapping one
35     3.5. Xenomai: incompatible ABI revision level
36     3.6. Xenomai: incompatible feature set
38         3.6.1. missing="kuser_tsc"
39         3.6.2. missing="sep"
40         3.6.3. missing="smp/nosmp"
41         3.6.4. missing="tsc"
43     3.7. Xenomai: kernel/user tsc emulation mismatch
44     3.8. Xenomai: native skin or CONFIG_XENO_OPT_PERVASIVE disabled
45     3.9. latency: not found
46     3.10. Xenomai: watchdog triggered (period too short?)
47     3.11. Xenomai: Your board/configuration does not allow tsc emulation
48     3.12. the latency test hangs
49     3.13. the latency test shows high latencies
50     3.14. ARM tsc emulation issues
52 4. switchtest fails with "pthread_create: Resource temporarily unavailable"
53 5. Known Bugs and Limitations
55     5.1. 2.6.2/x86
57 6. Problem with my code (not Xenomai code)
59     6.1. "Warning: <service> is deprecated" while compiling kernel code
60     6.2. "Xenomai: process memory not locked (missing mlockall?)" at startup
61     6.3. High latencies when transitioning from primary to secondary mode
62     6.4. Any Xenomai service fails with code -38 (ENOSYS)
63     6.5. My application reserves a lot of memory
65 This file is a troubleshooting guide about various known issues regarding
66 Xenomai.
68 The latest version is available at this address: 
69 "http://www.xenomai.org/documentation/xenomai-2.6/html/TROUBLESHOOTING/".
71 For questions, corrections and improvements, write to the mailing list: 
72 "xenomai@xenomai.org".
75 1. Kernel configuration
76 When configuring the Linux kernel, some options should be avoided.
78 CONFIG_CPU_FREQ
79     This allows the CPU frequency to be modulated with workload, but many CPUs
80     change the TSC counting frequency also, which makes it useless for accurate
81     timing when the CPU clock can change. Also some CPUs can take several
82     milliseconds to ramp up to full speed.
83 CONFIG_CPU_IDLE
84     Allows the CPU to enter deep sleep states, increasing the time it takes to
85     get out of these sleep states, hence the latency of an idle system. Also,
86     on some CPU, entering these deep sleep states causes the timers used by
87     Xenomai to stop functioning.
88 CONFIG_CC_STACKPROTECTOR
89     This option must be disabled on all platforms except x86_64: it requires
90     changes to the context switches currently only implemented for x86_64.
91 CONFIG_KGDB
92     This option can not be enabled with current versions of the I-pipe patch.
94 For x86 specific options see also this page: 
95 "http://www.xenomai.org/index.php/Configuring_x86_kernels".
98 2. Xenomai or I-pipe error in the kernel log
99 If the Xenomai and I-pipe messages do not appear in the kernel log as:
101 I-pipe: head domain Xenomai registered.
102 Xenomai: hal/<arch> started.
103 Xenomai: scheduling class idle registered.
104 Xenomai: scheduling class rt registered.
105 Xenomai: real-time nucleus v2.6.1 (Light Years Away) loaded.
106 Xenomai: debug mode enabled.
107 Xenomai: starting native API services.
108 Xenomai: starting POSIX services.
109 Xenomai: starting RTDM services.
111 Where <arch> is the architecture you use, check the following sections, they
112 describe the usual error messages you may encounter.
114 2.1. Kernel stops after "Uncompressing Linux… done, booting the kernel."
116 This means that the kernel crashes before the console is enabled. You should
117 enable the CONFIG_EARLY_PRINTK option. For some architectures (blackfin, x86,
118 arm), enabling this option also requires passing the earlyprintk parameter on
119 the kernel command line. See Documentation/kernel-parameters.txt for possible
120 values.
122 For the ARM architecture, you have to enable CONFIG_DEBUG_KERNEL and
123 CONFIG_DEBUG_LL in order to be able to enable CONFIG_EARLY_PRINTK.
125 2.2. Kernel stops with an OOPS
127 Please make sure that you have followed the "Kernel configuration" section.
128 Then, try capturing the oops text (using a serial console or netconsole) post
129 the oops to the xenomai mailing list: "xenomai@xenomai.org", with the kernel
130 configuration you used to compile the failing kernel.
132 2.3. Kernel boots but does not print any message
134 Your distribution may be configured to pass the quiet option on the kernel
135 command line. In this case, the kernel does not print all the log messages,
136 however, they are still available using the dmesg command.
138 2.4. Xenomai: compiled for TSC, but CPU has no TSC
140 You selected a CPU which as a TSC ("Pentium classic", and above), but the CPU
141 on which you run the kernel has no TSC. This issue was resolved in the I-pipe
142 core for Linux 3.4, but for prior versions, you need to select a CPU without a
143 TSC when configuring the kernel, and recompile the kernel.
145 2.5. Xenomai has detected a CPU frequency of 0
147 This happens when running in emulators. In such a case, Xenomai can not run as
148 it needs to know the clock frequency.
150 This may also happen when using I-pipe core patch for Linux 3.2, compiled for a
151 CPU with a TSC, but running on a CPU without a TSC, as in the "Xenomai:
152 compiled for TSC case.
154 2.6. I-pipe: could not find timer for cpu #x
156 See code -19.
158 2.7. Xenomai: Local APIC absent or disabled!
160 See code -19.
162 2.8. Xenomai: SMI-enabled chipset found, but SMI workaround disabled
164 First you should run the latency test under some load and see if you experience
165 any pathological latency ("pathological" meaning more than, say, 100
166 micro-seconds). If you do not observe any such latency, then this warning is
167 harmless, and if you find it annoying, you may add the parameter "xeno_hal.smi=
168 -1" on the kernel command line. You can skip the rest of this section.
170 If you observe any high latency then you have a problem with SMI, and this
171 warning was intended for you. But the Xenomai patched kernel parameters allow
172 you to enable two workarounds which may help you. These workarounds are enabled
173 by adding the parameter "xeno_hal.smi=1" on the kernel command line.
175 The first workaround which you should try is to disable all SMI sources. In
176 order to do this, simply boot with the parameter "xeno_hal.smi=1" on the kernel
177 command line. This option is the most reliable workaround, because when
178 enabled, no SMI can interfere with hardware interrupt management behind your
179 back and cause high latencies. Once this workaround enabled, you should run the
180 latency test again, verify that your high latency disappeared but most
181 importantly, verify that every peripheral you intend to use with Xenomai is
182 working properly.
184 If everything is working properly, then try and stress-test the system, and
185 check for overheating. If the motherboard sensors do not allow to check
186 temperature, and you get an unexplained reboot in the middle of the
187 stress-test, chances are that you have an overheating issue, otherwise, you are
188 done with the SMI workaround.
190 [Important] Important
191             if your system is over-heating you should not disable the SMI
192             globally as the SMI are probably needed for controlling the cooling
193             of your system, so disabling them globally may damage your system.
194             Try the next section. Otherwise, you are done with SMI.
196 If some peripheral is not working properly, then it probably needs SMI, in
197 which case you can not simply disable SMI globally, you will need to disable
198 all SMI sources on your system except the SMI needed by your peripheral. The
199 same goes if the system overheat, you have to find a way to keep the SMI source
200 which is controlling the thermal control enabled. This is a much less reliable
201 choice, since you have to know all SMI sources to disable them, one by one. In
202 order to choose this second workaround, check in the documentation for the
203 Intel chipset you use, for the documentation of the SMI_EN register. Then set
204 the "xeno_hal.smi_mask" parameter on the kernel command line with a value where
205 all bits set to 0 will be disabled when Xenomai starts.
207 You should then run the latency test again and verify that you do not observe
208 any high latency and that all your peripherals are functioning correctly. If
209 when running the latency test again, your peripheral is working properly and
210 you still observe high latencies, then you are out of luck, the peripheral you
211 want is likely to be the cause of such latencies.
213 2.9. Xenomai: system init failed, code -19
215 The most probable reason is that Xenomai could not find a timer.
217 Check that you have not enabled one of the options in the "Kernel
218 configuration" section.
220 2.9.1. On x86
222 You will most likely also see the following message:
224 Xenomai: Local APIC absent or disabled!
225 Disable APIC support or pass "lapic" as bootparam.
227 Xenomai sends this message if the kernel configuration Xenomai was compiled
228 against enables the local APIC support (CONFIG_X86_LOCAL_APIC), but the
229 processor status gathered at boot time by the kernel says that no local APIC
230 support is available. There are two options for fixing this issue:
232   * either your CPU really has no local APIC hw, then you need to rebuild a
233     kernel with LAPIC support disabled, before rebuilding Xenomai against the
234     latter;
235   * or it does have a local APIC but the kernel boot parameters did not specify
236     to activate it using the "lapic" option. The latter is required since
237     2.6.9-rc4 for boxen which APIC hardware is disabled by default by the BIOS.
238     You may want to look at the file Documentation/kernel-parameters.txt from
239     the Linux source tree, for more information about this parameter.
241 2.9.2. On AMD x86_64
243 You will most likely also see the following message:
245 I-pipe: cannot use LAPIC as a tick device
246 I-pipe: disable C1E power state in your BIOS
248 Xenomai sends this message if C1E option is enabled in a BIOS. To fix this
249 issue please disable C1E support in the BIOS. In some Award BIOS this option is
250 located in the Advanced BIOS Features→ menu (AMD C1E Support).
252 [Important] Important
253             Disabling AMD K8 Cool&Quiet option in a BIOS does not solve the
254             problem.
256 2.9.3. On ARM
258 If you see the following message:
260 Xenomai: hal/arm: hardware FPU support enabled but not available
262 It means that you enabled CONFIG_VFP and CONFIG_XENO_HW_FPU in the kernel
263 configuration, but the processor on which you are running the kernel has no
264 support for VFP. In that case, you have to recompile the kernel with
265 CONFIG_XENO_HW_FPU disabled.
267 2.9.4. On other supported platforms
269 As on x86, on other platforms where Xenomai shares the timer with Linux, the
270 timer is only used if it was not shut down by Linux. So you should check the
271 log for messages about disabled timers. You can also check /proc/timer_list to
272 see which timers are enabled. For instance, Xenomai on SMP systems requires
273 per-cpu local timers, so the local timers should be enabled. In case of doubt,
274 post a message to the xenomai mailing list: "xenomai@xenomai.org", sending:
276   * your kernel configuration
277   * the contents of /proc/timer_list run on the exact kernel which has the
278     issue
279   * the complete kernel boot log.
281 2.9.5. On a new I-pipe port
283 You will most likely also see the following message:
285 I-pipe: could not find timer for cpu #x
287 Starting with the I-pipe patch for Linux 3.2, the timers provided by the I-pipe
288 patch to Xenomai are registered at run-time. So, you may lack a struct
289 ipipe_timer definition, and its registration with ipipe_timer_register() or
290 with the ipipe_timer member of the struct clock_event_device structure.
292 For an example on the ARM platform see this page: 
293 "http://www.xenomai.org/index.php/I-pipe-core:ArmPorting#The_general_case".
295 2.10. Xenomai: system init failed, code -22
297 On the ppc64 platform, check whether CONFIG_PPC_64K_PAGES is defined in your
298 kernel configuration. If so, then you likely need to raise all Xenomai
299 parameters defining the size of internal heaps, such as
300 CONFIG_XENO_OPT_SYS_HEAPSZ, CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ,
301 CONFIG_XENO_OPT_SEM_HEAPSZ and CONFIG_XENO_OPT_SYS_STACKPOOLSZ, so that (size /
302 64k) > 2. The default values for these parameters are currently based on the
303 assumption that PAGE_SIZE = 4k.
306 3. Problems when running the latency test
307 The first test to run to see if Xenomai is running correctly on your platform
308 is the latency test. The following sections describe the usual reasons for this
309 test not to run correctly.
311 3.1. Xenomai: binding failed: Operation not permitted
313 This error message means that you are trying to run the latency test as a
314 non-root user. Using Xenomai services requires root privileges (more precisely
315 CAP_SYS_NICE). However, you can allow a specific group to access Xenomai
316 services, by following the instructions on this page: 
317 "http://xenomai.org/index.php/Non-root_RT".
319 3.2. Xenomai: --enable-x86-sep needs NPTL and Linux 2.6.x or higher
321 On the x86 architecture, the configure script option --enable-x86-sep allows
322 Xenomai to use the SYSENTER/SYSEXIT mechanism for issuing system calls.
324 However, this mechanism requires support from the libc. Currently, we know the
325 glibc with NPTL has this support, other libraries will cause Xenomai
326 applications to fail with this error message.
328 3.3. latency: failed to open benchmark device
330 You have launched latency -t 1 or latency -t 2 which both require the kernel to
331 have been compiled with the CONFIG_XENO_DRIVERS_TIMERBENCH option enabled.
333 3.4. Hardware tsc is not a fast wrapping one
335 See the "ARM tsc emulation issues" section.
337 3.5. Xenomai: incompatible ABI revision level
339 Each Xenomai branch (2.1, 2.2, 2.3, 2.4, 2.5, 2.6,…) defines a kernel/user ABI,
340 so that it is possible to mix kernels and user-space supports of different
341 versions in the same branch. So, for instance, after having build a system with
342 a kernel and user-space support using Xenomai 2.6.0, it is possible to update
343 the user-space support to Xenomai 2.6.1 without changing the kernel.
345 However, it is not possible to mix kernel and user-space supports of different
346 branches.
348 A common reason for this error is when you run a kernel compiled with Xenomai
349 2.6.1 support on a system where you have a user-space installed by your Debian
350 based Linux distribution (notably Ubuntu) from the 2.5 branch, this can not
351 work, the two branches use different ABIs. See README.INSTALL for details on
352 how to compile a user-space support, or to build a new xenomai-runtime Debian
353 package.
355 If you compiled and installed the correct Xenomai user-space support, there are
356 probably files on your system remaining from a previous installation.
358 3.6. Xenomai: incompatible feature set
360 Since kernel-space support and user-space support are compiled separately, each
361 Xenomai application checks, at startup, whether the kernel and user-space
362 supports have been configured with compatible options. If you see this message,
363 it means they have not. See README.INSTALL for further details. The following
364 sections detail the most frequent reasons for this message.
366 3.6.1. missing="kuser_tsc"
368 See the "ARM tsc emulation issues" section.
370 3.6.2. missing="sep"
372 On the x86 architecture, the configure script option --enable-x86-sep allows
373 Xenomai to use the SYSENTER/SYSEXIT mechanism for issuing system calls.
375 However, this mechanism requires a recent kernel (2.6 or higher).
377 3.6.3. missing="smp/nosmp"
379 On some SMP-capable architectures, for kernel-space and user-space supports to
380 be compatible, both should be compiled with the same setting for SMP.
382 SMP support in kernel-space is enabled with the CONFIG_SMP option.
384 For these architectures, SMP support in user-space is enabled by passing
385 --enable-smp to the configure script, and disabled by passing --disable-smp
386 (SMP is enabled by default on some platforms).
388 Other SMP-capable architectures may run userland code built with --enable-smp
389 or --disable-smp over the same kernel indifferently, at no noticeable
390 performance cost. These architectures never receive such SMP-related error.
392 3.6.4. missing="tsc"
394 This error is specific to the x86 architecture. You enabled tsc in user-space
395 by passing the --enable-x86-tsc option, but you selected a processor when
396 configuring the kernel which has no tsc.
398 So, if your processor has a tsc (all Intel processors starting with some
399 Pentium and Pentium Pro have a tsc), you probably mis-configured your kernel
400 and should select the exact processor you are using in the kernel configuration
401 and recompile it.
403 If your processor does not have a tsc, you should not pass the --enable-x86-tsc
404 option to the configure script.
406 3.7. Xenomai: kernel/user tsc emulation mismatch
408 See the "ARM tsc emulation issues" section.
410 3.8. Xenomai: native skin or CONFIG_XENO_OPT_PERVASIVE disabled
412 Possible reasons for this error are:
414   * you booted a kernel without Xenomai or I-pipe support, a kernel with I-pipe
415     and Xenomai support should have a /proc/ipipe/version and /proc/xenomai/
416     version files;
417   * the kernel you booted does not have the CONFIG_XENO_SKIN_NATIVE and
418     CONFIG_XENO_OPT_PERVASIVE options enabled;
419   * Xenomai failed to start, check the "Xenomai or I-pipe error in the kernel
420     log" section;
421   * you are trying to run Xenomai user-space support compiled for x86_32 on an
422     x86_64 kernel.
424 3.9. latency: not found
426 On the ARM platform this message happens when there is a mismatch between
427 kernel and user for the EABI setting: for instance you compiled the user-space
428 support with a toolchain generating OABI code, and are trying to run the result
429 on a kernel with CONFIG_AEABI but without CONFIG_OABI_COMPAT. Or vice versa,
430 when running user-space compiled with an EABI toolchain on a kernel without
431 CONFIG_AEABI.
433 3.10. Xenomai: watchdog triggered (period too short?)
435 Xenomai watchdog has stopped the latency test because it was using all the CPU
436 in primary mode. This is likely due to a too short period, re-run the latency
437 test passing a longer period using the -p option.
439 3.11. Xenomai: Your board/configuration does not allow tsc emulation
441 See the "ARM tsc emulation issues" section.
443 3.12. the latency test hangs
445 The most common reason for this issues is a too short period passed with the -p
446 option, try increasing the period. If you enable the watchdog (option
447 CONFIG_XENO_OPT_WATCHDOG, in your kernel configuration), you should see the
448 "Xenomai: watchdog triggered (period too short?)" message.
450 3.13. the latency test shows high latencies
452 The latency test runs, but you are seeing high latencies.
454   * make sure that you carefully followed the "Kernel configuration" section.
455   * make sure that you do not have an issue with SMIs, see the section about
456     SMIs.
457   * if you have some legacy USB switch at BIOS configuration level, try
458     disabling it.
459   * if you do not have this option at BIOS configuration level, it does not
460     necessarily mean that there is no support for it, thus no potential for
461     high latencies; this support might just be forcibly enabled at boot time.
462     To solve this, in case your machine has some USB controller hardware, make
463     sure to enable the corresponding host controller driver support in your
464     kernel configuration. For instance, UHCI-compliant hardware needs
465     CONFIG_USB_UHCI_HCD. As part of its init chores, the driver should reset
466     the host controller properly, kicking out the BIOS off the concerned
467     hardware, and deactivate the USB legacy mode if set in the same move.
468   * if you observe high latencies while running X-window, try disabling
469     hardware acceleration in the X-window server file. With recent versions of
470     X-window, try using the fbdev driver. Install it (Debian package named 
471     xserver-xorg-video-fbdev for instance), then modifiy the Device section to
472     use this driver in /etc/X11/xorg.conf, as in:
474 Section "Device"
475         Identifier  "Card0"
476         Driver      "fbdev"
477 EndSection
479 With olders versions of X-window, keep the existing driver, but add the
480 following line to the Device section:
482         Option "NoAccel"
484 3.14. ARM tsc emulation issues
486 In order to allow applications to measure short durations with as little
487 overhead as possible, Xenomai uses a 64 bits high resolution counter. On x86,
488 the counter used for this purpose is the time-stamp counter, aka "tsc".
490 ARM processors generally do not have a 64 bits high resolution counter
491 available in user-space, so this counter is emulated by reading whatever high
492 resolution counter is available on the processor, and used as clock source in
493 kernel-space, and extend it to 64 bits by using data shared with the kernel. If
494 Xenomai libraries are compiled without emulated tsc support, system calls are
495 used, which have a much higher overhead than the emulated tsc code.
497 In recent versions of the I-pipe patch, SOCs generally select the
498 CONFIG_IPIPE_ARM_KUSER_TSC option, which means that the code for reading this
499 counter is provided by the kernel at a predetermined address (in the vector
500 page, a page which is mapped at the same address in every process) and is the
501 code used if you do not pass the --enable-arm-tsc or --disable-arm-tsc option
502 to configure, or pass --enable-arm-tsc=kuser.
504 This default should be fine with recent patches and most ARM SOCs.
506 However, if you see the following message:
508 Xenomai: incompatible feature set
509 (userland requires "kuser_tsc...", kernel provides..., missing="kuser_tsc")
511 It means that you are either using an old patch, or that the SOC you are using
512 does not select the CONFIG_IPIPE_ARM_KUSER_TSC option.
514 So you should resort to what Xenomai did before branch 2.6: select the tsc
515 emulation code when compiling Xenomai user-space support by using the
516 --enable-arm-tsc option. The parameter passed to this option is the name of the
517 SOC or SOC family for which you are compiling Xenomai. Typing:
519 /patch/to/xenomai/configure --help
521 will return the list of valid values for this option.
523 If after having enabled this option and recompiled, you see the following
524 message when starting the latency test:
526 Xenomai: kernel/user tsc emulation mismatch
530 Hardware tsc is not a fast wrapping one
532 It means that you selected the wrong SOC or SOC family, reconfigure Xenomai
533 user-space support by passing the right parameter to --enable-arm-tsc and
534 recompile.
536 The following message:
538 Xenomai: Your board/configuration does not allow tsc emulation
540 means that the kernel-space support for the SOC you are using does not provide
541 support for tsc emulation in user-space. In that case, you should recompile
542 Xenomai user-space support passing the --disable-arm-tsc option.
544 4. switchtest fails with "pthread_create: Resource temporarily
545 unavailable"
547 The switchtest test creates many kernel threads, this means that the options
548 CONFIG_XENO_OPT_SYS_HEAPSZ and CONFIG_XENO_OPT_SYS_STACKPOOLSZ, in your kernel
549 configuration, should be configured to large enough values. Try increasing them
550 and recompiling the kernel.
553 5.1. 2.6.2/x86
555 2.6.2 (like any previous Xenomai release) does not handle the extended
556 5. Known Bugs and Limitations
557 processor state (xsave/xrstor) yet.
559 2.6.2 automatically disables this CPU feature at boot when the host kernel
560 detects it, so no action is to be taken by the user. However, this feature
561 shall be disabled manually for older Xenomai releases, by passing the "noxsave"
562 parameter on the kernel command line (see Documentation/kernel-parameters.txt).
564 Failing to do so, running with extended processor state support enabled on
565 these Xenomai releases beget random execution errors in userland, typically
566 when the switchtest program runs in the background, due to incorrect FPU
567 management in real-time mode.
570 6.1. "Warning: <service> is deprecated" while compiling kernel code
572 6. Problem with my code (not Xenomai code)
573 Where <service> is a thread creation service, one of:
575   * cre_tsk
576   * pthread_create
577   * rt_task_create
578   * sc_tecreate or sc_tcreate
579   * taskSpawn or taskInit
580   * t_create
582 Starting with Xenomai 3, the skins will not export their interface to kernel
583 modules anymore, at the notable exception of the RTDM device driver API, which
584 by essence must be used from kernel space for writing real-time device drivers.
585 Those warnings are there to remind you that application code should run in
586 user-space context instead.
588 The reason for this is fully explained in the project Roadmap document, see
589 "What Will Change With Xenomai 3": 
590 "http://www.xenomai.org/index.php/Xenomai:Roadmap#What_Will_Change_With_Xenomai_3".
592 You may switch those warnings off by enabling the
593 CONFIG_XENO_OPT_NOWARN_DEPRECATED option in your kernel configuration, but
594 nevertheless, you have been WARNED.
596 6.2. "Xenomai: process memory not locked (missing mlockall?)" at startup
598 In order to avoid unwanted transitions to secondary domain, an application
599 using Xenomai services should call, before any Xenomai service:
601 mlockall(MCL_CURRENT | MCL_FUTURE);
603 Even if your system has no swap, the Linux kernel may "swap out" some pages,
604 for instance the program pages which are known to exist on flash or on disk,
605 causing page faults (and a secondary mode switch for xenomai threads running in
606 primary mode) when the program tries to access this page.
608 So, Xenomai libraries abort when an application which has not called mlockall
609 is detected.
611 Note that some skins allow mlockall to be called automatically by Xenomai
612 libraries startup, this is enabled when configuring Xenomai user-space support
613 with the configure script.
615 See configure --help.
617 6.3. High latencies when transitioning from primary to secondary mode
619 Such transition requires to wake up the Linux task underlying your real-time
620 thread when running in secondary mode, since the latter needs to leave the
621 Xenomai domain for executing under the control of the regular Linux scheduler.
622 Therefore, it all depends on the Linux kernel granularity, i.e. its ability to
623 reach the next rescheduling point as soon as such wakeup has been requested.
624 Additionally, the task wakeup request is performed from a virtual interrupt
625 handler which has to be run from the Linux domain upon request from the Xenomai
626 domain, so the time required to handle and dispatch this interrupt outside of
627 any critical kernel section also needs to be accounted for. Even if the kernel
628 granularity improves at each new release, there are still a few catches:
630   * Although the use of DMA might induce additional interrupt latency due to
631     bus bandwidth saturation, disabling it for disk I/O is a bad idea when
632     using mixed real-time modes. This is due to the fact that using PIO often
633     leads to lengthy non-preemptible sections of kernel code being run from
634     e.g. IDE drivers, from which pending real-time mode transitions could be
635     delayed. In the same vein, make sure that your IDE driver runs in unmasked
636     IRQ mode. In any case, a quick check using the "hdparm" tool will help:
638 # hdparm -v /dev/hda
640 /dev/hda:
641  ...
642  unmaskirq    =  1 (on)
643  using_dma    =  1 (on)
644  ...
646   * Even if your application does not directly request disk I/O, remember that
647     the kernel routinely performs housekeeping duties which do, like filesystem
648     journal updates or VM commits to the backing store, so latencies due to
649     improper disk settings may well trigger apparently randomly. Of course, if
650     your application only operates in primary mode during all of its time
651     critical duties, i.e. never request Linux syscalls, it will not be
652     adversely affected by DMA deactivation or IDE masking, since it will remain
653     in the Xenomai domain, and activities from such domain can preempt any
654     activity from the Linux domain, including disk drivers.
656 6.4. Any Xenomai service fails with code -38 (ENOSYS)
658 Possible reasons for this error are:
660   * you booted a kernel without Xenomai or I-pipe support, a kernel with I-pipe
661     and Xenomai support should have a /proc/ipipe/version and /proc/xenomai/
662     version files;
663   * the kernel you booted does not have the CONFIG_XENO_SKIN_* option enabled
664     for the skin you use, or CONFIG_XENO_OPT_PERVASIVE is disabled;
665   * Xenomai failed to start, check the "Xenomai or I-pipe error in the kernel
666     log" section;
667   * you are trying to run Xenomai user-space support compiled for x86_32 on an
668     x86_64 kernel.
670 6.5. My application reserves a lot of memory
672 Your user-space application unexpectedly reserves a lot of virtual memory, as
673 reported by "top" or /proc/<pid>/maps. Sometimes OOM situations even appear
674 during runtime on systems with limited memory.
676 The Xenomai tasks are underlaid by native POSIX threads, for which a huge
677 default amount of stack space memory is reserved by the native POSIX support,
678 usually 8MiB per thread, so the overall allocated space is about
679 8MiB * +nr_threads+, which are likely to be locked using the mlockall()
680 service, which in turn even commits such space to RAM.
682 Unfortunately, this behaviour cannot be controlled by the "stacksize" parameter
683 passed to the various thread creation routines, i.e. the latter is about
684 limiting the addressable stack space on a per-thread basis, but does not affect
685 the amount of stack memory initially reserved by the POSIX library. A
686 work-around consists of setting a lower user-limit for initial stack
687 allocation, like calling:
689 ulimit -s <initial-size-in-kbytes>
691 in your parent shell before running your application (defaults to 8192).