Skip to contentSkip to conversation

Xenomai 3: Wierd problem resuming task

DISCUSSION Mauro S. 3 participants 8 messages Jul 16, 2021 – Sep 14, 2021

lore
Share & tools
lore

Mauro S.

author
#0 lore raw

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU  NAME
  1  620    3          8          13         0     00048041    0.0  t12

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
100 signal.c: No such file or directory.
(gdb) bt

#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
#1  0x00007f0ec14eb379 in threadobj_suspend (thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2  0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

But the suspended task does not get resumed.

Any idea/suggestion?

Thanks in advance, regards

Signature · 1 line
Mauro
#1 lore raw
Quoted 41 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU  NAME 1  620    3          8          13         0     00048041    0.0  t12

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 100    signal.c: No such file or directory.
(gdb) bt
#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1  0x00007f0ec14eb379 in threadobj_suspend (thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2  0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

Can you derive a sharable simple test case from this? That will ensure we are not misinterpreting what you code actually does.

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
author
#2 lore raw

Il 16/07/21 11:47, Jan Kiszka ha scritto:

Quoted 44 lines · Mauro S. via Xenomai
Quoted 43 lines

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU  NAME
  1  620    3          8          13         0     00048041    0.0  t12

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 100    signal.c: No such file or directory.
(gdb) bt
#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1  0x00007f0ec14eb379 in threadobj_suspend (thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2  0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

But the suspended task does not get resumed.

Quoted 8 lines
Quoted 2 lines

Any idea/suggestion?

Can you derive a sharable simple test case from this? That will ensure we are not misinterpreting what you code actually does.

Jan

I will try to reduce the application code to a simple test, but I'm not sure to succeed. I will get back to you anyway.

Thanks.

--
Mauro

#3 lore raw
In reply to Mauro S.
Quoted 13 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Quoted 7 lines

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU  NAME
  1  620    3          8          13         0     00048041    0.0

t12

                                                            ^

That bit (XNSUSP) indicates that the core thinks the task is still in suspended state.

Quoted 23 lines

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
100 signal.c: No such file or directory.
(gdb) bt
#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1 0x00007f0ec14eb379 in threadobj_suspend
(thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2 0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at
task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

You may want to check what happens in __cobalt_kill() (kernel/cobalt/posix/signal.c), and in COBALT_SYSCALL(kill, ...), to make sure the call actually succeeds.

Signature · 1 line
Philippe.
author
#4 lore raw

Il 16/07/21 14:06, Philippe Gerum ha scritto:

Quoted 51 lines
Quoted 13 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Quoted 7 lines

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU PID MSW CSW XSC PF STAT %CPU NAME
1 620 3 8 13 0 00048041 0.0
t12

                                                             ^

That bit (XNSUSP) indicates that the core thinks the task is still in suspended state.

Quoted 23 lines

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
100 signal.c: No such file or directory.
(gdb) bt
#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1 0x00007f0ec14eb379 in threadobj_suspend
(thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2 0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at
task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 8 lines
Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

You may want to check what happens in __cobalt_kill() (kernel/cobalt/posix/signal.c), and in COBALT_SYSCALL(kill, ...), to make sure the call actually succeeds.

I traversed the code until lib/cobalt/signal.c (__cobalt_kill() library-side) and I cheched retval of XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig) (that is 0).

If I understand correctly, kernel/cobalt/posix/signal.c is kernel code. Should I add printks? Or should I have to attach gdb to kernel (I think I'm not able)

thanks

#5 lore raw
Quoted 59 lines · Mauro S.

Il 16/07/21 14:06, Philippe Gerum ha scritto:

Quoted 50 lines
Quoted 13 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Quoted 7 lines

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU PID MSW CSW XSC PF STAT %CPU NAME
1 620 3 8 13 0 00048041 0.0
t12

                                                             ^

That bit (XNSUSP) indicates that the core thinks the task is still in
suspended state.

Quoted 23 lines

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
100 signal.c: No such file or directory.
(gdb) bt
#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1 0x00007f0ec14eb379 in threadobj_suspend
(thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2 0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at
task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 7 lines
Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

You may want to check what happens in __cobalt_kill() (kernel/cobalt/posix/signal.c), and in COBALT_SYSCALL(kill, ...), to make sure the call actually succeeds.

Quoted 7 lines

I traversed the code until lib/cobalt/signal.c (__cobalt_kill() library-side) and I cheched retval of XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig) (that is 0).

If I understand correctly, kernel/cobalt/posix/signal.c is kernel code. Should I add printks? Or should I have to attach gdb to kernel (I think I'm not able)

printk() would be fine.

Signature · 1 line
Philippe.
author
#6 lore raw

Il 16/07/21 16:58, Philippe Gerum ha scritto:

Quoted 66 lines
Quoted 63 lines · Mauro S.

Il 16/07/21 14:06, Philippe Gerum ha scritto:

Quoted 50 lines
Quoted 13 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Quoted 7 lines

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU PID MSW CSW XSC PF STAT %CPU NAME

    1  620    3          8          13         0     00048041    0.0

t12

                                                              ^

That bit (XNSUSP) indicates that the core thinks the task is still in
suspended state.

Quoted 23 lines

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100
100 signal.c: No such file or directory.
(gdb) bt
#0 0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1 0x00007f0ec14eb379 in threadobj_suspend
(thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2 0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at
task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 7 lines
Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

You may want to check what happens in __cobalt_kill() (kernel/cobalt/posix/signal.c), and in COBALT_SYSCALL(kill, ...), to make sure the call actually succeeds.

I traversed the code until lib/cobalt/signal.c (__cobalt_kill() library-side) and I cheched retval of XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig) (that is 0).

Quoted 6 lines
Quoted 3 lines

If I understand correctly, kernel/cobalt/posix/signal.c is kernel code. Should I add printks? Or should I have to attach gdb to kernel (I think I'm not able)

printk() would be fine.

Hi Philippe an Jan,

I have to check more deeply my application because there are some other strange behaviors that make me think that there could be memory leaks somewhere (and a standalone simple test code does not have the problem I seen).

I will be back if I will find something regarding Xenomai.

Thanks again for your help.

Regards

Signature · 1 line
Mauro
author
#7 lore raw

Il 19/07/21 10:10, Mauro S. via Xenomai ha scritto:

Quoted 76 lines

Il 16/07/21 16:58, Philippe Gerum ha scritto:

Quoted 66 lines
Quoted 63 lines · Mauro S.

Il 16/07/21 14:06, Philippe Gerum ha scritto:

Quoted 50 lines
Quoted 13 lines · Mauro S. via Xenomai

Hi,

I'm using Xenomai3 (master branch, commit bca41678742be80c3a0d5a01935c671c385a95a1) on a X86_64bit Intel Atom x5-E8000 with 2GB RAM, using kernel from Xenomai repos, in Cobalt coniguration. SMI workaround is enabled and all latency tests are good.

I'm facing with a very weird problem in my application. I have some tasks with priority < 90 that call rt_task_suspend() on themselves. Then, I have a task with priority 99 that resumes all other tasks with rt_task_resume(), when they are suspended.

Quoted 7 lines

Sometimes a task does not get resumed.

In /proc/xenomai/sched/stat I have this status for my suspendend task:

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU NAME 1  620    3          8          13         0     00048041    0.0 t12

                                                              ^ That bit (XNSUSP) indicates that the core thinks the task is still in
suspended state.

Quoted 23 lines

Analizing the scenario attaching gdb to the application, I observe that the not-resuming task has this backtrace:

#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 100    signal.c: No such file or directory.
(gdb) bt
#0  0x00007f0ec14c9b38 in __cobalt_kill (pid=620, sig=65) at signal.c:100 #1  0x00007f0ec14eb379 in threadobj_suspend (thobj=thobj@entry=0x7f0ec06bfcd0) at threadobj.c:335
#2  0x00007f0ec15013dc in rt_task_suspend (task=task@entry=0x0) at task.c:1154

that seems to me OK. If I understood correctly, it is locked in its SIGSUSP handler, that calls sigsuspend() waiting SIGRESM to "restart".

Then, I placed some breakpoints where rt_task_resume() were called, and in rt_task_resume() itself. I set tcb->suspends=1 with GDB and followed the subsequent call of threadobj_resume(). Then, I placed some breakpoints in threadobj_resume, I forced __THREAD_S_SUSPENDED bit in thobj->status, and I observed that __RT(kill(thobj->pid, SIGRESM)) got called, with a retval 0. thobj->pid has the right value.

Quoted 7 lines
Quoted 4 lines

But the suspended task does not get resumed.

Any idea/suggestion?

You may want to check what happens in __cobalt_kill() (kernel/cobalt/posix/signal.c), and in COBALT_SYSCALL(kill, ...), to make sure the call actually succeeds.

I traversed the code until lib/cobalt/signal.c (__cobalt_kill() library-side) and I cheched retval of XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig) (that is 0).

Quoted 6 lines
Quoted 3 lines

If I understand correctly, kernel/cobalt/posix/signal.c is kernel code. Should I add printks? Or should I have to attach gdb to kernel (I think I'm not able)

printk() would be fine.

Hi Philippe an Jan,

Quoted 8 lines

I have to check more deeply my application because there are some other strange behaviors that make me think that there could be memory leaks somewhere (and a standalone simple test code does not have the problem I seen).

I will be back if I will find something regarding Xenomai.

Thanks again for your help.

Regards

Hi all,

after a ton of tries, small test executables, headaches...I think I can assert with almost certainty that the problem I observe is the same reported in this old thread [1] and then that is better to move to semaphores instead of using rt_task_suspend/rt_task_resume.

Thanks to all, regards

[1] https://xenomai.org/pipermail/xenomai/2016-January/035781.html

Signature · 1 line
Mauro