Issue with Auto relax and nested mutexes
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt is not going down to 0. Another observation is that I do not hit rt_mutex_release in the kernel in the problem scenario, I believe when the thread undergoes a priority inversion. This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hitting rt_mutex_relase or am I missing anything?
If I have both the tasks running at priority 0, I stay in the secondary domain, rt_mutex_release is invoked as expected, the rescnt goes down to 0 when all the mutexes are released.
Has anyone faced this problem?
Rgds,
Makarand
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
#include <xenomai/asm-generic/bits/current.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <stdio.h>
#include <native/task.h>
#include <native/mutex.h>
#include <nucleus/thread.h>
#include <rtdk.h>
#include <stdlib.h>
#include <unistd.h>
RT_TASK task0, task1, task2;RT_MUTEX mux1, mux2, mux3, mux4;
char buff[8192];
void task1_func(void *arg)
{
RT_TASK_INFO info;
int current_in_primary = 0;
while(true)
{
rt_task_inquire(&task1, &info);
current_in_primary = !(xeno_get_current_mode() & XNRELAX);
rt_printf("bP: %i, cp: %i, mode: %i\n",
info.bprio, info.cprio, current_in_primary);
rt_mutex_acquire(&mux1, TM_INFINITE);
rt_mutex_acquire(&mux2, TM_INFINITE);
rt_mutex_acquire(&mux3, TM_INFINITE);
rt_printf("Acquire complete\n");
rt_task_sleep(2222222222LL);
rt_mutex_release(&mux3);
rt_mutex_release(&mux2);
rt_mutex_release(&mux1);
rt_printf("Release complete\n");
}
}void task2_func(void *arg)
{
int counter = 0;
while(true)
{
if (2 == counter)
{
rt_printf("Grabbing mux in HP\n");
rt_mutex_acquire(&mux1, TM_INFINITE);
rt_mutex_acquire(&mux2, TM_INFINITE);
rt_mutex_acquire(&mux3, TM_INFINITE);
rt_printf("Mux held by Task2\n");
}
rt_mutex_acquire(&mux4, TM_INFINITE);
rt_task_sleep(4444444444LL);
if (2 == counter)
{
rt_mutex_release(&mux3);
rt_mutex_release(&mux2);
rt_mutex_release(&mux1);
}
rt_mutex_release(&mux4);
counter++;
}
}int main(int argc, char **argv)
{
int prio1, prio2;
if (argc == 1)
{
printf("Pl enter prio1 prio1\n");
exit (0);
}
prio1 = atoi(argv[1]);
prio2 = atoi(argv[2]);
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_print_auto_init(1);
rt_task_shadow(&task0, "Task 0", 10, 0);
rt_mutex_create(&mux1, "test_mux1");
rt_mutex_create(&mux2, "test_mux2");
rt_mutex_create(&mux3, "test_mux3");
rt_mutex_create(&mux4, "test_mux4");
printf("Spawning: tasks\n");
rt_task_spawn(&task1, "TTTTTTTTTTT", 0, prio1, 0, task1_func, NULL);
rt_task_spawn(&task2, "TASK2", 0, prio2, 0, task2_func, NULL);
while (1) {
rt_task_sleep(5000000LL);
}
}Quoted 10 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt is not going down to 0.
From your code, task1 would auto-relax only if started with priority 0, which is what I get here:
-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...
Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...
In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.
Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?
These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented.
Quoted 6 lines
If I have both the tasks running at priority 0, I stay in the secondary domain,
rt_mutex_releaseis invoked as expected, the rescnt goes down to 0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire complete
Rgds,
Mak.
Quoted 81 lines · Philippe Gerum
Quoted 10 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt is not going down to 0.
From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented.
Quoted 6 lines
If I have both the tasks running at priority 0, I stay in the secondary domain,
rt_mutex_releaseis invoked as expected, the rescnt goes down to 0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 7 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
Eeek. Ok, I definitely need to reproduce this. I'm slightly buried alive in Xenomai 3 stuff right now, but I'll have a look at this asap.
Quoted 111 lines
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 81 lines · Philippe Gerum
Quoted 10 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt is not going down to 0.
From your code, task1 would auto-relax only if started with priority 0, which is what I get here:
-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented.
Quoted 6 lines
If I have both the tasks running at priority 0, I stay in the secondary domain,
rt_mutex_releaseis invoked as expected, the rescnt goes down to 0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented."
When the first task is started with prio 0, I always see that rt_mutex_release is invoked in the kernel. even when there is no contention.
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0
[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C
Rgds,
Mak.
Quoted 116 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 80 lines · Philippe Gerum
Quoted 10 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt is not going down to 0.
From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented.
Quoted 6 lines
If I have both the tasks running at priority 0, I stay in the secondary domain,
rt_mutex_releaseis invoked as expected, the rescnt goes down to 0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 8 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented."
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.
I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Quoted 189 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 118 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 82 lines · Philippe Gerum
Quoted 11 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0, which is what I get here:
-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented.
Quoted 7 lines
If I have both the tasks running at priority 0, I stay in the secondary domain,
rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented."
Quoted 8 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 194 lines
Quoted 192 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 121 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 85 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0, which is what I get here:
-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke rt_mutex_release in kernel. Will try to check it out.
Rgds,
Mak.
Quoted 208 lines · Philippe Gerum
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space unless the released mutex was actually contented."
Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 190 lines
Quoted 189 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 120 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at 1 in the kernel.
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 85 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to task1:
-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32 (52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 6 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when the thread undergoes a priority inversion.This may be a problem as the rescnt would not get decremented. Not sure how the mutex is releasing wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 4 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
Ah, bad side effect of __xnsched_rt_setparam likely. Ok, I need to have a deeper look, but this would make sense.
Quoted 228 lines
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Rgds,
Mak.Quoted 218 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 199 lines
Quoted 198 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 129 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 92 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.
Does this help in your case?
include/nucleus/sched-rt.h +1 -1
@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );else xnthread_set_state (thread,XNOTHER );
Quoted 225 lines
Rgds,
Mak.Quoted 218 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 199 lines
Quoted 198 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 129 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 92 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Hi Phillipe,
A bit surprised to see a change in sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER in rt_task_set_priority. I think this would fix that problem as well.
Will test the patch and get back with the results.
Thanks and Rgds,
Mak.
Quoted 244 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );else xnthread_set_state (thread,XNOTHER );Quoted 220 lines
Rgds,
Mak.Quoted 215 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 197 lines
Quoted 197 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 129 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 92 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak
[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#
Quoted 273 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 238 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );else xnthread_set_state (thread,XNOTHER );Quoted 215 lines
Rgds,
Mak.Quoted 211 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 193 lines
Quoted 193 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 125 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 88 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 9 lines
Rgds,
MakarandQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________
NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 4 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
This needs more testing, but this bug is a must fix for 2.6.1 for sure. Your test code does help a lot in this respect. Thanks for the heads up.
Quoted 314 lines
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 283 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 22 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 226 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 224 lines
Rgds,
Mak.Quoted 220 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 8 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 201 lines
Quoted 201 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 132 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first
task never jumps back to seconodary. Here is my output. The mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 93 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to
mutexes. I am using nested mutexes. The code is attached to this email.Quoted 4 lines
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, a rt_task_set_priority is done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in xnsynch_acquire. Hence the rescnt is not incremented.
The reason for that is, while doing a rt_task_set_priority, __xnsched_rt_setparam is invoked before the thread is reniced.
To resolve this issue, I had to set the XNOTHER bit in __xnpod_set_thread_schedparam after the thread was reniced or in rt_task_set_priority. Both the code changes are given below:
rt_task_set_priority(....
+ if (0==prio)
+ {
+ xnthread_set_state(&task->thread_base, XNOTHER);
+ }
xnpod_set_thread_schedparam(...
#ifdef CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))
xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))
xnthread_set_info(thread, XNPRIOSET);
}+ if (xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio || !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+ xnthread_clear_state(thread, XNOTHER);
+ else
+ xnthread_set_state(thread, XNOTHER);
+ }
Setting XNOTHER in rt_task_set_priority does not look appropriate. I believe the right place is in the xnpod_set_thread_schedparam.
Would highly appreciate your views.
Rgds,
Mak
Quoted 306 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 272 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 238 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );else xnthread_set_state (thread,XNOTHER );Quoted 215 lines
Rgds,
Mak.Quoted 211 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 7 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is a non-rt thread". This is because we have to jump to kernel space to track rescnt.
Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 193 lines
Quoted 193 lines
I have an instrumented kernel. The kernel trace is given below. In this trace only task1 is running at prio 0. It should be easy to follow:
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 125 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first task never jumps back to seconodary. Here is my output. The mode never goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 88 lines · Philippe Gerum
Quoted 4 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
Quoted 8 lines
I am noticing an issue while using the auto relax feature related to mutexes. I am using nested mutexes. The code is attached to this email.
The problem is that I am not relaxing after a RT thread grabs and releases a mutex. On further investigation, it was noted that the rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 9 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai threads only (i.e. prio == 0).
Quoted 9 lines
Rgds,
MakarandQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________
NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 7 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
That is deliberate. We explicitely decided to not support such case and volontarily send a SIGDEBUG when it happens, in order to signal do that you are doing an unsupported operation.
Can you show us a scenario where there is no other solution than changing priority while holding a mutex?
Signature · 1 line
Gilles.
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.
If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 373 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Would highly appreciate your views.
Rgds,
MakQuoted 321 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 287 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 22 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 231 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 229 lines
Rgds,
Mak.Quoted 225 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 8 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 206 lines
Quoted 206 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 137 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first
task never jumps back to seconodary. Here is my output. The mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 98 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to
mutexes. I am using nested mutexes. The code is attached to this email.Quoted 6 lines
The problem is that I am not relaxing after a RT thread grabs and
releases a mutex. On further investigation, it was noted that the
rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 10 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe
when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai
threads only (i.e. prio == 0).Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 29 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
Quoted 6 lines
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Even if you implement manual priority ceiling, you should change priority before acquiring the mutex, not after, otherwise there is a race condition.
Signature · 1 line
Gilles.
Hi Gilles,
GC: "Even if you implement manual priority ceiling, you should change priority before acquiring the mutex, not after, otherwise there is a race condition."
That's how it's being done.
The problem that is faced is basically due to XNOTHER bit being set before the base priority is adjusted in the kernel.
I have tried to explain the scenario again in my last email.
Your inputs will be highly appreciated.
Rgds,
Mak
Quoted 39 lines · Gilles Chanteperdrix
Quoted 28 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
Quoted 6 lines
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Even if you implement manual priority ceiling, you should change priority before acquiring the mutex, not after, otherwise there is a race condition.
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Hi Philippe,
I think I may have not communicated the scenario properly. I am not trying to control the priorities from user space during resource contention. That is left to the kernel. Let me try again.
At some point, my application which was relaxed has to run with a real time priority. That's when I invoke rt_task_set_priority to change the base priority. After the critical section is past, the thread has to relax again where the priority is set to 0 again.
The rt_task_set_priority API allows me to change the task priority on the fly, so I think that the operation is supported and legal. Pl feel free to correct me if that is not true.
This change of priorities does introduce the race condition that was encountered which can be handled properly in the kernel using any of the 2 approaches that were mentioned.
Your comments are highly valued and I look forward to your opinions.
Rgds,
Mak.
Quoted 408 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 42 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Quoted 328 lines
Would highly appreciate your views.
Rgds,
MakQuoted 320 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 287 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 22 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when task1 gets a priority boost and starts running with priority 1. That's when the rescnt is not decremented.
It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 231 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 229 lines
Rgds,
Mak.Quoted 225 lines · Philippe Gerum
Quoted 7 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel space
unless the released mutex was actually contented."Quoted 8 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 206 lines
Quoted 206 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 137 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start seeing
the problem after task2 grabs the mutex and releases them. The first
task never jumps back to seconodary. Here is my output. The mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 98 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature related to
mutexes. I am using nested mutexes. The code is attached to this email.Quoted 6 lines
The problem is that I am not relaxing after a RT thread grabs and
releases a mutex. On further investigation, it was noted that the
rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 10 lines
Another observation is that I do not hit
rt_mutex_releasein the kernel in the problem scenario, I believe
when
the thread undergoes a priority inversion.This may be a problem as the
rescnt would not get decremented. Not sure how the mutex is releasing
wiithout hittingrt_mutex_relaseor am I missing anything?These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented.Quoted 8 lines
If I have both the tasks running at priority 0, I stay in the secondary
domain,rt_mutex_releaseis invoked as expected, the rescnt goes down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai
threads only (i.e. prio == 0).Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
Quoted 6 lines · Makarand Pradhan
Hi Philippe,
I think I may have not communicated the scenario properly. I am not trying to control the priorities from user space during resource contention. That is left to the kernel. Let me try again.
Quoted 8 lines
At some point, my application which was relaxed has to run with a real time priority. That's when I invoke
rt_task_set_priorityto change the base priority. After the critical section is past, the thread has to relax again where the priority is set to 0 again.The
rt_task_set_priorityAPI allows me to change the task priority on the fly, so I think that the operation is supported and legal. Pl feel free to correct me if that is not true.
What is not supported is:
get_mutexset_priority(current)release_mutex
This can't be a valid operation, because of the reason I mentioned earlier. So, regardless of the reason why you call rt_set_task_priority(), you may not call it while holding a mutex.
What happens afterward, e.g. not getting the auto-relax feature back is irrelevant in this case.
So, if your app does:
set_priority(current, > 0)get_mutexrelease_mutexset_priority(current, 0)
then fine, and not getting back the auto-relax after switching to priority 0 would indeed reveal a kernel issue. But the former scenario is wrong.
Quoted 432 lines
This change of priorities does introduce the race condition that was encountered which can be handled properly in the kernel using any of the 2 approaches that were mentioned.
Your comments are highly valued and I look forward to your opinions.
Rgds,
Mak.Quoted 419 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 42 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Quoted 339 lines
Would highly appreciate your views.
Rgds,
MakQuoted 331 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 298 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I
had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 24 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when
task1 gets a priority boost and starts running with priority 1. That's
when the rescnt is not decremented.It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 238 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 236 lines
Rgds,
Mak.Quoted 232 lines · Philippe Gerum
Quoted 8 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented."Quoted 9 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to
track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 211 lines
Quoted 211 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 141 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start
seeing
the problem after task2 grabs the mutex and releases them. The first
task never jumps back to seconodary. Here is my output. The mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 101 lines · Philippe Gerum
Quoted 16 lines · Makarand Pradhan
Hi,
I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature
related to
mutexes. I am using nested mutexes. The code is attached to
this
email.The problem is that I am not relaxing after a RT thread grabs
and
releases a mutex. On further investigation, it was noted that
the
rescnt
is not going down to 0.From your code, task1 would auto-relax only if started with priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the result.
I'm running current 2.6 HEAD commit (
168da46de), kernel 3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Quoted 11 lines
Another observation is that I do not hit
rt_mutex_release in the kernel in the problem scenario, I
believe
when
the thread undergoes a priority inversion.This may be a
problem
as the
rescnt would not get decremented. Not sure how the mutex is
releasing
wiithout hitting rt_mutex_relase or am I missing anything?These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented.Quoted 9 lines
If I have both the tasks running at priority 0, I stay in the
secondary
domain, rt_mutex_release is invoked as expected, the rescnt
goes
down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt Xenomai
threads only (i.e. prio == 0).Quoted 13 lines
Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.
Signature · 1 line
Philippe.
Hi,
The scenario is:
Start task prio 0
<Task is running>
Set priority 85
<Do something>
Set priority 0get_mutex <-- rescnt not incremented as XNOTHER is not set. <Do something> <-- XNOTHER gets set somewhere Release mutex <-- Sends a SIGDEBUG/SIGXCPU
Am trying to write a simple app that will reveal the issue. Will send it out shortly.
Rgds,
Mak
Quoted 470 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Hi Philippe,
I think I may have not communicated the scenario properly. I am not trying to control the priorities from user space during resource contention. That is left to the kernel. Let me try again.
Quoted 8 lines
At some point, my application which was relaxed has to run with a real time priority. That's when I invoke
rt_task_set_priorityto change the base priority. After the critical section is past, the thread has to relax again where the priority is set to 0 again.The
rt_task_set_priorityAPI allows me to change the task priority on the fly, so I think that the operation is supported and legal. Pl feel free to correct me if that is not true.What is not supported is:
get_mutexset_priority(current)release_mutexThis can't be a valid operation, because of the reason I mentioned earlier. So, regardless of the reason why you call
rt_set_task_priority(), you may not call it while holding a mutex.What happens afterward, e.g. not getting the auto-relax feature back is irrelevant in this case.
So, if your app does:
set_priority(current,> 0)get_mutexrelease_mutexset_priority(current, 0)then fine, and not getting back the auto-relax after switching to priority 0 would indeed reveal a kernel issue. But the former scenario is wrong.
Quoted 4 lines
This change of priorities does introduce the race condition that was encountered which can be handled properly in the kernel using any of the 2 approaches that were mentioned.
Quoted 424 lines
Your comments are highly valued and I look forward to your opinions.
Rgds,
Mak.Quoted 417 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 42 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Quoted 338 lines
Would highly appreciate your views.
Rgds,
MakQuoted 331 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 298 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I
had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 24 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when
task1 gets a priority boost and starts running with priority 1. That's
when the rescnt is not decremented.It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 238 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 236 lines
Rgds,
Mak.Quoted 232 lines · Philippe Gerum
Quoted 8 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented."Quoted 9 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to
track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 211 lines
Quoted 211 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 141 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I start
seeing
the problem after task2 grabs the mutex and releases them. The first
task never jumps back to seconodary. Here is my output. The mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays stuck at
1 in the kernel.[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 1 Acquire complete Release complete bP: 0, cp: 0, mode: 1 Acquire completeRgds,
Mak.Quoted 101 lines · Philippe Gerum
On 01/09/2012 09:50 PM, Makarand Pradhan wrote:
Hi,I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature
related to
mutexes. I am using nested mutexes. The code is attached to
this
email.The problem is that I am not relaxing after a RT thread grabs
and
releases a mutex. On further investigation, it was noted that
the
rescnt
is not going down to 0.
From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero
priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the
result.I'm running current 2.6 HEAD commit (168da46de), kernel
3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Another observation is that I do not hit
rt_mutex_release in the kernel in the problem scenario, I
believe
when
the thread undergoes a priority inversion.This may be a
problem
as the
rescnt would not get decremented. Not sure how the mutex is
releasing
wiithout hitting rt_mutex_relase or am I missing anything?These are fast mutexes, the thread does not have to jump to
kernel
space
unless the released mutex was actually contented.If I have both the tasks running at priority 0, I stay in the
secondary
domain, rt_mutex_release is invoked as expected, the rescnt
goes
down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt
Xenomai
threads only (i.e. prio == 0).Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
____________________________________________________________________________________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.--
Philippe.
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
The attached c file should get you a SIGXCPU/SIGDEBUG revealing the bug that I am talking about.
Rgds,
Mak.
Quoted 500 lines · Makarand Pradhan
Hi,
The scenario is:
Start task prio 0
<Task is running>
Set priority 85
<Do something>
Set priority 0
get_mutex<-- rescnt not incremented as XNOTHER is not set. <Do something> <-- XNOTHER gets set somewhere Release mutex<-- Sends a SIGDEBUG/SIGXCPUAm trying to write a simple app that will reveal the issue. Will send it out shortly.
Rgds,
MakQuoted 460 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Hi Philippe,
I think I may have not communicated the scenario properly. I am not trying to control the priorities from user space during resource contention. That is left to the kernel. Let me try again.
Quoted 8 lines
At some point, my application which was relaxed has to run with a real time priority. That's when I invoke
rt_task_set_priorityto change the base priority. After the critical section is past, the thread has to relax again where the priority is set to 0 again.The
rt_task_set_priorityAPI allows me to change the task priority on the fly, so I think that the operation is supported and legal. Pl feel free to correct me if that is not true.What is not supported is:
get_mutexset_priority(current)release_mutexThis can't be a valid operation, because of the reason I mentioned earlier. So, regardless of the reason why you call
rt_set_task_priority(), you may not call it while holding a mutex.What happens afterward, e.g. not getting the auto-relax feature back is irrelevant in this case.
So, if your app does:
set_priority(current,> 0)get_mutexrelease_mutexset_priority(current, 0)then fine, and not getting back the auto-relax after switching to priority 0 would indeed reveal a kernel issue. But the former scenario is wrong.
Quoted 421 lines
This change of priorities does introduce the race condition that was encountered which can be handled properly in the kernel using any of the 2 approaches that were mentioned.
Your comments are highly valued and I look forward to your opinions.
Rgds,
Mak.Quoted 411 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 376 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Would highly appreciate your views.
Rgds,
MakQuoted 327 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 294 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I
had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 24 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when
task1 gets a priority boost and starts running with priority 1. That's
when the rescnt is not decremented.It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 238 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 236 lines
Rgds,
Mak.Quoted 232 lines · Philippe Gerum
Quoted 8 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to kernel
space
unless the released mutex was actually contented."Quoted 9 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_releaseis invoked in the kernel. even when there is no contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to
track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 211 lines
Quoted 211 lines
I have an instrumented kernel. The kernel trace is given below. In this
trace only task1 is running at prio 0. It should be easy to follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:01 ruggedcom kernel: RML Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0 Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release Jan 10 10:37:03 ruggedcom kernel: RML Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1 Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0 Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0 Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0 Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^CRgds,
Mak.Quoted 141 lines · Makarand Pradhan
Hi Phillippe,
You are right. Task 1 requires to be started with prio 0. I
start
seeing
the problem after task2 grabs the mutex and releases them. The
first
task never jumps back to seconodary. Here is my output. The
mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays
stuck at
1 in the kernel.[email protected]:~# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Grabbing mux in HP
Mux held by Task2
Release complete
bP: 0, cp: 0, mode: 1
Acquire complete
Release complete
bP: 0, cp: 0, mode: 1
Acquire completeRgds,
Mak.On 10/01/12 10:11 AM, Philippe Gerum wrote:
On 01/09/2012 09:50 PM, Makarand Pradhan wrote:
Hi,I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature
related to
mutexes. I am using nested mutexes. The code is attached to
this
email.The problem is that I am not relaxing after a RT thread grabs
and
releases a mutex. On further investigation, it was noted that
the
rescnt
is not going down to 0.
From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero
priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the
result.I'm running current 2.6 HEAD commit (168da46de), kernel
3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Another observation is that I do not hit
rt_mutex_release in the kernel in the problem scenario, I
believe
when
the thread undergoes a priority inversion.This may be a
problem
as the
rescnt would not get decremented. Not sure how the mutex is
releasing
wiithout hitting rt_mutex_relase or am I missing anything?These are fast mutexes, the thread does not have to jump to
kernel
space
unless the released mutex was actually contented.If I have both the tasks running at priority 0, I stay in the
secondary
domain, rt_mutex_release is invoked as expected, the rescnt
goes
down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt
Xenomai
threads only (i.e. prio == 0).Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
_____________________________________________________________________Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.--
Philippe.--
___________________________________________________________________________
NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.
_____________________________________________________________________
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________
#include <xenomai/asm-generic/bits/current.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <stdio.h>
#include <native/task.h>
#include <native/mutex.h>
#include <native/timer.h>
#include <nucleus/thread.h>
#include <rtdk.h>
#include <stdlib.h>
#include <unistd.h>
RT_TASK task0, task1, task2;RT_MUTEX mux1, mux2, mux3, mux4;
char buff[8192];
void task1_func(void *arg)
{
RT_TASK_INFO info;
int current_in_primary = 0;
int i = 0;
RTIME st, en;
int iterations = 10000;
rt_task_set_priority(&task1, 85);
rt_task_set_priority(&task1, 0);
rt_mutex_acquire(&mux1, TM_INFINITE);
rt_task_sleep(2222222222LL);
rt_mutex_release(&mux1);
rt_printf("Should get a SIGDEBUG/SIGXCPU now\n");}
int main(int argc, char **argv)
{
int prio1, prio2;
if (argc == 1)
{
printf("Pl enter prio1 prio1\n");
exit (0);
}
prio1 = atoi(argv[1]);
prio2 = atoi(argv[2]);
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_print_auto_init(1);
rt_task_shadow(&task0, "Task 0", 10, 0);
rt_mutex_create(&mux1, "test_mux1");
rt_mutex_create(&mux2, "test_mux2");
rt_mutex_create(&mux3, "test_mux3");
rt_mutex_create(&mux4, "test_mux4");
printf("Spawning: tasks %x\n", XNTHREAD_STATE_SPARE0);
rt_task_spawn(&task1, "PRIO_BUG", 0, prio1, 0, task1_func, NULL);
while (1) {
rt_task_sleep(5000000LL);
}
}Hi Phiippe,
Just wanted to send a gentle reminder regarding the issue related to task priority and mutexes.
The scenario under discussion was:
Start task prio 0
<Task is running>
Set priority 85
<Do something>
Set priority 0
get_mutex <-- rescnt not incremented as XNOTHER is not set.
<Do something> <-- XNOTHER gets set somewhere
Release mutex <-- Sends a SIGDEBUG/SIGXCPU
Would highly appreciate your opinion. Do you feel that there is a genuine issue out here?
Rgds,
Mak.
Quoted 520 lines · Makarand Pradhan
The attached c file should get you a SIGXCPU/SIGDEBUG revealing the bug that I am talking about.
Rgds,
Mak.Quoted 488 lines · Makarand Pradhan
Hi,
The scenario is:
Start task prio 0
<Task is running>
Set priority 85
<Do something>
Set priority 0
get_mutex<-- rescnt not incremented as XNOTHER is not set.
<Do something> <-- XNOTHER gets set somewhere
Release mutex<-- Sends a SIGDEBUG/SIGXCPUAm trying to write a simple app that will reveal the issue. Will send it out shortly.
Rgds,
MakQuoted 460 lines · Philippe Gerum
Quoted 6 lines · Makarand Pradhan
Hi Philippe,
I think I may have not communicated the scenario properly. I am not trying to control the priorities from user space during resource contention. That is left to the kernel. Let me try again.
Quoted 8 lines
At some point, my application which was relaxed has to run with a real time priority. That's when I invoke
rt_task_set_priorityto change the base priority. After the critical section is past, the thread has to relax again where the priority is set to 0 again.The
rt_task_set_priorityAPI allows me to change the task priority on the fly, so I think that the operation is supported and legal. Pl feel free to correct me if that is not true.What is not supported is:
get_mutexset_priority(current)release_mutexThis can't be a valid operation, because of the reason I mentioned earlier. So, regardless of the reason why you call
rt_set_task_priority(), you may not call it while holding a mutex.What happens afterward, e.g. not getting the auto-relax feature back is irrelevant in this case.
So, if your app does:
set_priority(current,> 0)get_mutexrelease_mutexset_priority(current, 0)then fine, and not getting back the auto-relax after switching to priority 0 would indeed reveal a kernel issue. But the former scenario is wrong.
Quoted 421 lines
This change of priorities does introduce the race condition that was encountered which can be handled properly in the kernel using any of the 2 approaches that were mentioned.
Your comments are highly valued and I look forward to your opinions.
Rgds,
Mak.Quoted 411 lines · Philippe Gerum
Quoted 8 lines · Makarand Pradhan
Hi,
Another problem was encountered with rescnt related to nested mutexes.
This time the rescnt is not incrementing because the XNOTHER bit is not set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing my application to crash.
Quoted 7 lines
The scenario is as follows:
1. Thread started with priority 0. (Relaxed)
2. This thread uses mutexes which causes Priority Inversions.
3. At some point, art_task_set_priorityis done to change the priority. (RT 85).
4. Some time later the priority is set back to 0.If I understand it properly, your runtime scenario is badly broken I'm afraid. By contrast to priority ceiling, priority inheritance is about leaving the responsibility to the _kernel_ to pick the best dynamic priority for your thread to solve a priority inversion.
Therefore, by changing your dynamic priority while holding a mutex, your application is preventing the kernel to do the job you previously assigned to it. Worst, you could be causing unexpected latencies to other threads your application has no clue about, or just can't tell whether they compete with your thread for accessing the resource at that specific time.
After all, this is your application that defined the contented mutex, and as such the fact that priority inheritance might be involved at some point. If you don't trust the kernel and want to deal with priorities manually during resource contention, then maybe you should use a different mutual exclusion mechanism not implementing priority inheritance, e.g. a plain binary semaphore.
Quoted 376 lines
The problem again revolves around setting XNOTHER. In the problem scenario, the XNOTHER bit is not set in
xnsynch_acquire. Hence the rescnt is not incremented.The reason for that is, while doing a
rt_task_set_priority,__xnsched_rt_setparamis invoked before the thread is reniced.To resolve this issue, I had to set the XNOTHER bit in
__xnpod_set_thread_schedparamafter the thread was reniced or inrt_task_set_priority. Both the code changes are given below:rt_task_set_priority(....
+ if (0==prio)
+ {
+xnthread_set_state(&task->thread_base, XNOTHER);
+ }xnpod_set_thread_schedparam(...
#ifdef
CONFIG_XENO_OPT_PERVASIVE
if (propagate) {
if (xnthread_test_state(thread, XNRELAX))xnshadow_renice(thread);
else if (xnthread_test_state(thread, XNSHADOW))xnthread_set_info(thread, XNPRIOSET);
}+ if (
xnthread_test_state(thread, XNSHADOW)) {
+ // if (thread->bprio|| !xnthread_test_state(thread, XNBOOST))
+ if (thread->bprio)
+xnthread_clear_state(thread, XNOTHER);
+ else
+xnthread_set_state(thread, XNOTHER);
+ }Setting XNOTHER in
rt_task_set_prioritydoes not look appropriate. I believe the right place is in thexnpod_set_thread_schedparam.Would highly appreciate your views.
Rgds,
MakQuoted 327 lines · Makarand Pradhan
The patch does work. Thanks.
Will it be available in the next release of xenomai?
Rgds,
Mak[email protected]:~# ./relax 0 1 Spawning: tasks bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete Grabbing mux in HP Mux held by Task2 Release complete bP: 0, cp: 0, mode: 0 Acquire complete Release complete bP: 0, cp: 0, mode: 0 Acquire complete ^C [email protected]:~#Quoted 294 lines · Makarand Pradhan
Hi Phillipe,
A bit surprised to see a change in
sched-rt.h. I had another problem earlier where the XNOTHER was not getting set after a priority change. I
had to look at the code that you have modified. Although I had temporarily worked around it by setting the XNOTHER inrt_task_set_priority. I think this would fix that problem as well.Will test the patch and get back with the results.
Thanks and Rgds,
Mak.Quoted 24 lines · Philippe Gerum
Quoted 9 lines · Makarand Pradhan
Based on my testing, it is noted that the rescnt is not released when
task1 gets a priority boost and starts running with priority 1. That's
when the rescnt is not decremented.It would imply that we may be checking the current priority while testing if we want to invoke
rt_mutex_releasein kernel. Will try to check it out.Does this help in your case?
include/nucleus/sched-rt.h +1
-1@@ -87,7 +87,7 @@ static inline void __xnsched_rt_setparam(struct xnthread *thread, { thread->cprio = p->rt.prio;if (xnthread_test_state (thread,XNSHADOW )) { -if (thread->cprio) +if (thread->bprio || !xnthread_test_state (thread,XNBOOST ))xnthread_clear_state (thread,XNOTHER );Quoted 238 lines
else
xnthread_set_state(thread, XNOTHER);Quoted 236 lines
Rgds,
Mak.Quoted 232 lines · Philippe Gerum
Quoted 8 lines · Philippe Gerum
Quoted 7 lines · Makarand Pradhan
Another point:
"These are fast mutexes, the thread does not have to jump to
kernel
space
unless the released mutex was actually contented."Quoted 9 lines
Quoted 3 lines
When the first task is started with prio 0, I always see that
rt_mutex_release is invoked in the kernel. even when there is no
contention.I should have added: "unless there is no contention ... or the caller is
a non-rt thread". This is because we have to jump to kernel space to
track rescnt.Ok, next try: "unless the mutex was contented ... or the caller is a non-rt thread".
Quoted 211 lines
Quoted 211 lines
I have an instrumented kernel. The kernel trace is given below.
In this
trace only task1 is running at prio 0. It should be easy to
follow:Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 0, switched: 0
Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 0, switched: 0
Jan 10 10:36:59 ruggedcom kernel: lo: rescnt: 1, switched: 1
Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 2, switched: 0
Jan 10 10:36:59 ruggedcom kernel: hi: rescnt: 3, switched: 0
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0
Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:01 ruggedcom kernel: RML
Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0
Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:01 ruggedcom kernel: RML
Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 1, switched: 0
Jan 10 10:37:01 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:01 ruggedcom kernel: RML
Jan 10 10:37:01 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:01 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 0, switched: 0
Jan 10 10:37:01 ruggedcom kernel: lo: rescnt: 1, switched: 1
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 2, switched: 0
Jan 10 10:37:01 ruggedcom kernel: hi: rescnt: 3, switched: 0
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0
Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:03 ruggedcom kernel: RML
Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0
Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:03 ruggedcom kernel: RML
Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 1, switched: 0
Jan 10 10:37:03 ruggedcom kernel: __rt_mutex_release
Jan 10 10:37:03 ruggedcom kernel: RML
Jan 10 10:37:03 ruggedcom kernel: rt_mutex_release: lockcnt: 1
Jan 10 10:37:03 ruggedcom kernel: xnsynch_release_thread: BP: 0
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 0, switched: 0
Jan 10 10:37:03 ruggedcom kernel: lo: rescnt: 1, switched: 1
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 2, switched: 0
Jan 10 10:37:03 ruggedcom kernel: hi: rescnt: 3, switched: 0
Jan 10 10:37:04 ruggedcom kernel: hi: rescnt: 3, switched: 0[email protected]:~# ./a.out 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
^CRgds,
Mak.On 10/01/12 10:26 AM, Makarand Pradhan wrote:
Hi Phillippe,You are right. Task 1 requires to be started with prio 0. I
start
seeing
the problem after task2 grabs the mutex and releases them. The
first
task never jumps back to seconodary. Here is my output. The
mode never
goes back to 0 after "Grabbing mux in HP" and the rescnt stays
stuck at
1 in the kernel.[email protected]:~# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Grabbing mux in HP
Mux held by Task2
Release complete
bP: 0, cp: 0, mode: 1
Acquire complete
Release complete
bP: 0, cp: 0, mode: 1
Acquire completeRgds,
Mak.On 10/01/12 10:11 AM, Philippe Gerum wrote:
On 01/09/2012 09:50 PM, Makarand Pradhan wrote:
Hi,I am running kernel 3.0.0, xenomai: 2.6, powerpc 8360.
I am noticing an issue while using the auto relax feature
related to
mutexes. I am using nested mutexes. The code is attached to
this
email.The problem is that I am not relaxing after a RT thread grabs
and
releases a mutex. On further investigation, it was noted that
the
rescnt
is not going down to 0.
From your code, task1 would auto-relax only if started with
priority 0,
which is what I get here:-bash-3.2# ./relax 0 1
Spawning: tasks
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
bP: 0, cp: 0, mode: 0
Acquire complete
Release complete
...Conversely, I get the right behavior if setting a non-zero
priority to
task1:-bash-3.2# ./relax 1 0
Spawning: tasks
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
Release complete
bP: 1, cp: 1, mode: 1
Acquire complete
...In any case, the priority of task2 should have no impact on the
result.I'm running current 2.6 HEAD commit (168da46de), kernel
3.1.5/powerpc32
(52xx), pipeline 2.13-06.Which priority arguments are you passing to your test program?
Another observation is that I do not hit
rt_mutex_release in the kernel in the problem scenario, I
believe
when
the thread undergoes a priority inversion.This may be a
problem
as the
rescnt would not get decremented. Not sure how the mutex is
releasing
wiithout hitting rt_mutex_relase or am I missing anything?These are fast mutexes, the thread does not have to jump to
kernel
space
unless the released mutex was actually contented.If I have both the tasks running at priority 0, I stay in the
secondary
domain, rt_mutex_release is invoked as expected, the rescnt
goes
down to
0 when all the mutexes are released.Has anyone faced this problem?
I'm unsure there is any yet. Auto-relax applies to non -rt
Xenomai
threads only (i.e. prio == 0).Rgds,
Makarand_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
___________________________________________________________________________NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are
not the intended recipient, please notify the sender immediately by return e-mail and delete this
e-mail and any copies. Any dissemination or use of this information by a person other than the
intended recipient is unauthorized and may be illegal.
_____________________________________________________________________Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.--
Philippe.Quoted 11 lines
--
___________________________________________________________________________
NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.
_____________________________________________________________________--
___________________________________________________________________________
NOTICE OF CONFIDENTIALITY:
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.
_____________________________________________________________________
Signature · 7 lines
___________________________________________________________________________ NOTICE OF CONFIDENTIALITY: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this e-mail and any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. _____________________________________________________________________