Page faults
I'm observing a considerable amount of Page Faults (5090 after an hour or so), each one associated with a MSW increase in /proc/xenomai/stat. I'm missing RT deadlines on those occasions and I want to fix it, so I would like to know what Page Faults actually are.
Jeroen.
Quoted 5 lines · Jeroen Van den Keybus
I'm observing a considerable amount of Page Faults (5090 after an hour or so), each one associated with a MSW increase in
/proc/xenomai/stat. I'm missing RT deadlines on those occasions and I want to fix it, so I would like to know what Page Faults actually are.
Maybe not all of your user memory is cleanly locked and got swapped out (swapping activated?). If you don't see kernel oopses and your programs don't receive segfaults, these faults are references to swapped out or not yet mapped in pages. BTW, what does the kernel console tell you?
The deadline misses as a result are "normal": your RT thread gets switched to secondary mode to handle the fault, and handling it may take some time...
Jan
Quoted 5 lines
Maybe not all of your user memory is cleanly locked and got swapped out (swapping activated?). If you don't see kernel oopses and your programs don't receive segfaults, these faults are references to swapped out or not yet mapped in pages. BTW, what does the kernel console tell you?
I have a mlockall(MCL_CURRENT | MCL_FUTURE) in my main() (non-RT) task alright. Do I need to repeat that for the real-time tasks as well ?
I'm quite certain that my kernel is configured for swapping. I did not see any harm in it, as a mlockall() was given. Should I try turning it off (if so, where) ?
I do not see 'oopses' and the dmesg log is clean, apart from one incidental spurious IRQ7 interrupt. Is 'dmesg' what you mean by 'kernel console' ?
Jeroen.
Quoted 8 lines · Jeroen Van den Keybus
Quoted 4 lines
Maybe not all of your user memory is cleanly locked and got swapped out (swapping activated?). If you don't see kernel oopses and your programs don't receive segfaults, these faults are references to swapped out or not yet mapped in pages. BTW, what does the kernel console tell you?
I have a
mlockall(MCL_CURRENT | MCL_FUTURE)in mymain()(non-RT) task alright. Do I need to repeat that for the real-time tasks as well ?
You should not have to. I observed some cases where malloc'ed memory was not immediately available, and you had to touch it first. I guess this depends on how glibc requests the memory. So, if unsure, do an memset on freshly allocated memory.
Quoted 4 lines
I'm quite certain that my kernel is configured for swapping. I did not see any harm in it, as a
mlockall()was given. Should I try turning it off (if so, where) ?
Swapping does not do any harm, correct. I just wanted to check what may trigger the problem.
Quoted 5 lines
I do not see 'oopses' and the dmesg log is clean, apart from one incidental spurious IRQ7 interrupt. Is 'dmesg' what you mean by 'kernel console' ?
Ah, I oversaw some dependency. Try to enable CONFIG_XENO_OPT_DEBUG. Then the nucleus should spit out which task is being relaxed due to faults:
"Switching XYZ to secondary mode after exception #? from user-space at 0x??? (pid ?)"
Jan
Quoted 2 lines · Jeroen Van den Keybus
I'm observing a considerable amount of Page Faults (5090 after an hour or so), each one associated with a MSW increase in
/proc/xenomai/stat. I'm missing RT deadlines on those occasions and I want to fix it, so I would like to know what Page Faults actually are.
Since page faults cause mode switches as you observed, you might want to try using a built-in feature that sends a SIGXCPU signal to a task going back to the Linux domain (e.g. typically relaxing to process a fault). The way to do this is as follows:
- set the T_WARNSW bit for your task using the rt_task_set_mode() call. Something like rt_task_set_mode(0,T_WARNSW,NULL) would do.
- code a Linux signal handler, and register it for receiving SIGXCPU.
The signal is always sent on behalf of the relaxing task, so you just need to inspect the backtrace to discover the cause of the mode switch by analysing the inner frames. You may either use GDB and set a breakpoint in the handler, or play with the backtrace_*() routines available from the glibc.
ksrc/skins/native/snippets/sigxcpu.c gives an example of such use.
Quoted 10 lines
Jeroen.
------------------------------------------------------------------------
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Debugging tools also suggested 'normal' pagefaults. Made me look for the mlockall() call which turns out to be unsuccessful. I made a mistake in evaluating its (non-zero) return value, which caused the error to go by unnoticed.
The reason mlockall() fails is that I executed the real-time program as non-root. (Guess I'll have to figure out that daunting sudoers thing...)
Thanks for your advice, which led me in the right direction.
Jeroen.