Skip to contentSkip to conversation

Sleeping function called from invalid context

Xenomai Stoidner, Christoph 2 participants 22 messages Dec 6, 2014 – Dec 10, 2014

lore
Share & tools
lore
#0 lore raw

Hi at all,

I am using linux 3.10.18 and ipipe-core-3.10.18-arm-1 on a Freescale i.MX28. I have also merged PREEMPT RT rt14 into the kernel. FCSE is disabled.

I have enabled several debug options in the kernel. When a started program exits I get the message below:

[   33.187104] BUG: sleeping function called from invalid context at kernel/rtmutex.c:659
[   33.187125] in_atomic(): 1, irqs_disabled(): 128, pid: 87, name: 
[   33.187138] 1 lock held by /87:
[   33.187213]  #0:  (rcu_read_lock){......}, at: [<c002add8>] __lock_task_sighand+0x24/0xf4
[   33.187232] Preemption disabled at:[<  (null)>]   (null)
[   33.187237] 
[   33.187262] CPU: 0 PID: 87 Comm:  Not tainted 3.10.18-rt14-arvero-rev01-ipipe #2
[   33.187337] [<c0013110>] (unwind_backtrace+0x0/0xf0) from [<c001158c>] (show_stack+0x10/0x14)
[   33.187398] [<c001158c>] (show_stack+0x10/0x14) from [<c04a0b70>] (rt_spin_lock+0x20/0x64)
[   33.187444] [<c04a0b70>] (rt_spin_lock+0x20/0x64) from [<c002ae28>] (__lock_task_sighand+0x74/0xf4)
[   33.187479] [<c002ae28>] (__lock_task_sighand+0x74/0xf4) from [<c002aecc>] (do_send_sig_info+0x24/0x64)
[   33.187522] [<c002aecc>] (do_send_sig_info+0x24/0x64) from [<c00b0878>] (lostage_handler+0xf8/0x128)
[   33.187568] [<c00b0878>] (lostage_handler+0xf8/0x128) from [<c0073860>] (rthal_apc_handler+0x60/0x84)
[   33.187615] [<c0073860>] (rthal_apc_handler+0x60/0x84) from [<c0066a58>] (__ipipe_do_sync_stage+0x1f8/0x288)
[   33.187655] [<c0066a58>] (__ipipe_do_sync_stage+0x1f8/0x288) from [<c00145c0>] (__ipipe_syscall_root+0xf4/0x13c)
[   33.187694] [<c00145c0>] (__ipipe_syscall_root+0xf4/0x13c) from [<c000ea34>] (vector_swi+0x54/0x74)

For me it seems as I have done something wrong when merging spinlocks of PREEMPT RT and ipipe. Isn't rt_spin_lock() allowed to be called within that context? Does anyone has an idea why?

Regards,
Christoph

#1 lore raw
Quoted 4 lines · Christoph

Hi at all,

I am using linux 3.10.18 and ipipe-core-3.10.18-arm-1 on a Freescale i.MX28. I have also merged PREEMPT RT rt14 into the kernel. FCSE is disabled.

If you have lockdep enabled, you should disable it, as it currently does not work with xenomai on arm.

Signature · 1 line
					    Gilles.
#2 lore raw

Hi Gilles,

Quoted 2 lines

If you have lockdep enabled, you should disable it, as it currently does not work with xenomai on arm.

lockdep is disabled in my kernel config.

Regards,
Christoph

#3 lore raw
Quoted 8 lines
Quoted 4 lines

If you have lockdep enabled, you should disable it, as it currently does not work with xenomai on arm.

lockdep is disabled in my kernel config.

From my understanding the output

[   33.187125] in_atomic(): 1, irqs_disabled(): 128, pid: 87, name: 
[   33.187138] 1 lock held by /87:

tells that preemt_count was unequal to zero and IRQ's were disabled. In that case sleeping would not be allowed. Am I right here?

That bug detection is enabled by kernel config DEBUG_ATOMIC_SLEEP. Do you think that debug config has same problem as lockdep and the detected bug is not really a bug?

Actually I am searching for a bug that crashs my application program after some hours and leading to complete system-freeze. Unfortunately no message does appear when the crash happens. That's the reason why I am using the debug config from above. Do you think these problems could be concerned. Our do you have some other idea how to figure out what's happening there?

Regards and thanks in advance,
Christoph

#4 lore raw
In reply to Stoidner, Christoph
Quoted 24 lines · Christoph

Hi at all,

I am using linux 3.10.18 and ipipe-core-3.10.18-arm-1 on a Freescale i.MX28. I have also merged PREEMPT RT rt14 into the kernel. FCSE is disabled.

I have enabled several debug options in the kernel. When a started program exits I get the message below:

[   33.187104] BUG: sleeping function called from invalid context at kernel/rtmutex.c:659
[   33.187125] in_atomic(): 1, irqs_disabled(): 128, pid: 87, name: 
[   33.187138] 1 lock held by /87:
[   33.187213]  #0:  (rcu_read_lock){......}, at: [<c002add8>] __lock_task_sighand+0x24/0xf4
[   33.187232] Preemption disabled at:[<  (null)>]   (null)
[   33.187237] 
[   33.187262] CPU: 0 PID: 87 Comm:  Not tainted 3.10.18-rt14-arvero-rev01-ipipe #2
[   33.187337] [<c0013110>] (unwind_backtrace+0x0/0xf0) from [<c001158c>] (show_stack+0x10/0x14)
[   33.187398] [<c001158c>] (show_stack+0x10/0x14) from [<c04a0b70>] (rt_spin_lock+0x20/0x64)
[   33.187444] [<c04a0b70>] (rt_spin_lock+0x20/0x64) from [<c002ae28>] (__lock_task_sighand+0x74/0xf4)
[   33.187479] [<c002ae28>] (__lock_task_sighand+0x74/0xf4) from [<c002aecc>] (do_send_sig_info+0x24/0x64)
[   33.187522] [<c002aecc>] (do_send_sig_info+0x24/0x64) from [<c00b0878>] (lostage_handler+0xf8/0x128)
[   33.187568] [<c00b0878>] (lostage_handler+0xf8/0x128) from [<c0073860>] (rthal_apc_handler+0x60/0x84)
[   33.187615] [<c0073860>] (rthal_apc_handler+0x60/0x84) from [<c0066a58>] (__ipipe_do_sync_stage+0x1f8/0x288)
[   33.187655] [<c0066a58>] (__ipipe_do_sync_stage+0x1f8/0x288) from [<c00145c0>] (__ipipe_syscall_root+0xf4/0x13c)
[   33.187694] [<c00145c0>] (__ipipe_syscall_root+0xf4/0x13c) from [<c000ea34>] (vector_swi+0x54/0x74)
Quoted 3 lines

For me it seems as I have done something wrong when merging spinlocks of PREEMPT RT and ipipe. Isn't rt_spin_lock() allowed to be called within that context? Does anyone has an idea why?

From what I understand of Xenomai 2.6 code (if this is the version

you are using), normally, the apc should be invoked from the rthal_apc_thread context, not from rthal_apc_handler.

The virq handler should be rthal_apc_kicker, which wakes up the process.

This code is #ifdef CONFIG_PREEMPT_RT, is not CONFIG_PREEMPT_RT defined in your kernel ?

Signature · 1 line
					    Gilles.
#5 lore raw
Quoted 4 lines

From what I understand of Xenomai 2.6 code (if this is the version you are using),

Yes, I am using Xenomai 2.6

Quoted 8 lines

normally, the apc should be invoked from the rthal_apc_thread context, not from rthal_apc_handler.

The virq handler should be rthal_apc_kicker, which wakes up the process.

This code is #ifdef CONFIG_PREEMPT_RT, is not CONFIG_PREEMPT_RT defined in your kernel ?

In my kernel CONFIG_PREEMPT_RT is not defined but CONFIG_PREEMPT_RT_FULL. Moreover except in Xenomai code I did not find any CONFIG_PREEMPT_RT in kernel code or preempt RT patch-3.10.18-rt14. In older versions of preempt RT (e.g. patch-2.6.33.9-rt31) I can found such a define/configuration. It seems as it was removed.

Regards,
Christoph

#6 lore raw
Quoted 16 lines · Christoph
Quoted 4 lines

From what I understand of Xenomai 2.6 code (if this is the version you are using),

Yes, I am using Xenomai 2.6

Quoted 8 lines

normally, the apc should be invoked from the rthal_apc_thread context, not from rthal_apc_handler.

The virq handler should be rthal_apc_kicker, which wakes up the process.

This code is #ifdef CONFIG_PREEMPT_RT, is not CONFIG_PREEMPT_RT defined in your kernel ?

Quoted 6 lines

In my kernel CONFIG_PREEMPT_RT is not defined but CONFIG_PREEMPT_RT_FULL. Moreover except in Xenomai code I did not find any CONFIG_PREEMPT_RT in kernel code or preempt RT patch-3.10.18-rt14. In older versions of preempt RT (e.g. patch-2.6.33.9-rt31) I can found such a define/configuration. It seems as it was removed.

Well, then you need to replace #ifdef CONFIG_PREEMPT_RT with CONFIG_PREEMPT_RT_FULL, and test the kernel version in wrappers.h to define CONFIG_PREEMPT_RT_FULL if CONFIG_PREEMPT_RT is dedined for old kernels.

Signature · 1 line
					    Gilles.
#7 lore raw
Quoted 5 lines

Well, then you need to replace #ifdef CONFIG_PREEMPT_RT with CONFIG_PREEMPT_RT_FULL, and test the kernel version in wrappers.h to define CONFIG_PREEMPT_RT_FULL if CONFIG_PREEMPT_RT is dedined for old kernels.

I have applied both changes and try if this solves the my problem. If it works I will publish the patch here.

Thanks,
Christoph

#8 lore raw

Hi Gilles,

Quoted 6 lines
Quoted 4 lines

Well, then you need to replace #ifdef CONFIG_PREEMPT_RT with CONFIG_PREEMPT_RT_FULL, and test the kernel version in wrappers.h to define CONFIG_PREEMPT_RT_FULL if CONFIG_PREEMPT_RT is dedined for old kernels.

I have applied both changes and try if this solves the my problem. If it works I will publish the patch here.

below you can find the patch. It solves the problem concerning "sleeping function called from invalid context" when using PREEMPT RT. Would it be reasonable to apply that change to GIT repository?

arch/generic/hal.c +6 -6
Index: ksrc/arch/generic/hal.c
===================================================================
@@ -355,7 +355,7 @@
     rthal_spin_unlock(&rthal_apc_lock);
 }
 
-#ifdef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_RT_FULL
 
 /* On PREEMPT_RT, we need to invoke the apc handlers over a process
    context, so that the latter can access non-atomic kernel services
@@ -398,11 +398,11 @@
 
 #define rthal_apc_trampoline rthal_apc_kicker
 
-#else /* !CONFIG_PREEMPT_RT */
+#else /* !CONFIG_PREEMPT_RT_FULL */
 
 #define rthal_apc_trampoline rthal_apc_handler
 
-#endif /* CONFIG_PREEMPT_RT */
+#endif /* CONFIG_PREEMPT_RT_FULL */
 
 /**
  * @fn int rthal_apc_alloc (const char *name,void (*handler)(void *cookie),void *cookie)
@@ -495,7 +495,7 @@
 	clear_bit(apc, &rthal_apc_map);
 }
 
-#ifdef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_RT_FULL
 
 static inline int setup_apc_handler(void)
 {
@@ -524,7 +524,7 @@
 	}
 }
 
-#else  /* !CONFIG_PREEMPT_RT */
+#else  /* !CONFIG_PREEMPT_RT_FULL */
 
 static inline int setup_apc_handler(void)
 {
@@ -533,7 +533,7 @@
 
 static inline void cleanup_apc_handler(void) { }
 
-#endif  /* !CONFIG_PREEMPT_RT */
+#endif  /* !CONFIG_PREEMPT_RT_FULL */
 
 int rthal_init(void)
 {
nucleus/pipe.c +2 -2
Index: ksrc/nucleus/pipe.c
===================================================================
@@ -173,7 +173,7 @@
 					xnlock_get_irqsave(&nklock, s);
 				}
 			}
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
 			/*
 			 * Assume a waiter might have entered/left the
 			 * queue, so we need to refetch the sleep
@@ -198,7 +198,7 @@
 			xnlock_put_irqrestore(&nklock, s);
 			kill_fasync(&state->asyncq, xnpipe_asyncsig, POLL_IN);
 			xnlock_get_irqsave(&nklock, s);
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
 			nh = getheadq(&xnpipe_asyncq);
 #endif
 		}
asm-generic/wrappers.h +8 -2
Index: include/asm-generic/wrappers.h
===================================================================
@@ -43,6 +43,12 @@
 #include <asm/system.h>
 #endif /* kernel < 3.4.0 */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+#ifdef CONFIG_PREEMPT_RT
+#define CONFIG_PREEMPT_RT_FULL /* after kernel 2.6 CONFIG_PREEMPT_RT was renamed */
+#endif
+#endif /* kernel < 3.0.0 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 
 #include <linux/wrapper.h>
@@ -664,8 +670,8 @@
 #ifndef DEFINE_SEMAPHORE
 /* Legacy DECLARE_MUTEX vanished in 2.6.37 */
 #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif

Regards,
Christoph

#9 lore raw
Quoted 11 lines · Christoph

Hi Gilles,

Quoted 6 lines
Quoted 4 lines

Well, then you need to replace #ifdef CONFIG_PREEMPT_RT with CONFIG_PREEMPT_RT_FULL, and test the kernel version in wrappers.h to define CONFIG_PREEMPT_RT_FULL if CONFIG_PREEMPT_RT is dedined for old kernels.

I have applied both changes and try if this solves the my problem. If it works I will publish the patch here.

below you can find the patch. It solves the problem concerning "sleeping function called from invalid context" when using PREEMPT RT. Would it be reasonable to apply that change to GIT repository?

Yes, of course.

asm-generic/wrappers.h line 677

Quoted 10 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

Signature · 1 line
					    Gilles.
#10 lore raw
Quoted 14 lines

asm-generic/wrappers.h line 677

Quoted 11 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Regards,
Christoph

#11 lore raw
Quoted 15 lines · Christoph
Quoted 14 lines

asm-generic/wrappers.h line 677

Quoted 11 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

Quoted 1 line

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE, so DEFINE_SEMAPHORE is defined, or am I missing something ?

Signature · 1 line
					    Gilles.
#12 lore raw
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE, so DEFINE_SEMAPHORE is defined, or am I missing something ?

Let me explain that more in detail:

DEFINE_SEMAPHORE is defined for linux >= 2.6.37

So for linux 2.6.37 we are in

#elif defined(CONFIG_PREEMPT_RT)

Also in linux 3.0.0 we are in that elif. Since in 3.0.0 and above CONFIG_PREEMPT_RT was changed to CONFIG_PREEMPT_RT_FULL, so we have to use the latter one instead.

Regards,
Christoph

#13 lore raw
Quoted 23 lines · Christoph
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE, so DEFINE_SEMAPHORE is defined, or am I missing something ?

Let me explain that more in detail:

Quoted 8 lines

DEFINE_SEMAPHORE is defined for linux >= 2.6.37

So for linux 2.6.37 we are in

#elif defined(CONFIG_PREEMPT_RT)

Also in linux 3.0.0 we are in that elif. Since in 3.0.0 and above CONFIG_PREEMPT_RT was changed to CONFIG_PREEMPT_RT_FULL, so we have to use the latter one instead.

Ok, but please the two ifdefs then, one for PREEMPT_RT and the other for PREEMT_RT_FULL. This will avoid breaking is someone decides to change the header and moves the chunks around.

Also, I believe the hunk is still wrong, it replaces:
#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1) with:
#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)

Signature · 1 line
					    Gilles.
#14 lore raw
Quoted 26 lines
Quoted 26 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

asm-generic/wrappers.h +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE, so DEFINE_SEMAPHORE is defined, or am I missing something ?

Let me explain that more in detail:

DEFINE_SEMAPHORE is defined for linux >= 2.6.37

So for linux 2.6.37 we are in

Quoted 8 lines
Quoted 4 lines

#elif defined(CONFIG_PREEMPT_RT)

Also in linux 3.0.0 we are in that elif. Since in 3.0.0 and above CONFIG_PREEMPT_RT was changed to CONFIG_PREEMPT_RT_FULL, so we have to use the latter one instead.

Ok, but please the two ifdefs then, one for PREEMPT_RT and the other for PREEMT_RT_FULL. This will avoid breaking is someone decides to change the header and moves the chunks around.

Sorry, maybe I am a little bit confused but I do not understand what you mean. There is only one ifdef using CONFIG_PREEMPT_RT. This is required for compatibility to lower kernel versions to introduce newer CONFIG_PREEMPT_RT_FULL. All other code parts are using CONFIG_PREEMPT_RT_FULL afterwards.

Quoted 4 lines

Also, I believe the hunk is still wrong, it replaces:
#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1) with:
#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)

Your are right, that's true! In newer kernel version DEFINE_SEMAPHORE does accept only one argument. But I am not sure why and in which version. So I will check how to do here.

Regards,
Christoph

#15 lore raw
Quoted 35 lines · Christoph
Quoted 26 lines
Quoted 26 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

#ifndef DEFINE_SEMAPHORE
/* Legacy DECLARE_MUTEX vanished in 2.6.37 */ #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)

(quoted diff) +2 -2
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT anwyay.

If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.

Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE, so DEFINE_SEMAPHORE is defined, or am I missing something ?

Let me explain that more in detail:

DEFINE_SEMAPHORE is defined for linux >= 2.6.37

So for linux 2.6.37 we are in

Quoted 8 lines
Quoted 4 lines

#elif defined(CONFIG_PREEMPT_RT)

Also in linux 3.0.0 we are in that elif. Since in 3.0.0 and above CONFIG_PREEMPT_RT was changed to CONFIG_PREEMPT_RT_FULL, so we have to use the latter one instead.

Ok, but please the two ifdefs then, one for PREEMPT_RT and the other for PREEMT_RT_FULL. This will avoid breaking is someone decides to change the header and moves the chunks around.

Quoted 5 lines

Sorry, maybe I am a little bit confused but I do not understand what you mean. There is only one ifdef using CONFIG_PREEMPT_RT. This is required for compatibility to lower kernel versions to introduce newer CONFIG_PREEMPT_RT_FULL. All other code parts are using CONFIG_PREEMPT_RT_FULL afterwards.

This is what I asked in Xenomai code. But in wrappers.h, I would prefer the code to not depend on the order of the definitions.

Currently, you have, at the beginning of the file

#if whatever
#ifdef CONFIG_PREEMPT_RT
#define CONFIG_PREEMPT_RT_FULL
#endif
#endif

And later:

#ifdef CONFIG_PREEMPT_RT_FULL

This works because if we are in the PREEMPT_RT case, the define at the top of the file will get PREEMT_RT_FULL defined.

Now, if someone decides to move the ifdef from the top of the file to the bottom of the file. The binary semaphore defines breaks.

Whereas if at the bottom of the file, you use:

#ifdef CONFIG_PREEMPT_RT
foo
#elif define CONFIG_PREEMPT_RT_FULL
foo

You no longer have this issue.

Beware of these ifdefs, breakage is easy and may long stay unnoticed.

Signature · 1 line
					    Gilles.
#16 lore raw
In reply to Stoidner, Christoph

Now with the fix from above unfortunately I ran into another problem.

After some undetermined situation nuclues freezes. That means all tasks running in primary domain are freezed. In contrast all processes and tasks of secondary domain are still running without any problem at the same time. The xenomai task states are looking normal:

~ # cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          13914      0     00500080   98.8  ROOT
  0  83     196        196        0     00300380    0.0  DOS4
  0  82     13         13         0     00300380    0.0  DOS5

I have enabled ipipe traceing to figure out what's happening here (see output below, created after tasks have freezed). However I am not sure how to interpret that. Does anyone has an idea?

~ # echo 1 > /proc/ipipe/trace/frozen
~ # cat /proc/ipipe/trace/frozen
I-pipe frozen back-tracing service on 3.10.18-rt14-arvero-rev01-ipipe/ipipe release #1
------------------------------------------------------------

CPU: 0, Freeze: 2248334328 cycles, Trace Points: 100 (+10)

Calibrated minimum trace-point overhead: 1.080 us

 +----- Hard IRQs ('|': locked)
 |+-- Xenomai
 ||+- Linux ('*': domain stalled, '+': current, '#': current+stalled)
 |||			  +---------- Delay flag ('+': > 1 us, '!': > 10 us)
 |||			  |	   +- NMI noise ('N')
 |||			  |	   |
	  Type	  User Val.   Time    Delay  Function (Parent)
:    +func                -181+   1.040  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x1c)
:    +func                -180+   1.200  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x88)
:    +func                -179+   2.160  filp_close+0x10 (do_dup2+0xdc)
:    +func                -177+   1.760  locks_remove_posix+0x14 (filp_close+0x64)
:    +func                -175+   1.240  fput+0x10 (filp_close+0x6c)
:|   +begin   0x80000001  -174+   1.520  fput+0xe8 (filp_close+0x6c)
:|   +end     0x80000001  -172+   1.240  fput+0xfc (filp_close+0x6c)
:|   +func                -171	  0.880  __ipipe_bugon_irqs_enabled+0x10 (ret_fast_syscall+0x14)
:|   +end     0x90000000  -170+   2.080  ret_fast_syscall+0x2c (<0000b5bc>)
:|   +begin   0x90000000  -168+   2.320  vector_swi+0x3c (<0000b3d8>)
:    +func                -166+   1.360  __ipipe_syscall_root+0x10 (vector_swi+0x74)
:    +func                -164	  0.920  SyS_close+0x10 (ret_fast_syscall+0x0)
:    +func                -164+   1.080  __close_fd+0x10 (SyS_close+0x30)
:    +func                -162	  0.880  rt_spin_lock+0x10 (__close_fd+0x28)
:    +func                -162	  0.960  ipipe_root_only+0x10 (rt_spin_lock+0x1c)
:    +func                -161	  0.920  rt_spin_lock_slowlock+0x14 (rt_spin_lock+0x24)
:    +func                -160+   1.320  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x40)
:    +func                -158+   1.520  __try_to_take_rt_mutex+0x14 (rt_spin_lock_slowlock+0x70)
:    +func                -157+   2.080  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x238)
:    +func                -155	  0.880  rt_spin_unlock+0x10 (__close_fd+0xbc)
:    +func                -154	  0.880  rt_spin_lock_slowunlock+0x10 (rt_spin_unlock+0x18)
:    +func                -153	  1.000  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x1c)
:    +func                -152+   1.040  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x88)
:    +func                -151+   1.120  filp_close+0x10 (__close_fd+0xc8)
:    +func                -150+   1.120  locks_remove_posix+0x14 (filp_close+0x64)
:    +func                -149	  0.960  fput+0x10 (filp_close+0x6c)
:|   +begin   0x80000001  -148	  0.920  fput+0xe8 (filp_close+0x6c)
:|   +end     0x80000001  -147+   1.800  fput+0xfc (filp_close+0x6c)
:|   +func                -145	  1.000  __ipipe_bugon_irqs_enabled+0x10 (ret_fast_syscall+0x14)
:|   +end     0x90000000  -144!  18.320  ret_fast_syscall+0x2c (<0000b3dc>)
:|   +begin   0x90000000  -126+   2.360  vector_swi+0x3c (<0012097c>)
:    +func                -123+   1.800  __ipipe_syscall_root+0x10 (vector_swi+0x74)
:    +func                -122+   1.960  SyS_wait4+0x14 (ret_fast_syscall+0x0)
:    +func                -120+   2.440  do_wait+0x14 (SyS_wait4+0x94)
:    +func                -117+   1.320  add_wait_queue+0x10 (do_wait+0x6c)
:    +func                -116+   1.200  rt_spin_lock+0x10 (add_wait_queue+0x30)
:    +func                -115+   1.160  ipipe_root_only+0x10 (rt_spin_lock+0x1c)
:    +func                -113	  0.920  rt_spin_lock_slowlock+0x14 (rt_spin_lock+0x24)
:    +func                -113+   1.640  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x40)
:    +func                -111+   1.320  __try_to_take_rt_mutex+0x14 (rt_spin_lock_slowlock+0x70)
:    +func                -110+   2.040  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x238)
:    +func                -108+   1.040  rt_spin_unlock+0x10 (add_wait_queue+0x50)
:    +func                -107	  0.880  rt_spin_lock_slowunlock+0x10 (rt_spin_unlock+0x18)
:    +func                -106	  1.000  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x1c)
:    +func                -105+   1.920  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x88)
:    +func                -103+   1.080  rt_read_lock+0x10 (do_wait+0xb0)
:    +func                -102	  0.880  __rt_spin_lock+0x10 (rt_read_lock+0x3c)
:    +func                -101	  0.960  ipipe_root_only+0x10 (__rt_spin_lock+0x1c)
:    +func                -100	  0.920  rt_spin_lock_slowlock+0x14 (__rt_spin_lock+0x24)
:    +func                 -99+   1.160  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x40)
:    +func                 -98	  1.000  __try_to_take_rt_mutex+0x14 (rt_spin_lock_slowlock+0x70)
:    +func                 -97+   1.920  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x238)
:    +func                 -95+   2.440  wait_consider_task+0x14 (do_wait+0xec)
:    +func                 -92+   3.360  task_stopped_code+0x10 (wait_consider_task+0xe4)
:    +func                 -89+   1.160  rt_read_unlock+0x10 (do_wait+0x194)
:    +func                 -88	  0.880  __rt_spin_unlock+0x10 (rt_read_unlock+0x2c)
:    +func                 -87	  0.880  rt_spin_lock_slowunlock+0x10 (__rt_spin_unlock+0x18)
:    +func                 -86	  1.000  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x1c)
:    +func                 -85+   1.760  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x88)
:    +func                 -83	  0.880  remove_wait_queue+0x10 (do_wait+0x114)
:    +func                 -82	  0.880  rt_spin_lock+0x10 (remove_wait_queue+0x20)
:    +func                 -82	  0.960  ipipe_root_only+0x10 (rt_spin_lock+0x1c)
:    +func                 -81	  0.920  rt_spin_lock_slowlock+0x14 (rt_spin_lock+0x24)
:    +func                 -80	  1.000  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x40)
:    +func                 -79	  1.000  __try_to_take_rt_mutex+0x14 (rt_spin_lock_slowlock+0x70)
:    +func                 -78+   1.680  ipipe_root_only+0x10 (rt_spin_lock_slowlock+0x238)
:    +func                 -76	  0.880  rt_spin_unlock+0x10 (remove_wait_queue+0x48)
:    +func                 -75	  0.880  rt_spin_lock_slowunlock+0x10 (rt_spin_unlock+0x18)
:    +func                 -74	  1.000  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x1c)
:    +func                 -73+   1.560  ipipe_root_only+0x10 (rt_spin_lock_slowunlock+0x88)
:    +func                 -72+   1.480  put_pid+0x10 (SyS_wait4+0xa0)
:|   +func                 -70	  0.840  __ipipe_bugon_irqs_enabled+0x10 (ret_fast_syscall+0x14)
:|   +end     0x90000000   -69!  18.440  ret_fast_syscall+0x2c (<00120980>)
:|   +begin   0x90000000   -51+   2.240  vector_swi+0x3c (<0000b4f8>)
:    +func                 -49+   1.560  __ipipe_syscall_root+0x10 (vector_swi+0x74)
:    +func                 -47+   1.200  SyS_write+0x14 (ret_fast_syscall+0x0)
:    +func                 -46+   2.320  fget_light+0x10 (SyS_write+0x28)
:    +func                 -44+   2.640  vfs_write+0x14 (SyS_write+0x50)
:    +func                 -41+   2.640  rw_verify_area+0x14 (vfs_write+0x8c)
:    +func                 -38+   1.280  __sb_start_write+0x14 (vfs_write+0x1c8)
:    +func                 -37	  1.000  ipipe_root_only+0x10 (__sb_start_write+0x48)
:    +func                 -36+   1.920  ipipe_root_only+0x10 (__sb_start_write+0x70)
:    +func                 -34+   2.120  proc_reg_write+0x14 (vfs_write+0xcc)
:|   +begin   0x80000001   -32+   1.360  proc_reg_write+0xb8 (vfs_write+0xcc)
:|   +end     0x80000001   -31+   2.040  proc_reg_write+0xe0 (vfs_write+0xcc)
:    +func                 -29+   7.080  __ipipe_frozen_ctrl+0x14 (proc_reg_write+0x94)
:    +func                 -22	  0.920  _mutex_lock+0x10 (__ipipe_frozen_ctrl+0x9c)
:    +func                 -21+   1.080  rt_mutex_lock+0x10 (_mutex_lock+0x18)
:    +func                 -20+   1.440  ipipe_root_only+0x10 (rt_mutex_lock+0x1c)
:    +func                 -18+   1.080  rt_mutex_slowlock+0x14 (rt_mutex_lock+0x30)
:    +func                 -17+   1.800  ipipe_root_only+0x10 (rt_mutex_slowlock+0x38)
:    +func                 -15+   1.320  __try_to_take_rt_mutex+0x14 (rt_mutex_slowlock+0x74)
:    +func                 -14+   1.800  ipipe_root_only+0x10 (rt_mutex_slowlock+0x128)
:    +func                 -12+   1.240  ipipe_trace_frozen_reset+0x10 (__ipipe_frozen_ctrl+0xa0)
:    +func                 -11+   2.160  __ipipe_global_path_lock+0x10 (ipipe_trace_frozen_reset+0x18)
:    +func                  -9+   1.400  __ipipe_spin_lock_irqsave+0x10 (__ipipe_global_path_lock+0x1c)
:|   +begin   0x80000001    -7+   3.960  __ipipe_spin_lock_irqsave+0x5c (__ipipe_global_path_lock+0x1c)
:|   #func                  -3+   1.680  __ipipe_spin_unlock_irqcomplete+0x10 (__ipipe_global_path_unlock+0x6c)
:|   +end     0x80000001    -2+   2.120  __ipipe_spin_unlock_irqcomplete+0x48 (__ipipe_global_path_unlock+0x6c)
<    +freeze  0xffffffff     0	  1.440  __ipipe_frozen_ctrl+0xb0 (proc_reg_write+0x94)
     +func                   1	  1.200  _mutex_unlock+0x10 (__ipipe_frozen_ctrl+0xb8)
     +func                   2	  0.920  rt_mutex_unlock+0x10 (_mutex_unlock+0x18)
     +func                   3	  1.160  ipipe_root_only+0x10 (rt_mutex_unlock+0x1c)
     +func                   4	  1.560  ipipe_root_only+0x10 (rt_mutex_unlock+0x88)
     +func                   6	  1.280  unuse_pde+0x10 (proc_reg_write+0xa0)
 |   +begin   0x80000001     7	  1.120  unuse_pde+0x58 (proc_reg_write+0xa0)
 |   +end     0x80000001     8	  2.320  unuse_pde+0x6c (proc_reg_write+0xa0)
     +func                  11	  1.240  __fsnotify_parent+0x14 (vfs_write+0x168)
     +func                  12	  1.520  fsnotify+0x14 (vfs_write+0x184)
     +func                  13	  0.000  __srcu_read_lock+0x10 (fsnotify+0x1d0)

~ #

Regards,
Christoph

#17 lore raw
Quoted 10 lines · Christoph

Now with the fix from above unfortunately I ran into another problem.

After some undetermined situation nuclues freezes. That means all tasks running in primary domain are freezed. In contrast all processes and tasks of secondary domain are still running without any problem at the same time. The xenomai task states are looking normal:

~ # cat /proc/xenomai/stat

Quoted 8 lines
CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          13914      0     00500080   98.8  ROOT
  0  83     196        196        0     00300380    0.0  DOS4
  0  82     13         13         0     00300380    0.0  DOS5

I have enabled ipipe traceing to figure out what's happening here (see output below, created after tasks have freezed). However I am not sure how to interpret that. Does anyone has an idea?

ipipe tracing will not help you, because you have no way to trigger it at the right time.

Anyway, is not it simply a deadlock in your application ?

Please check that Xenomai timer is still running by checking that its counter increases in cat /proc/xenomai/irq result.

If Xenomai and Linux timers are shared (I believe they are on imx28), checking the same thing for Linux timer in /proc/interrupts is sufficient, Xenomai timer can not possibly be jammed if Linux timer still ticks.

Signature · 1 line
					    Gilles.
#18 lore raw
Quoted 3 lines

Anyway, is not it simply a deadlock in your application ?

I don't think so. Here is a list of all tasks:

~ # cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          7452       0     00500080   98.9  ROOT
  0  83     196        196        0     00300380    0.0  DOS4
  0  81     13         13         0     00300380    0.0  DOS5
  0  97     618        830        0     00300380    0.0  @WDG
  0  101    751        1127       0     00300380    0.0  HSSR
  0  128    1268       2186       0     00300380    0.0  DOS8
  0  129    1          1          0     00300380    0.0  @CGI
  0  130    7          10         0     00300182    0.0  LOG 
  0  131    1          2          0     00300184    0.0  IOXP
  0  142    20         42         0     00300380    0.0  KTMR
  0  151    1652       1901       0     00300380    0.0  Sdrv
  0  152    383        489        0     00300380    0.0  LApp
  0  156    0          1          0     00300380    0.0  DOS9
  0  0      0          14937556   0     00000000    1.0  IRQ16: [timer]

Most of them are in state 00300380, that means:
XNSTARTED
XNMAPPED
XNRELAXED
XNFPU
XNSHADOW

For a deadlock I would expect all threads must be wait for a semaphore or something else (state flag XNPEND). However all tasks are freezed.

Quoted 2 lines

Please check that Xenomai timer is still running by checking that its counter increases in cat /proc/xenomai/irq result.

That's the output:

~ # cat /proc/xenomai/irq
IRQ CPU0
16: 14155140 [timer]
1027: 5233 [virtual]
~ # cat /proc/xenomai/irq
IRQ CPU0
16: 14158294 [timer]
1027: 5233 [virtual]
~ # cat /proc/xenomai/irq
IRQ CPU0
16: 14159556 [timer]
1027: 5233 [virtual]
~ #

The time-IRQ (16) is still counting. However the IRQ 1027 - called "virtual" - is stopped when all xenomai tasks are freezed. Do you know for what that 'virtual' IRQ is?

Quoted 4 lines

If Xenomai and Linux timers are shared (I believe they are on imx28), checking the same thing for Linux timer in /proc/interrupts is sufficient, Xenomai timer can not possibly be jammed if Linux timer still ticks.

Linux timer seem to run as well:

~ # cat /proc/interrupts
CPU0

 16:      49931         -  MXS Timer Tick
 18:         61         -  mxs-dma
 19:          0         -  mxs-dma
 25:         11         -  mxs-mmc
 26:          0         -  mxs-spi
207:          0         -  mxs-lradc-touchscreen
208:          0         -  mxs-lradc-thresh0
209:          0         -  mxs-lradc-thresh1
210:          0         -  mxs-lradc-channel0
211:          0         -  mxs-lradc-channel1
212:          0         -  mxs-lradc-channel2
213:          0         -  mxs-lradc-channel3
214:          0         -  mxs-lradc-channel4
215:          0         -  mxs-lradc-channel5
216:          0         -  mxs-lradc-channel6
217:          0         -  mxs-lradc-channel7
218:          0         -  mxs-lradc-button0
219:          0         -  mxs-lradc-button1
220:          0         -  RTC alarm
224:         90         -  80072000.serial
225:       2982         -  uart-pl011
226:          0         -  ci13xxx_imx
227:      40138         -  800f0000.ethernet
Err:          0
~ # cat /proc/interrupts 
           CPU0       
 16:      49958         -  MXS Timer Tick
 18:         61         -  mxs-dma
 19:          0         -  mxs-dma
 25:         11         -  mxs-mmc
 26:          0         -  mxs-spi
207:          0         -  mxs-lradc-touchscreen
208:          0         -  mxs-lradc-thresh0
209:          0         -  mxs-lradc-thresh1
210:          0         -  mxs-lradc-channel0
211:          0         -  mxs-lradc-channel1
212:          0         -  mxs-lradc-channel2
213:          0         -  mxs-lradc-channel3
214:          0         -  mxs-lradc-channel4
215:          0         -  mxs-lradc-channel5
216:          0         -  mxs-lradc-channel6
217:          0         -  mxs-lradc-channel7
218:          0         -  mxs-lradc-button0
219:          0         -  mxs-lradc-button1
220:          0         -  RTC alarm
224:         90         -  80072000.serial
225:       3115         -  uart-pl011
226:          0         -  ci13xxx_imx
227:      40154         -  800f0000.ethernet

Err: 0
~ #

Regards,
Christoph

#19 lore raw
Quoted 23 lines · Christoph
Quoted 3 lines

Anyway, is not it simply a deadlock in your application ?

I don't think so. Here is a list of all tasks:

~ # cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          7452       0     00500080   98.9  ROOT
  0  83     196        196        0     00300380    0.0  DOS4
  0  81     13         13         0     00300380    0.0  DOS5
  0  97     618        830        0     00300380    0.0  @WDG
  0  101    751        1127       0     00300380    0.0  HSSR
  0  128    1268       2186       0     00300380    0.0  DOS8
  0  129    1          1          0     00300380    0.0  @CGI
  0  130    7          10         0     00300182    0.0  LOG 
  0  131    1          2          0     00300184    0.0  IOXP
  0  142    20         42         0     00300380    0.0  KTMR
  0  151    1652       1901       0     00300380    0.0  Sdrv
  0  152    383        489        0     00300380    0.0  LApp
  0  156    0          1          0     00300380    0.0  DOS9
  0  0      0          14937556   0     00000000    1.0  IRQ16: [timer]
Quoted 8 lines

Most of them are in state 00300380, that means:
XNSTARTED
XNMAPPED
XNRELAXED
XNFPU
XNSHADOW

For a deadlock I would expect all threads must be wait for a semaphore or something else (state flag XNPEND). However all tasks are freezed.

Well no, XNRELAXED state means that it is suspended from xenomai scheduler point of view, and handled by Linux scheduler. So, if there is a deadlock, it happens in secondary mode.

Signature · 1 line
					    Gilles.
#20 lore raw
Quoted 29 lines
Quoted 29 lines
Quoted 2 lines

Anyway, is not it simply a deadlock in your application ?

I don't think so. Here is a list of all tasks:

~ # cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          7452       0     00500080   98.9  ROOT
  0  83     196        196        0     00300380    0.0  DOS4
  0  81     13         13         0     00300380    0.0  DOS5
  0  97     618        830        0     00300380    0.0  @WDG
  0  101    751        1127       0     00300380    0.0  HSSR
  0  128    1268       2186       0     00300380    0.0  DOS8
  0  129    1          1          0     00300380    0.0  @CGI
  0  130    7          10         0     00300182    0.0  LOG
  0  131    1          2          0     00300184    0.0  IOXP
  0  142    20         42         0     00300380    0.0  KTMR
  0  151    1652       1901       0     00300380    0.0  Sdrv
  0  152    383        489        0     00300380    0.0  LApp
  0  156    0          1          0     00300380    0.0  DOS9
  0  0      0          14937556   0     00000000    1.0  IRQ16: [timer]

Most of them are in state 00300380, that means:
XNSTARTED
XNMAPPED
XNRELAXED
XNFPU
XNSHADOW

Quoted 5 lines
Quoted 1 line

For a deadlock I would expect all threads must be wait for a semaphore or something else (state flag XNPEND). However all tasks are freezed.

Well no, XNRELAXED state means that it is suspended from xenomai scheduler point of view, and handled by Linux scheduler. So, if there is a deadlock, it happens in secondary mode.

The callstack in /proc/[PID]/tasks/[TID]/stack of all threads shows that they are at same address in __xnpod_schedule:

Call stack for task with TID 128:

~ # cat /proc/128/tasks/128/stack

[<c00a8a78>] __xnpod_schedule+0x294/0x764
[<c00a92a4>] xnpod_suspend_thread+0x2c0/0x354
[<c00b6b48>] xnshadow_relax+0x94/0x168
[<c00b7384>] losyscall_event+0x240/0x26c
[<c007c6fc>] ipipe_syscall_hook+0x44/0x54
[<c0078474>] __ipipe_notify_syscall+0x70/0x1d0
[<c0016820>] __ipipe_syscall_root+0x6c/0x194
[<c000f734>] vector_swi+0x74/0x8c

[<ffffffff>] 0xffffffff

With addr2line I have identified the if-statement as below on address c00a8a78 (found in kernel/xenomai/nucleus/pod.c:2256):

  if (shadow && xnarch_root_domain_p())

Before this line there is the call xnpod_switch_to(sched, prev, next). So I assume the thread has not resumed from context switch.

Do you have any more idea?

Regards,
Christoph

#21 lore raw
Quoted 2 lines · Christoph
[<c00b6b48>] xnshadow_relax+0x94/0x168
[<c00b7384>] losyscall_event+0x240/0x26c

That is strange, are these tasks running with the SCHED_OTHER policy ?

Signature · 1 line
					    Gilles.