Skip to contentSkip to conversation

freeze on system() call

Xenomai-help [email protected] 3 participants 13 messages Mar 31, 2008 – Apr 3, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

A few months ago, my colleague Jerome Pasquero reported a problem with calls to system() with the 2.4 branch of Xenomai
(https://mail.gna.org/public/xenomai-help/2008-01/msg00047.html). I am experiencing the same problem with linux 2.6.24.4 and xenomai 2.4.2.

The problem occurs when calling system() or fork() in a realtime task. It only seems to occur when the program is linked against other libraries (e.g. -lxml2 or -lgtkmm-2.4). The mouse continues to function after the call but the system becomes unresponsive and must be rebooted.

The problem can be reproduced by compiling and running the following code:

gcc -lgtkmm-2.4 -lnative /usr/xenomai/bin/xeno-config --xeno-cflags /usr/xenomai/bin/xeno-config --xeno-ldflags -lstdc++ main.cpp

#include <native/task.h>
#include <sys/mman.h>
int main(int argc, char* argv[])

{
	RT_TASK task;
	mlockall(MCL_CURRENT | MCL_FUTURE);
	rt_task_shadow(&task, "stress-gui", 50, 0);
	system("ls");
	return 0;
};

I tried to apply the patch suggested by Jan Kiszka
(https://mail.gna.org/public/xenomai-help/2008-01/msg00051.html) but I wasn't able to find the version of linux kernel and xenomai that the patch was intended for.

I would appreciate your help to resolve or work around this problem. I am using the system() calls to insert and remove modules with modprobe and rmmod. Is there a better way to accomplish the same result? Is there a way to terminate a realtime task and resume normal execution? I could then execute the modprobe and rmmod commands before and after running the realtime tasks.

Thank you,

Vincent Levesque
[email protected]

#1 lore raw
Quoted 11 lines · [email protected] wrote:

Hello,

A few months ago, my colleague Jerome Pasquero reported a problem with calls to system() with the 2.4 branch of Xenomai
(https://mail.gna.org/public/xenomai-help/2008-01/msg00047.html). I am experiencing the same problem with linux 2.6.24.4 and xenomai 2.4.2.

The problem occurs when calling system() or fork() in a realtime task. It only seems to occur when the program is linked against other libraries (e.g. -lxml2 or -lgtkmm-2.4). The mouse continues to function after the call but the system becomes unresponsive and must be rebooted.

I see you are talking about the mouse, are you running under X-windows ? If yes, could you try to run your example in the console ? This way you could see some kernel oops if one occurs.

Signature · 1 line
					    Gilles.
#2 lore raw

Thanks for the tip. I tried and did indeed get error messages. Unfortunately
I haven't been able to redirect these errors to a file or to find any
reference to them in /var/log/. The best I could do was to take a picture of
the screen: http://www.cim.mcgill.ca/~vleves/oops.jpg<http://www.cim.mcgill.ca/%7Evleves/oops.jpg>.
Please let me know if I can do anything else.

Thanks,

Vincent Levesque
[email protected]

Quoted 5 lines · Gilles Chanteperdrix

<[email protected]>
I see you are talking about the mouse, are you running under X-windows ? If yes, could you try to run your example in the console ? This way you could see some kernel oops if one occurs.

#3 lore raw
Quoted 5 lines · Vincent Levesque

Thanks for the tip. I tried and did indeed get error messages. Unfortunately
I haven't been able to redirect these errors to a file or to find any
reference to them in /var/log/. The best I could do was to take a picture of
the screen: http://www.cim.mcgill.ca/~vleves/oops.jpg<http://www.cim.mcgill.ca/%7Evleves/oops.jpg>.
Please let me know if I can do anything else.

At first sight, it looks like you have the same issue with kmap_atomic as Tomas. Could you try and increase resolution so that we get the beginning of the oops ? Enable "Video mode selection support" in "Console display driver support" menu, then pass something like vga=0x0F01 on kernel command line. Also enable frame pointers in the kernel if they are disabled.

Signature · 1 line
					    Gilles.
#4 lore raw

Hi Gilles,

Thanks for walking me through this. I did as you suggested and grabbed this more complete screenshot (stitched from two pictures):
http://www.cim.mcgill.ca/~vleves/oops-full.jpg.

Vincent Levesque
[email protected]

Quoted 22 lines · Gilles Chanteperdrix
Quoted 1 line · Vincent Levesque

Thanks for the tip. I tried and did indeed get error messages.

Unfortunately

Quoted 2 lines

I haven't been able to redirect these errors to a file or to find any reference to them in /var/log/. The best I could do was to take a

picture of

Quoted 1 line

the screen: http://www.cim.mcgill.ca/~vleves/oops.jpg<http://www.cim.mcgill.ca/%7Evleves/oops.jpg>

<http://www.cim.mcgill.ca/%7Evleves/oops.jpg>.

Quoted 1 line

Please let me know if I can do anything else.

At first sight, it looks like you have the same issue with kmap_atomic as Tomas. Could you try and increase resolution so that we get the beginning of the oops ? Enable "Video mode selection support" in "Console display driver support" menu, then pass something like vga=0x0F01 on kernel command line. Also enable frame pointers in the kernel if they are disabled.

--

Gilles.

#6 lore raw

Hi Gilles,

I tried the patch on both linux-2.6.24.4+xeno-2.4.2 and linux2.6.24.3+xeno-2.4.2 (like Tomas). In both cases I get errors messages when patching:

[email protected]# patch -p1 < 6.patch
patching file include/linux/mm.h
Hunk #1 FAILED at 104.
1 out of 1 hunk FAILED -- saving rejects to file include/linux/mm.h.rej
patching file mm/memory.c
Hunk #1 FAILED at 584.
1 out of 1 hunk FAILED -- saving rejects to file mm/memory.c.rej

Am I using the right version of linux and xenomai? Was I supposed to apply other patches first? I had to fix the patch a bit (line endings were mangled in the email) but I don't think I broke anything.

Out of curiosity, can you reproduce the bug?

Thanks,

--VL

#7 lore raw
Quoted 14 lines · Vincent Levesque

Hi Gilles,

I tried the patch on both linux-2.6.24.4+xeno-2.4.2 and linux2.6.24.3+xeno-2.4.2 (like Tomas). In both cases I get errors messages when patching:

[email protected]# patch -p1 < 6.patch
 patching file include/linux/mm.h
Hunk #1 FAILED at 104.
1 out of 1 hunk FAILED -- saving rejects to file include/linux/mm.h.rej
patching file mm/memory.c
Hunk #1 FAILED at 584.
1 out of 1 hunk FAILED -- saving rejects to file mm/memory.c.rej
Quoted 3 lines

Am I using the right version of linux and xenomai? Was I supposed to apply other patches first? I had to fix the patch a bit (line endings were mangled in the email) but I don't think I broke anything.

What do the rejects look like ?

Quoted 2 lines

Out of curiosity, can you reproduce the bug?

I have not tried yet.

Signature · 1 line
 Gilles
#8 lore raw

I'm attaching the files. -- VL

Quoted 26 lines · Gilles Chanteperdrix
Quoted 4 lines · Vincent Levesque

Hi Gilles,

I tried the patch on both linux-2.6.24.4+xeno-2.4.2 and linux2.6.24.3+xeno-2.4.2 (like Tomas). In both cases I get errors

messages

Quoted 11 lines

when patching:

[email protected]# patch -p1 < 6.patch
 patching file include/linux/mm.h
Hunk #1 FAILED at 104.
1 out of 1 hunk FAILED -- saving rejects to file include/linux/mm.h.rej
patching file mm/memory.c
Hunk #1 FAILED at 584.
1 out of 1 hunk FAILED -- saving rejects to file mm/memory.c.rej

Am I using the right version of linux and xenomai? Was I supposed to

apply

Quoted 1 line

other patches first? I had to fix the patch a bit (line endings were

mangled

Quoted 1 line

in the email) but I don't think I broke anything.

What do the rejects look like ?

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Out of curiosity, can you reproduce the bug?

I have not tried yet.

--
Gilles

include/linux/mm.h +2 -1
index 7f27db6..a0c80c7 100644
@@ -104,10 +104,11 @@ extern unsigned int kobjsize(const void *objp);
 #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_ALWAYSDUMP  0x04000000      /* Always include in core dumps */
-#define VM_PINNED      0x08000000      /* Disable faults for the vma */
 
 #define VM_CAN_NONLINEAR 0x08000000    /* Has ->fault & does nonlinear pages */
 
+#define VM_PINNED      0x10000000      /* Disable faults for the vma */
+
 #ifndef VM_STACK_DEFAULT_FLAGS         /* arch can override this */
 #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
 #endif
mm/memory.c +7 -1
index e0e7a3d..32d6cb6 100644
@@ -584,8 +584,14 @@ again:
                        if (is_cow_mapping(vma->vm_flags)) {
                                if (((vma->vm_flags|src_mm->def_flags) & (VM_LOCKED|VM_PINNED))
                                    == (VM_LOCKED|VM_PINNED)) {
+                                       arch_leave_lazy_mmu_mode();
+                                       spin_unlock(src_ptl);
+                                       pte_unmap_nested(src_pte);
+                                       add_mm_rss(dst_mm, rss[0], rss[1]);
+                                       pte_unmap_unlock(dst_pte, dst_ptl);
+                                       cond_resched();
                                        do_cow_break = 1;
-                                       break;
+                                       goto again;
                                }
                        }
                }
#9 lore raw
Quoted 1 line · Vincent Levesque

I'm attaching the files. -- VL

The patch applies to a kernel patched with the I-pipe patch. Are the kernel sources you are trying to patch, already patched with the I-pipe patch ?

Signature · 1 line
 Gilles
#10 lore raw

Yes. I just repeated the process with fresh sources to be sure. I'm attaching all the relevant files, including a log of scripts/prepare_kernel.sh. This time I used linux-2.6.24.4 (from kernel.org) and xenomai 2.4.2.

--VL

Quoted 11 lines · Gilles Chanteperdrix
Quoted 1 line · Vincent Levesque

I'm attaching the files. -- VL

The patch applies to a kernel patched with the I-pipe patch. Are the kernel sources you are trying to patch, already patched with the I-pipe patch ?

--
Gilles

root@vleves-desktop:/usr/src/xenomai-2.4.2# scripts/prepare-kernel.sh 
Linux tree [default /lib/modules/2.6.22-14-generic/source]: /usr/src/linux-2.6.24.4-xn242
Target architecture [default i686]: 
Adeos patch [default /usr/src/xenomai-2.4.2/ksrc/arch/x86/patches/adeos-ipipe-2.6.24-x86-2.0-03.patch]: 
patching file Makefile
patching file arch/x86/Kconfig
patching file arch/x86/Makefile_32
patching file arch/x86/boot/Makefile
patching file arch/x86/boot/compressed/Makefile_32
patching file arch/x86/kernel/Makefile_32
Hunk #1 succeeded at 35 (offset 1 line).
patching file arch/x86/kernel/Makefile_64
patching file arch/x86/kernel/apic_32.c
patching file arch/x86/kernel/apic_64.c
patching file arch/x86/kernel/cpu/mtrr/cyrix.c
patching file arch/x86/kernel/cpu/mtrr/generic.c
patching file arch/x86/kernel/entry_32.S
patching file arch/x86/kernel/entry_64.S
patching file arch/x86/kernel/genapic_flat_64.c
patching file arch/x86/kernel/head64.c
patching file arch/x86/kernel/i8253.c
patching file arch/x86/kernel/i8259_32.c
patching file arch/x86/kernel/i8259_64.c
patching file arch/x86/kernel/io_apic_32.c
patching file arch/x86/kernel/io_apic_64.c
patching file arch/x86/kernel/ipipe.c
patching file arch/x86/kernel/mcount_32.S
patching file arch/x86/kernel/mcount_64.S
patching file arch/x86/kernel/nmi_32.c
patching file arch/x86/kernel/nmi_64.c
patching file arch/x86/kernel/process_32.c
patching file arch/x86/kernel/process_64.c
Hunk #3 succeeded at 234 (offset -1 lines).
Hunk #4 succeeded at 286 (offset -1 lines).
Hunk #5 succeeded at 507 (offset -1 lines).
Hunk #6 succeeded at 605 (offset -1 lines).
patching file arch/x86/kernel/setup64.c
patching file arch/x86/kernel/smp_32.c
patching file arch/x86/kernel/smp_64.c
patching file arch/x86/kernel/smpboot_32.c
patching file arch/x86/kernel/smpboot_64.c
patching file arch/x86/kernel/time_32.c
patching file arch/x86/kernel/traps_32.c
patching file arch/x86/kernel/traps_64.c
patching file arch/x86/kernel/vm86_32.c
patching file arch/x86/kernel/vsyscall_64.c
patching file arch/x86/lib/mmx_32.c
patching file arch/x86/lib/thunk_64.S
patching file arch/x86/mach-visws/visws_apic.c
patching file arch/x86/mm/fault_32.c
patching file arch/x86/mm/fault_64.c
patching file drivers/pci/htirq.c
patching file drivers/serial/8250.c
patching file include/asm-x86/apic_32.h
patching file include/asm-x86/apic_64.h
patching file include/asm-x86/hw_irq_32.h
patching file include/asm-x86/hw_irq_64.h
patching file include/asm-x86/i8259.h
patching file include/asm-x86/io_apic_64.h
Hunk #1 succeeded at 131 with fuzz 2.
patching file include/asm-x86/ipi.h
patching file include/asm-x86/ipipe.h
patching file include/asm-x86/ipipe_32.h
patching file include/asm-x86/ipipe_64.h
patching file include/asm-x86/ipipe_base.h
patching file include/asm-x86/ipipe_base_32.h
patching file include/asm-x86/ipipe_base_64.h
patching file include/asm-x86/irqflags_32.h
patching file include/asm-x86/irqflags_64.h
patching file include/asm-x86/mmu_context_32.h
patching file include/asm-x86/mmu_context_64.h
patching file include/asm-x86/nmi_32.h
patching file include/asm-x86/nmi_64.h
patching file include/asm-x86/processor_64.h
patching file include/asm-x86/spinlock_32.h
patching file include/asm-x86/system_64.h
patching file include/asm-x86/unistd_64.h
patching file include/asm-x86/vsyscall.h
patching file include/linux/hardirq.h
patching file include/linux/ipipe.h
patching file include/linux/ipipe_base.h
patching file include/linux/ipipe_compat.h
patching file include/linux/ipipe_percpu.h
patching file include/linux/ipipe_tickdev.h
patching file include/linux/ipipe_trace.h
patching file include/linux/irq.h
Hunk #2 succeeded at 378 with fuzz 2 (offset 3 lines).
patching file include/linux/kernel.h
patching file include/linux/linkage.h
patching file include/linux/mm.h
patching file include/linux/preempt.h
patching file include/linux/sched.h
patching file include/linux/spinlock.h
patching file include/linux/spinlock_types.h
patching file init/Kconfig
patching file init/main.c
patching file kernel/Makefile
patching file kernel/exit.c
patching file kernel/fork.c
patching file kernel/ipipe/Kconfig
patching file kernel/ipipe/Kconfig.debug
patching file kernel/ipipe/Makefile
patching file kernel/ipipe/core.c
patching file kernel/ipipe/tracer.c
patching file kernel/irq/chip.c
Hunk #1 succeeded at 353 (offset 18 lines).
Hunk #2 succeeded at 432 (offset 18 lines).
Hunk #3 succeeded at 482 (offset 18 lines).
Hunk #4 succeeded at 525 (offset 18 lines).
Hunk #5 succeeded at 653 (offset 18 lines).
Hunk #6 succeeded at 683 (offset 18 lines).
Hunk #7 succeeded at 722 (offset 18 lines).
Hunk #8 succeeded at 742 (offset 18 lines).
patching file kernel/power/disk.c
patching file kernel/power/swsusp.c
patching file kernel/printk.c
patching file kernel/sched.c
Hunk #9 succeeded at 4361 with fuzz 2 (offset -2 lines).
Hunk #10 succeeded at 7415 (offset -4 lines).
patching file kernel/signal.c
patching file kernel/spinlock.c
patching file kernel/time/tick-common.c
patching file lib/Kconfig.debug
patching file lib/bust_spinlocks.c
patching file lib/ioremap.c
patching file lib/smp_processor_id.c
patching file lib/spinlock_debug.c
patching file mm/memory.c
Hunk #7 succeeded at 1569 (offset 2 lines).
Hunk #8 succeeded at 2801 (offset 2 lines).
patching file mm/mlock.c
patching file mm/vmalloc.c
include/linux/mm.h +2 -1
index 7f27db6..a0c80c7 100644
@@ -104,10 +104,11 @@ extern unsigned int kobjsize(const void *objp);
 #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_ALWAYSDUMP  0x04000000      /* Always include in core dumps */
-#define VM_PINNED      0x08000000      /* Disable faults for the vma */
 
 #define VM_CAN_NONLINEAR 0x08000000    /* Has ->fault & does nonlinear pages */
 
+#define VM_PINNED      0x10000000      /* Disable faults for the vma */
+
 #ifndef VM_STACK_DEFAULT_FLAGS         /* arch can override this */
 #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
 #endif
mm/memory.c +7 -1
index e0e7a3d..32d6cb6 100644
@@ -584,8 +584,14 @@ again:
                        if (is_cow_mapping(vma->vm_flags)) {
                                if (((vma->vm_flags|src_mm->def_flags) & (VM_LOCKED|VM_PINNED))
                                    == (VM_LOCKED|VM_PINNED)) {
+                                       arch_leave_lazy_mmu_mode();
+                                       spin_unlock(src_ptl);
+                                       pte_unmap_nested(src_pte);
+                                       add_mm_rss(dst_mm, rss[0], rss[1]);
+                                       pte_unmap_unlock(dst_pte, dst_ptl);
+                                       cond_resched();
                                        do_cow_break = 1;
-                                       break;
+                                       goto again;
                                }
                        }
                }
#11 lore raw
Quoted 4 lines · Vincent Levesque

Yes. I just repeated the process with fresh sources to be sure. I'm attaching all the relevant files, including a log of scripts/prepare_kernel.sh. This time I used linux-2.6.24.4 (from kernel.org) and xenomai 2.4.2.

The patch you have got is whitespace damaged. Here comes the good one.

Signature · 1 line
 Gilles
include/linux/mm.h +2 -1
index 7f27db6..a0c80c7 100644
@@ -104,10 +104,11 @@ extern unsigned int kobjsize(const void *objp);
 #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_ALWAYSDUMP	0x04000000	/* Always include in core dumps */
-#define VM_PINNED	0x08000000	/* Disable faults for the vma */
 
 #define VM_CAN_NONLINEAR 0x08000000	/* Has ->fault & does nonlinear pages */
 
+#define VM_PINNED	0x10000000	/* Disable faults for the vma */
+
 #ifndef VM_STACK_DEFAULT_FLAGS		/* arch can override this */
 #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
 #endif
mm/memory.c +7 -1
index e0e7a3d..32d6cb6 100644
@@ -584,8 +584,14 @@ again:
 			if (is_cow_mapping(vma->vm_flags)) {
 				if (((vma->vm_flags|src_mm->def_flags) & (VM_LOCKED|VM_PINNED))
 				    == (VM_LOCKED|VM_PINNED)) {
+				    	arch_leave_lazy_mmu_mode();
+				    	spin_unlock(src_ptl);
+				    	pte_unmap_nested(src_pte);
+				    	add_mm_rss(dst_mm, rss[0], rss[1]);
+				    	pte_unmap_unlock(dst_pte, dst_ptl);
+				    	cond_resched();
 					do_cow_break = 1;
-					break;
+					goto again;
 				}
 			}
 		}
#12 lore raw

The patch seems to resolve the problem. Thanks for your help!

Vincent Levesque
[email protected]

Quoted 1 line

The patch you have got is whitespace damaged. Here comes the good one.