Skip to contentSkip to conversation

Pagefaults during mlocked Realtime task

Xenomai-help Henri Roosen 2 participants 8 messages Jul 28, 2009 – Aug 17, 2009

lore
Share & tools
lore
#0 lore raw

Hi everyone,

I have a basic Xenomai realtime user task which does a read call to a basic RTDM driver. The problem is that the realtime task is generating pagefaults when the system is under heavy network load even while the current and future memory is locked with mlockall(MCL_CURRENT | MCL_FUTURE);. There should also be enough free memory.

Both the MSW and PF go up when showing the stat. So the realtime task switches to the secondary domain causing long latencies which we don't want.

(Aside from that I just want to mention that when we generate the high load on the usb-gadget ethernet interface (g_ether), the realtime task even gets defunct or generates a segfault. I first want to understand the pagefaults when using the normal ethernet interface, which might then later explain the things we are seeing using the usb-gadget interface.)

I used the sigxcpu.c example to try to find the root of the pagefaults, but that only provides me one address which seems to be on the [stack] according to the process maps. Running the app in the debugger halts when the signal triggers and the call stack shows it is
at <rt_dev_read+60>: pop {r4, r7, pc}
I cannot really find anything in our driver code (rt_dev_read) or realtime app that would generate these pagefaults.

Any help to explain and get rid of the pagefaults is very welcome!

I am currently running a 2.6.28 linux kernel and Xenomai version 2.4.8 on an ARM926EJ-S (at91sam9263ek) processor, using the EABI and -msoft-float cross compiled with CodeSourcery 2007q3.

[email protected]:~# free
Unknown HZ value! (86) Assume 100.
             total       used       free     shared    buffers     cached
Mem:         60788      17100      43688          0        564       7464
-/+ buffers/cache:       9072      51716
Swap:            0          0          0
[email protected]:~# cat /proc/xenomai/stat
CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          9310038    0     00500080   49.7  ROOT
  0  1317   7          4223140    7     00320182   47.8  RTT
  0  0      0          1356807    0     00000000    0.2  IRQ19: [timer]
  0  0      0          13455406   0     00000000    2.1  IRQ31: fpga

Thanks,
Henri

#1 lore raw
Quoted 27 lines · Henri Roosen

Hi everyone,

I have a basic Xenomai realtime user task which does a read call to a basic RTDM driver. The problem is that the realtime task is generating pagefaults when the system is under heavy network load even while the current and future memory is locked with mlockall(MCL_CURRENT | MCL_FUTURE);. There should also be enough free memory.

Both the MSW and PF go up when showing the stat. So the realtime task switches to the secondary domain causing long latencies which we don't want.

(Aside from that I just want to mention that when we generate the high load on the usb-gadget ethernet interface (g_ether), the realtime task even gets defunct or generates a segfault. I first want to understand the pagefaults when using the normal ethernet interface, which might then later explain the things we are seeing using the usb-gadget interface.)

I used the sigxcpu.c example to try to find the root of the pagefaults, but that only provides me one address which seems to be on the [stack] according to the process maps. Running the app in the debugger halts when the signal triggers and the call stack shows it is
at <rt_dev_read+60>: pop {r4, r7, pc}
I cannot really find anything in our driver code (rt_dev_read) or realtime app that would generate these pagefaults.

Quoted 5 lines

Any help to explain and get rid of the pagefaults is very welcome!

I am currently running a 2.6.28 linux kernel and Xenomai version 2.4.8 on an ARM926EJ-S (at91sam9263ek) processor, using the EABI and -msoft-float cross compiled with CodeSourcery 2007q3.

Do you have the same behaviour while running the Xenomai latency test. If not, without seeing your code, there is not much we can tell. One thing to look for, however is the unaligned accesses. Also, do you have FCSE enabled?

Signature · 1 line
                                          Gilles
#2 lore raw

We have not much progress tracing the problem so far. But in parallel to the tracing we also updated a kernel to the latest xenomai git status of the 2.4.8 branch, just to see whether we are not facing problems that are solved already.

This version however crashes and dumps its call-stack directly when starting the latency test application. Interesting is that it crashes at a check that is added recently in xnshadow_harden:
XENO_BUGON(NUCLEUS, !irqs_disable_hw());

Please find attached the .config

Quoted 43 lines · Gilles Chanteperdrix
Quoted 28 lines · Henri Roosen

Hi everyone,

I have a basic Xenomai realtime user task which does a read call to a basic RTDM driver. The problem is that the realtime task is generating pagefaults when the system is under heavy network load even while the current and future memory is locked with mlockall(MCL_CURRENT | MCL_FUTURE);. There should also be enough free memory.

Both the MSW and PF go up when showing the stat. So the realtime task switches to the secondary domain causing long latencies which we don't want.

(Aside from that I just want to mention that when we generate the high load on the usb-gadget ethernet interface (g_ether), the realtime task even gets defunct or generates a segfault. I first want to understand the pagefaults when using the normal ethernet interface, which might then later explain the things we are seeing using the usb-gadget interface.)

I used the sigxcpu.c example to try to find the root of the pagefaults, but that only provides me one address which seems to be on the [stack] according to the process maps. Running the app in the debugger halts when the signal triggers and the call stack shows it is at <rt_dev_read+60>: pop    {r4, r7, pc}
I cannot really find anything in our driver code (rt_dev_read) or realtime app that would generate these pagefaults.

Quoted 5 lines

Any help to explain and get rid of the pagefaults is very welcome!

I am currently running a 2.6.28 linux kernel and Xenomai version 2.4.8 on an ARM926EJ-S (at91sam9263ek) processor, using the EABI and -msoft-float cross compiled with CodeSourcery 2007q3.

Do you have the same behaviour while running the Xenomai latency test. If not, without seeing your code, there is not much we can tell. One thing to look for, however is the unaligned accesses. Also, do you have FCSE enabled?

--
                                         Gilles

#3 lore raw
Quoted 11 lines · Henri Roosen

We have not much progress tracing the problem so far. But in parallel to the tracing we also updated a kernel to the latest xenomai git status of the 2.4.8 branch, just to see whether we are not facing problems that are solved already.

This version however crashes and dumps its call-stack directly when starting the latency test application. Interesting is that it crashes at a check that is added recently in xnshadow_harden:
XENO_BUGON(NUCLEUS, !irqs_disable_hw());

Please find attached the .config

Ok. Thanks for reporting. I am afraid there is a hole in the way Xenomai 2.4 uses the Linux preemptible context switches. I do not even understand how it is supposed to have worked at one time.

It is my fault, of course, since I am always testing head with the full modification for unlocked context switches, and only 2.4 once in a while.

I will test this configuration and will keep you informed as soon as I have a fix.

Signature · 1 line
                                          Gilles
#4 lore raw
In reply to Henri Roosen
Quoted 11 lines · Henri Roosen

We have not much progress tracing the problem so far. But in parallel to the tracing we also updated a kernel to the latest xenomai git status of the 2.4.8 branch, just to see whether we are not facing problems that are solved already.

This version however crashes and dumps its call-stack directly when starting the latency test application. Interesting is that it crashes at a check that is added recently in xnshadow_harden:
XENO_BUGON(NUCLEUS, !irqs_disable_hw());

Please find attached the .config

Ok. I will propose a better fix later, but could you check the following quick fix?

ksrc/arch/arm/Kconfig +1 -1
index c79fe66..b62a14d 100644
@@ -10,7 +10,7 @@ depends on XENO_OPT_NUCLEUS
 
 config IPIPE_WANT_PREEMPTIBLE_SWITCH
        bool
-       default y
+       default n
 
 config XENO_HW_FPU
        bool "Enable FPU support"
Signature · 1 line
                                          Gilles
#5 lore raw

Unfortunately the latency app still crashes from xnshadow_harden with this patch.
Please find attached the updated .config.

Quoted 35 lines · Gilles Chanteperdrix
Quoted 11 lines · Henri Roosen

We have not much progress tracing the problem so far. But in parallel to the tracing we also updated a kernel to the latest xenomai git status of the 2.4.8 branch, just to see whether we are not facing problems that are solved already.

This version however crashes and dumps its call-stack directly when starting the latency test application. Interesting is that it crashes at a check that is added recently in xnshadow_harden:
XENO_BUGON(NUCLEUS, !irqs_disable_hw());

Please find attached the .config

Ok. I will propose a better fix later, but could you check the following quick fix?

ksrc/arch/arm/Kconfig +0 -0
index c79fe66..b62a14d 100644
@@ -10,7 +10,7 @@ depends on XENO_OPT_NUCLEUS
 

 config IPIPE_WANT_PREEMPTIBLE_SWITCH
       bool
-       default y
+       default n

 config XENO_HW_FPU
       bool "Enable FPU support"

--
                                         Gilles

#6 lore raw
Quoted 3 lines · Henri Roosen

Unfortunately the latency app still crashes from xnshadow_harden with this patch.
Please find attached the updated .config.

Ok. I will work on it tonight.

Signature · 1 line
                                          Gilles
#7 lore raw
In reply to Gilles Chanteperdrix
Quoted 23 lines · Gilles Chanteperdrix
Quoted 11 lines · Henri Roosen

We have not much progress tracing the problem so far. But in parallel to the tracing we also updated a kernel to the latest xenomai git status of the 2.4.8 branch, just to see whether we are not facing problems that are solved already.

This version however crashes and dumps its call-stack directly when starting the latency test application. Interesting is that it crashes at a check that is added recently in xnshadow_harden:
XENO_BUGON(NUCLEUS, !irqs_disable_hw());

Please find attached the .config

Ok. I will propose a better fix later, but could you check the following quick fix?

ksrc/arch/arm/Kconfig +0 -0
index c79fe66..b62a14d 100644

ksrc/arch/arm/Kconfig depends on XENO_OPT_NUCLEUS · line 16

Quoted 8 lines
ksrc/arch/arm/Kconfig +1 -1
@@ -10,7 +10,7 @@ depends on XENO_OPT_NUCLEUS
 
 config IPIPE_WANT_PREEMPTIBLE_SWITCH
        bool
-       default y
+       default n
 
 config XENO_HW_FPU
        bool "Enable FPU support"

Ok. The bug should now be fixed in the repository. But it requires a new I-pipe patch which should be available tomorrow.

Signature · 1 line
					    Gilles.