Skip to contentSkip to conversation

non-blocking rt_task_suspend(NULL)

Xenomai Petr Cervenka 3 participants 14 messages May 2, 2014 – May 20, 2014

lore
Share & tools
lore
#0 lore raw
Quoted 33 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 25 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 8 lines
Quoted 4 lines

We see that xnpod_suspend_thread returns immediately, likely because it has the XNKICKED bit set. Could you add more back trace points? So that we see what is setting the XNKICKED bit?

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Could you please help me with analysis, what is happening in the trace log? I only see at the end only peaces of log, which are already contained somewhere before. For example lines 3832-3993 are the same as 2901-3062.
Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Thank you in advance.
Petr

#1 lore raw
Quoted 42 lines · Petr Cervenka
Quoted 33 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 25 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 8 lines
Quoted 4 lines

We see that xnpod_suspend_thread returns immediately, likely because it has the XNKICKED bit set. Could you add more back trace points? So that we see what is setting the XNKICKED bit?

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Quoted 8 lines

Could you please help me with analysis, what is happening in the trace log? I only see at the end only peaces of log, which are already contained somewhere before. For example lines 3832-3993 are the same as 2901-3062.
Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

I will probably not have time to have a look at it before the end of the week-end. I had a quick glance and did not find what I expected. We will have to add some calls to ipipe_trace_special to see get the values of the task state or info flags in the trace.

Signature · 1 line
Gilles.
#2 lore raw
In reply to Petr Cervenka
Quoted 42 lines · Petr Cervenka
Quoted 33 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 25 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 8 lines
Quoted 4 lines

We see that xnpod_suspend_thread returns immediately, likely because it has the XNKICKED bit set. Could you add more back trace points? So that we see what is setting the XNKICKED bit?

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Quoted 9 lines

Could you please help me with analysis, what is happening in the trace log? I only see at the end only peaces of log, which are already contained somewhere before. For example lines 3832-3993 are the same as 2901-3062.
Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Please add these bits to your trace setup:

ksrc/nucleus/shadow.c +4 -0
index 13865a3..ccc54a8 100644
@@ -2516,6 +2516,10 @@ int do_losyscall_event(unsigned event, rthal_pipeline_stage_t *stage,
 		 * We may have gained a shadow TCB from the syscall we
 		 * just invoked, so make sure to fetch it.
 		 */
+		if (__xn_interrupted_p(regs)) {
+			xntrace_special(0x44, thread->info);
+			xntrace_special(0x55, signal_pending(current));
+		}
 		thread = xnshadow_thread(current);
 		if (signal_pending(current)) {
 			sigs = 1;

TIA,

Signature · 1 line
Philippe.
#3 lore raw
Quoted 76 lines

Od: Philippe Gerum <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 42 lines · Petr Cervenka
Quoted 33 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 25 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 8 lines
Quoted 4 lines

We see that xnpod_suspend_thread returns immediately, likely because it has the XNKICKED bit set. Could you add more back trace points? So that we see what is setting the XNKICKED bit?

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Quoted 9 lines

Could you please help me with analysis, what is happening in the trace log? I only see at the end only peaces of log, which are already contained somewhere before. For example lines 3832-3993 are the same as 2901-3062.
Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Please add these bits to your trace setup:

ksrc/nucleus/shadow.c +4 -0
index 13865a3..ccc54a8 100644
@@ -2516,6 +2516,10 @@ int do_losyscall_event(unsigned event, 
 rthal_pipeline_stage_t *stage,
 		 * We may have gained a shadow TCB from the syscall we
 		 * just invoked, so make sure to fetch it.
 		 */
+		if (__xn_interrupted_p(regs)) {
+			xntrace_special(0x44, thread->info);
+			xntrace_special(0x55, signal_pending(current));
+		}
 		thread = xnshadow_thread(current);
 		if (signal_pending(current)) {

sigs = 1;

Quoted 1 line

TIA,

I have applied the patch and here is the trace log. It took a while because some change I made caused lesser probability of the problem. Short version:

:   + (0x44)	0x0000000c    -3	  0.097  losyscall_event+0x270 (ipipe_syscall_hook+0x89)
:   + (0x55)	0x00000000    -3	  0.119  losyscall_event+0x292 (ipipe_syscall_hook+0x89)

Long version is in the attachment.

Petr
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: freeze13.txt
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20140506/aad6f1af/attachment.txt>

#4 lore raw
Quoted 83 lines · Petr Cervenka
Quoted 83 lines

Od: Philippe Gerum <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 55 lines · Petr Cervenka
Quoted 40 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 19 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

Quoted 6 lines

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 6 lines

We see that xnpod_suspend_thread returns immediately, likely because it
has the XNKICKED bit set. Could you add more back trace points? So that
we see what is setting the XNKICKED bit?

Quoted 5 lines

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Could you please help me with analysis, what is happening in the trace log?
I only see at the end only peaces of log, which are already contained somewhere before.
For example lines 3832-3993 are the same as 2901-3062. Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

Quoted 3 lines

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Please add these bits to your trace setup:

ksrc/nucleus/shadow.c +4 -0
index 13865a3..ccc54a8 100644
@@ -2516,6 +2516,10 @@ int do_losyscall_event(unsigned event,
 rthal_pipeline_stage_t *stage,
          * We may have gained a shadow TCB from the syscall we
          * just invoked, so make sure to fetch it.
          */
+        if (__xn_interrupted_p(regs)) {
+            xntrace_special(0x44, thread->info);
+            xntrace_special(0x55, signal_pending(current));
+        }
         thread = xnshadow_thread(current);
         if (signal_pending(current)) {
             sigs = 1;
Quoted 11 lines
Quoted 1 line

TIA,

I have applied the patch and here is the trace log. It took a while because some change I made caused lesser probability of the problem. Short version:
: + (0x44) 0x0000000c -3 0.097 losyscall_event+0x270
(ipipe_syscall_hook+0x89)
: + (0x55) 0x00000000 -3 0.119 losyscall_event+0x292
(ipipe_syscall_hook+0x89)
Long version is in the attachment.

Ok, thanks. Things are getting clearer: the real-time core believes it has kicked a thread out of sleep for receiving a linux signal, but linux does not have any signal to process for this thread. So the real-time core ends up propagating EINTR to userland as nobody clears the kick notification Xenomai-wise. Ok, something is definitely wrong in the Xenomai core logic here.

And this bug is likely present in Xenomai 3/Cobalt as well.

Signature · 1 line
Philippe.
#5 lore raw
In reply to Petr Cervenka
Quoted 83 lines · Petr Cervenka
Quoted 83 lines

Od: Philippe Gerum <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 55 lines · Petr Cervenka
Quoted 40 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 19 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

Quoted 6 lines

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 6 lines

We see that xnpod_suspend_thread returns immediately, likely because it
has the XNKICKED bit set. Could you add more back trace points? So that
we see what is setting the XNKICKED bit?

Quoted 5 lines

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Could you please help me with analysis, what is happening in the trace log?
I only see at the end only peaces of log, which are already contained somewhere before.
For example lines 3832-3993 are the same as 2901-3062. Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

Quoted 3 lines

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Please add these bits to your trace setup:

ksrc/nucleus/shadow.c +4 -0
index 13865a3..ccc54a8 100644
@@ -2516,6 +2516,10 @@ int do_losyscall_event(unsigned event,
 rthal_pipeline_stage_t *stage,
          * We may have gained a shadow TCB from the syscall we
          * just invoked, so make sure to fetch it.
          */
+        if (__xn_interrupted_p(regs)) {
+            xntrace_special(0x44, thread->info);
+            xntrace_special(0x55, signal_pending(current));
+        }
         thread = xnshadow_thread(current);
         if (signal_pending(current)) {
             sigs = 1;
Quoted 10 lines
Quoted 1 line

TIA,

I have applied the patch and here is the trace log. It took a while because some change I made caused lesser probability of the problem. Short version:
: + (0x44) 0x0000000c -3 0.097 losyscall_event+0x270
(ipipe_syscall_hook+0x89)
: + (0x55) 0x00000000 -3 0.119 losyscall_event+0x292
(ipipe_syscall_hook+0x89)
Long version is in the attachment.

Could you post your kernel config?

TIA,

Signature · 1 line
Philippe.
#6 lore raw
Quoted 98 lines

Od: Philippe Gerum <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 83 lines · Petr Cervenka
Quoted 83 lines

Od: Philippe Gerum <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 55 lines · Petr Cervenka
Quoted 40 lines

Od: "Petr Cervenka" <[email protected]>

CC "Xenomai" <[email protected]>
Quoted 30 lines

Od: Gilles Chanteperdrix <[email protected]>

CC: "Xenomai" <[email protected]>

Quoted 19 lines · Petr Cervenka
Quoted 9 lines

Od: Gilles Chanteperdrix <[email protected]>

Quoted 6 lines

SIGDEBUG signal was not received. Task status from rt_task_inquire() was 0x300180 or 0x300380 (depends where it is placed) When the task is in the "wrong" state, also the call of rt_task_sleep(100000) is returning permanently -EINTR code. Do you have any other idea what to check or what can cause perhaps every xenomai call fail with -EINTR in one task?

Quoted 5 lines

If I had to debug this issue, I would enable the I-pipe tracer and trigger a trace freeze when the -EINTR code is received. With enough trace points, it should be possible to understand what happens.

I called a xntrace_user_freeze() immediately when the issue occurs, but I simply don't understand what is happening there. The trace output is in the attachment. Could you please help me to understand it?

Quoted 6 lines

I also got some minor problem with xntrace_user_freeze, because the linker was not able to find it: asyncwriter.cpp:(.text+0x843):
undefined reference to `xntrace_user_freeze(unsigned long, int)' It is defined in src/skins/common/trace.c and (should be) contained in libxenomai.so. But I was not successful and I had to define it myself (under different name). Version of xenomai is 2.6.3.

Quoted 6 lines

We see that xnpod_suspend_thread returns immediately, likely because it
has the XNKICKED bit set. Could you add more back trace points? So that
we see what is setting the XNKICKED bit?

Quoted 5 lines

I have added (maybe too much) back trace points. But as last time, I'm not able to see (almost) anything in it ;-) Previous xnpod_suspend_thread (on line 3713, probably caused by rt_mutex_aquire) seems to be fine (for me;-) ).

Could you please help me with analysis, what is happening in the trace log?
I only see at the end only peaces of log, which are already contained somewhere before.
For example lines 3832-3993 are the same as 2901-3062. Also 3697-3861 and 3065-3229.
Also 3596-3692 and 2935-3058
Also 3065-3550 and 2402-2887

Quoted 3 lines

There are also suspicious lines with "device_not_available" and "ipipe_handle_exception", but they seem to be regularly appearing.

Please add these bits to your trace setup:

ksrc/nucleus/shadow.c +4 -0
index 13865a3..ccc54a8 100644
@@ -2516,6 +2516,10 @@ int do_losyscall_event(unsigned event,
 rthal_pipeline_stage_t *stage,
          * We may have gained a shadow TCB from the syscall we
          * just invoked, so make sure to fetch it.
          */
+        if (__xn_interrupted_p(regs)) {
+            xntrace_special(0x44, thread->info);
+            xntrace_special(0x55, signal_pending(current));
+        }
         thread = xnshadow_thread(current);
         if (signal_pending(current)) {
             sigs = 1;
Quoted 10 lines
Quoted 1 line

TIA,

I have applied the patch and here is the trace log. It took a while because some change I made caused lesser probability of the problem. Short version:
: + (0x44) 0x0000000c -3 0.097 losyscall_event+0x270
(ipipe_syscall_hook+0x89)
: + (0x55) 0x00000000 -3 0.119 losyscall_event+0x292
(ipipe_syscall_hook+0x89)
Long version is in the attachment.

Quoted 2 lines

Could you post your kernel config?

Here it is. It's full of modules and other perhaps not so real-time settings, because it was derived from Kubuntu kernel config file.

Petr
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: kernel_config_debug.txt
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20140506/38f80d30/attachment.txt>

#7 lore raw
Quoted 4 lines · Petr Cervenka

Here it is. It's full of modules and other perhaps not so real-time settings, because it was derived from Kubuntu kernel config file.

Thanks. The issue seems to happen as a result of a relax -> harden transition racing with a signal receipt. In order to help me ruling out some assumptions, could you please apply the patch below, and confirm that no job control is involved (SIGCONT/SIGSTOP) in your application?

Knowing whether any of the two warnings added by this patch is issued when the bug happens would also help solving the issue, TIA.

ksrc/nucleus/pod.c +10 -8
index 0a2ee19..9fb797f 100644
@@ -1379,15 +1379,17 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		 * context, to collect and act upon the pending Linux
 		 * signal.
 		 */
-		if ((mask & XNRELAX) == 0 &&
-		    xnthread_test_info(thread, XNKICKED)) {
-			if (wchan) {
-				thread->wchan = wchan;
-				xnsynch_forget_sleeper(thread);
+		if (xnthread_test_info(thread, XNKICKED)) {
+			if ((mask & XNRELAX) == 0) {
+				if (wchan) {
+					thread->wchan = wchan;
+					xnsynch_forget_sleeper(thread);
+				}
+				xnthread_clear_info(thread, XNRMID | XNTIMEO);
+				xnthread_set_info(thread, XNBREAK);
+				goto unlock_and_exit;
 			}
-			xnthread_clear_info(thread, XNRMID | XNTIMEO);
-			xnthread_set_info(thread, XNBREAK);
-			goto unlock_and_exit;
+			WARN_ON(1);
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
ksrc/nucleus/shadow.c +2 -0
index 38c1423..fc592a2 100644
@@ -2696,6 +2696,8 @@ static inline void do_sigwake_event(struct task_struct *p)
 		}
 	}
 
+	WARN_ON(!signal_pending(p));
+
 	/*
 	 * If a relaxed thread is getting a signal while running, we
 	 * force it out of RPI, so that it won't keep a boosted
Signature · 1 line
Philippe.
#8 lore raw
Quoted 45 lines

Od: Philippe Gerum <[email protected]>

Quoted 3 lines

Here it is. It's full of modules and other perhaps not so real-time settings, because it was derived from Kubuntu kernel config file.

Thanks. The issue seems to happen as a result of a relax -> harden transition racing with a signal receipt. In order to help me ruling out some assumptions, could you please apply the patch below, and confirm that no job control is involved (SIGCONT/SIGSTOP) in your application?

Knowing whether any of the two warnings added by this patch is issued when the bug happens would also help solving the issue, TIA.

ksrc/nucleus/pod.c +10 -8
index 0a2ee19..9fb797f 100644
@@ -1379,15 +1379,17 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		 * context, to collect and act upon the pending Linux
 		 * signal.
 		 */
-		if ((mask & XNRELAX) == 0 &&
-		    xnthread_test_info(thread, XNKICKED)) {
-			if (wchan) {
-				thread->wchan = wchan;
-				xnsynch_forget_sleeper(thread);
+		if (xnthread_test_info(thread, XNKICKED)) {
+			if ((mask & XNRELAX) == 0) {
+				if (wchan) {
+					thread->wchan = wchan;
+					xnsynch_forget_sleeper(thread);
+				}
+				xnthread_clear_info(thread, XNRMID | XNTIMEO);
+				xnthread_set_info(thread, XNBREAK);
+				goto unlock_and_exit;
 			}
-			xnthread_clear_info(thread, XNRMID | XNTIMEO);
-			xnthread_set_info(thread, XNBREAK);
-			goto unlock_and_exit;
+			WARN_ON(1);
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
ksrc/nucleus/shadow.c +0 -0
index 38c1423..fc592a2 100644

ksrc/nucleus/shadow.c static inline void do_sigwake_event(struct task_struct *p) · line 2703

Quoted 8 lines
ksrc/nucleus/shadow.c +2 -0
@@ -2696,6 +2696,8 @@ static inline void do_sigwake_event(struct task_struct *p)
 		}
 	}
 
+	WARN_ON(!signal_pending(p));
+
 	/*
 	 * If a relaxed thread is getting a signal while running, we
 	 * force it out of RPI, so that it won't keep a boosted

Finally, I was able to catch the warning(s). I got 38 of these before task ended:

[ 1109.336726] ------------[ cut here ]------------
[ 1109.336737] WARNING: at kernel/xenomai/nucleus/pod.c:1392 xnpod_suspend_thread+0x17d/0x5a0()
[ 1109.336746] Hardware name: X7SBA
[ 1109.336755] Modules linked in: fr01_rtdm(O) netconsole configfs igb dca e1000e e1000 r8169 rt_e1000(O) rt_r8169(O) rtpacket(O) rtnet(O) coretemp psmouse microcode serio_raw shpchp lpc_ich i3200_edac video edac_core floppy
[ 1109.336908] Pid: 786, comm: ASYNC_TASK_1869 Tainted: G           O 3.5.7-debug #38
[ 1109.336917] Call Trace:
[ 1109.336933]  [<ffffffff8103cdcf>] warn_slowpath_common+0x7f/0xc0
[ 1109.336949]  [<ffffffff8103ce2a>] warn_slowpath_null+0x1a/0x20
[ 1109.336965]  [<ffffffff8110b08d>] xnpod_suspend_thread+0x17d/0x5a0
[ 1109.336981]  [<ffffffff81117054>] xnshadow_relax+0xf4/0x250
[ 1109.336997]  [<ffffffff810cc73c>] ? __ipipe_restore_head+0x7c/0x100
[ 1109.337013]  [<ffffffff811181db>] xnshadow_harden+0x30b/0x340
[ 1109.337029]  [<ffffffff811183e0>] losyscall_event+0xb0/0x2f0
[ 1109.337045]  [<ffffffff810d0829>] ipipe_syscall_hook+0x89/0xd0
[ 1109.337061]  [<ffffffff810cbc68>] __ipipe_notify_syscall+0x158/0x340
[ 1109.337076]  [<ffffffff8102167a>] __ipipe_syscall_root+0x4a/0x1f0
[ 1109.337092]  [<ffffffff81367baa>] __ipipe_syscall_root_thunk+0x35/0x67
[ 1109.337108]  [<ffffffff81682217>] ? system_call_after_swapgs+0x54/0x6d
[ 1109.337117] ---[ end trace 9fc5fa66a7479311 ]---

The trace log is in the attachment.

Petr

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: freeze14.txt
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20140507/37a07957/attachment.txt>

#9 lore raw
Quoted 90 lines · Petr Cervenka
Quoted 59 lines

Od: Philippe Gerum <[email protected]>

Quoted 4 lines

Here it is. It's full of modules and other perhaps not so real-time settings, because it was derived from Kubuntu kernel config file.

Thanks. The issue seems to happen as a result of a relax -> harden transition racing with a signal receipt. In order to help me ruling out some assumptions, could you please apply the patch below, and confirm that no job control is involved (SIGCONT/SIGSTOP) in your application?

Knowing whether any of the two warnings added by this patch is issued when the bug happens would also help solving the issue, TIA.

ksrc/nucleus/pod.c +10 -8
index 0a2ee19..9fb797f 100644
@@ -1379,15 +1379,17 @@ void xnpod_suspend_thread(xnthread_t *thread, 
 xnflags_t mask,
         * context, to collect and act upon the pending Linux
         * signal.
         */
-        if ((mask & XNRELAX) == 0 &&
-            xnthread_test_info(thread, XNKICKED)) {
-            if (wchan) {
-                thread->wchan = wchan;
-                xnsynch_forget_sleeper(thread);
+        if (xnthread_test_info(thread, XNKICKED)) {
+            if ((mask & XNRELAX) == 0) {
+                if (wchan) {
+                    thread->wchan = wchan;
+                    xnsynch_forget_sleeper(thread);
+                }
+                xnthread_clear_info(thread, XNRMID | XNTIMEO);
+                xnthread_set_info(thread, XNBREAK);
+                goto unlock_and_exit;
            }
-            xnthread_clear_info(thread, XNRMID | XNTIMEO);
-            xnthread_set_info(thread, XNBREAK);
-            goto unlock_and_exit;
+            WARN_ON(1);
        }
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
ksrc/nucleus/shadow.c +2 -0
index 38c1423..fc592a2 100644
@@ -2696,6 +2696,8 @@ static inline void do_sigwake_event(struct 
 task_struct *p)
        }
    }
 
+    WARN_ON(!signal_pending(p));
+
    /*
     * If a relaxed thread is getting a signal while running, we
Quoted 2 lines

* force it out of RPI, so that it won't keep a boosted

Finally, I was able to catch the warning(s). I got 38 of these before task ended:

[ 1109.336726] ------------[ cut here ]------------
[ 1109.336737] WARNING: at kernel/xenomai/nucleus/pod.c:1392 
xnpod_suspend_thread+0x17d/0x5a0()
[ 1109.336746] Hardware name: X7SBA
[ 1109.336755] Modules linked in: fr01_rtdm(O) netconsole configfs igb 
dca e1000e e1000 r8169 rt_e1000(O) rt_r8169(O) rtpacket(O) rtnet(O) 
coretemp psmouse microcode serio_raw shpchp lpc_ich i3200_edac video 
edac_core floppy
[ 1109.336908] Pid: 786, comm: ASYNC_TASK_1869 Tainted: G           O 
3.5.7-debug #38
[ 1109.336917] Call Trace:
[ 1109.336933]  [<ffffffff8103cdcf>] warn_slowpath_common+0x7f/0xc0
[ 1109.336949]  [<ffffffff8103ce2a>] warn_slowpath_null+0x1a/0x20
[ 1109.336965]  [<ffffffff8110b08d>] xnpod_suspend_thread+0x17d/0x5a0
[ 1109.336981]  [<ffffffff81117054>] xnshadow_relax+0xf4/0x250
[ 1109.336997]  [<ffffffff810cc73c>] ? __ipipe_restore_head+0x7c/0x100
[ 1109.337013]  [<ffffffff811181db>] xnshadow_harden+0x30b/0x340
[ 1109.337029]  [<ffffffff811183e0>] losyscall_event+0xb0/0x2f0
[ 1109.337045]  [<ffffffff810d0829>] ipipe_syscall_hook+0x89/0xd0
[ 1109.337061]  [<ffffffff810cbc68>] __ipipe_notify_syscall+0x158/0x340
[ 1109.337076]  [<ffffffff8102167a>] __ipipe_syscall_root+0x4a/0x1f0
[ 1109.337092]  [<ffffffff81367baa>] __ipipe_syscall_root_thunk+0x35/0x67
[ 1109.337108]  [<ffffffff81682217>] ? system_call_after_swapgs+0x54/0x6d
[ 1109.337117] ---[ end trace 9fc5fa66a7479311 ]---
Quoted 2 lines

The trace log is in the attachment.

Thanks. Could you drop the previous instrumentation patches, and give a try at this one? It fixes a flaw in the logic for maintaining the thread information bits, which may have caused the issue you observed:

ksrc/nucleus/pod.c +2 -1
index 0a2ee19..22fa91d 100644
@@ -1391,7 +1391,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
-		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | XNWAKEN | XNROBBED);
+		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | \
+				    XNWAKEN | XNROBBED | XNKICKED);
 	}
 
 	/* Don't start the timer for a thread indefinitely delayed by

TIA,

Signature · 1 line
Philippe.
#10 lore raw
Quoted 11 lines

Od: Philippe Gerum <[email protected]>

Thanks. Could you drop the previous instrumentation patches, and give a try at this one? It fixes a flaw in the logic for maintaining the thread information bits, which may have caused the issue you observed:

ksrc/nucleus/pod.c +0 -0
index 0a2ee19..22fa91d 100644

ksrc/nucleus/pod.c void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask, · line 1398

Quoted 9 lines
ksrc/nucleus/pod.c +2 -1
@@ -1391,7 +1391,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
-		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | XNWAKEN | XNROBBED);
+		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | \
+				    XNWAKEN | XNROBBED | XNKICKED);
 	}
 
 	/* Don't start the timer for a thread indefinitely delayed by

I applied the new patch and I was not able to reproduce the -EINTR problem to this moment. But one of the machines I tried during long term test over the weekend got frozen. But it could be also from different reason. What do you think?

Petr

#11 lore raw
Quoted 18 lines · Petr Cervenka
Quoted 18 lines

Od: Philippe Gerum <[email protected]>

Thanks. Could you drop the previous instrumentation patches, and give a try at this one? It fixes a flaw in the logic for maintaining the thread information bits, which may have caused the issue you observed:

ksrc/nucleus/pod.c +2 -1
index 0a2ee19..22fa91d 100644
@@ -1391,7 +1391,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
-		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | XNWAKEN | XNROBBED);
+		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | \
+				    XNWAKEN | XNROBBED | XNKICKED);
 	}
 
Quoted 4 lines

ksrc/nucleus/pod.c void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask, · line 1398

Quoted 2 lines
ksrc/nucleus/pod.c +0 -0
 	/* Don't start the timer for a thread indefinitely delayed by

I applied the new patch and I was not able to reproduce the -EINTR problem to this moment. But one of the machines I tried during long term test over the weekend got frozen. But it could be also from different reason. What do you think?

Could you enable all debug features (CONFIG_XENO_OPT_DEBUG), and particularly CONFIG_XENO_OPT_WATCHDOG? The system will be significantly slowed down due to the consistency checks on all internal lists (i.e. DEBUG_QUEUES), but this may give us some hints about the freeze.

Signature · 1 line
Philippe.
#12 lore raw
Quoted 23 lines

Od: Philippe Gerum

Quoted 16 lines
Quoted 16 lines

Thanks. Could you drop the previous instrumentation patches, and give a try at this one? It fixes a flaw in the logic for maintaining the thread information bits, which may have caused the issue you observed:

ksrc/nucleus/pod.c +2 -1
index 0a2ee19..22fa91d 100644
@@ -1391,7 +1391,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
-		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | XNWAKEN | XNROBBED);
+		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | \
+				    XNWAKEN | XNROBBED | XNKICKED);
 	}
 
Quoted 4 lines

ksrc/nucleus/pod.c void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask, · line 1398

Quoted 2 lines
ksrc/nucleus/pod.c +0 -0
 	/* Don't start the timer for a thread indefinitely delayed by

I applied the new patch and I was not able to reproduce the -EINTR problem to this moment. But one of the machines I tried during long term test over the weekend got frozen. But it could be also from different reason. What do you think?

Quoted 5 lines

Could you enable all debug features (CONFIG_XENO_OPT_DEBUG), and particularly CONFIG_XENO_OPT_WATCHDOG? The system will be significantly slowed down due to the consistency checks on all internal lists (i.e. DEBUG_QUEUES), but this may give us some hints about the freeze.

I have enabled almost all debug features and tortured several PCs for a week without a single problem. Thank you all for your help.

Petr

#13 lore raw
Quoted 23 lines · Petr Cervenka
Quoted 23 lines

Od: Philippe Gerum

Quoted 20 lines
Quoted 9 lines

Thanks. Could you drop the previous instrumentation patches, and give a try at this one? It fixes a flaw in the logic for maintaining the thread information bits, which may have caused the issue you observed:

ksrc/nucleus/pod.c +0 -0
index 0a2ee19..22fa91d 100644

ksrc/nucleus/pod.c void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask, · line 1398

Quoted 9 lines
ksrc/nucleus/pod.c +2 -1
@@ -1391,7 +1391,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t mask,
 		}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 
-		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | XNWAKEN | XNROBBED);
+		xnthread_clear_info(thread, XNRMID | XNTIMEO | XNBREAK | \
+				    XNWAKEN | XNROBBED | XNKICKED);
 	}
 
 	/* Don't start the timer for a thread indefinitely delayed by

I applied the new patch and I was not able to reproduce the -EINTR problem to this moment. But one of the machines I tried during long term test over the weekend got frozen. But it could be also from different reason. What do you think?

Quoted 8 lines
Quoted 5 lines

Could you enable all debug features (CONFIG_XENO_OPT_DEBUG), and particularly CONFIG_XENO_OPT_WATCHDOG? The system will be significantly slowed down due to the consistency checks on all internal lists (i.e. DEBUG_QUEUES), but this may give us some hints about the freeze.

I have enabled almost all debug features and tortured several PCs for a week without a single problem. Thank you all for your help.

Ok, thanks for testing this extensively. The suggested patch has been pushed to the maintenance tree.

Signature · 1 line
Philippe.