Skip to contentSkip to conversation

Scheduling while atomic

Xenomai-core Jeroen Van den Keybus 4 participants 16 messages Jan 17, 2006 – Jan 29, 2006 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

I'm still wondering if there's a programming error in the mutex test program. After I sent my previous message, and before I turned nucleus debugging on, I managed (by reducing the sleeptimes to max. 5.0e4) to fatally crash the computer, while spewing out countless 'scheduling while atomic messages'. Is the mutex error reproducible ?

Tomorrow I'll try the patch.

lostage_handler + e/33a
rthal_apc_handler + 3b/46
lostage_handler + 190/33a
rthal_apc_handler + 3b/46
__ipipe_sync_stage + 2a1/2bc
mark_offset_tsc + c1/456
__ipipe_sync_stage + 2a9/2bc ipipe_unstall_pipeline_from + 189/194 (might be 181/194) xnpod_delete_thread + ba1/bc3
mcount + 23/2a
taskexit_event + 4f/6c
__ipipe_dispatch_event + 90/173
do_exit + 10f/604
sys_exit + 8/14
syscall_call + 7/b
next_thread + 0/15
syscall_call + 7/b

<0> Kernel panic - not syncing: Fatal Exception in interrupt

Thanks for investigating,

Jeroen.

#1 lore raw
Quoted 10 lines · Jeroen Van den Keybus

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

Could you try adding a call to mlockall(MCL_CURRENT|MCL_FUTURE) ?

Also note that you do not need protecting accesses to file descriptor with rt_mutexes. stdio file descriptor are protected with pthread mutexes, and pthread mutexes functions cause threads migration to secondary mode. And unix file descriptor are passed to system calls, which also cause migration to secondary mode.

Signature · 1 line
					    Gilles Chanteperdrix.
#2 lore raw
In reply to Jeroen Van den Keybus
Quoted 11 lines · Jeroen Van den Keybus

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

Quoted 5 lines

I'm still wondering if there's a programming error in the mutex test program. After I sent my previous message, and before I turned nucleus debugging on, I managed (by reducing the sleeptimes to max. 5.0e4) to fatally crash the computer, while spewing out countless 'scheduling while atomic messages'. Is the mutex error reproducible ?

I was not able to crash my box or generate that scheduler warnings, but the attached patch fixes the false positive warnings of unlocked mutexes. We had a "leak" in the unlock path when someone was already waiting. Anyway, *this* issues should not have caused any other problems then the wrong report of rt_mutex_inquire().

@Gilles: please apply to both trees.

[Update] While writing this mail and letting your test run for a while, I *did* get a hard lock-up. Hold on, digging deeper...

Jan

ChangeLog +5 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,8 @@
+2006-01-18  Jan Kiszka  <[email protected]>
+
+	* ksrc/skins/native/mutex.c (rt_mutex_unlock): Fix leaking lockcnt
+	on unlock with pending waiters.
+
 2006-01-16  Gilles Chanteperdrix  <[email protected]>
 
 	* ksrc/skins/native/task.c (rt_task_create): Use a separate string
skins/native/mutex.c +4 -1
Index: ksrc/skins/native/mutex.c
===================================================================
@@ -461,8 +461,11 @@
     mutex->owner = thread2rtask(xnsynch_wakeup_one_sleeper(&mutex->synch_base));
 
     if (mutex->owner != NULL)
+	{
+	mutex->lockcnt = 1;
 	xnpod_schedule();
-    
+	}
+
  unlock_and_exit:
 
     xnlock_put_irqrestore(&nklock,s);
#3 lore raw
Quoted 4 lines · Jan Kiszka

...
[Update] While writing this mail and letting your test run for a while, I *did* get a hard lock-up. Hold on, digging deeper...

And here are its last words, spoken via serial console:

c31dfab0 00000086 c30d1a90 c02a2500 c482a360 00000001 00000001 00200000

       c012e564 00000022 ffffffff 00000246 c30d1a90 c4866ce0 00000033
c4820000
       c482a360 c4866ca0 ffffffff c48293a4 c48524e1 00000000 00000000
00000002
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c4820000>] e100_hw_init+0x3ad/0xa81 [e100]
 [<c48524e1>] xnpod_suspend_thread+0x714/0x76d [xeno_nucleus]
 [<c4856946>] xnsynch_sleep_on+0x76d/0x7a7 [xeno_nucleus]
 [<c4a09b29>] rt_sem_p+0xa6/0x10a [xeno_native]
 [<c4a03c62>] __rt_sem_p+0x5d/0x66 [xeno_native]
 [<c485b207>] hisyscall_event+0x1cb/0x2d3 [xeno_nucleus]
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c010b3ea>] __ipipe_syscall_root+0x53/0xbe
 [<c01029c0>] system_call+0x20/0x41
Xenomai: fatal: blocked thread main[863] rescheduled?! (status=0x300082,
sig=0, prev=gatekeeper/0[809])
 CPU  PID    PRI  TIMEOUT  STAT      NAME
>  0  0      30   0        00500080  ROOT
   0  864    30   0        00300180  task0
   0  865    29   0        00300288  task1
   0  863    1    0        00300082  main

Timer: oneshot [tickval=1 ns, elapsed=175144731477]

c31e1f14 c4860572 c3188000 c31dfab0 00300082 c02a2500 00000286 c02a2500

       c030cbec c012e564 00000022 c02a2500 c30d1a90 c30d1a90 00000022
00000001
       c02a2500 c30d1a90 c08e4623 00000028 c31e1fa0 c0266ed5 0000f610
c030cd80
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c0266ed5>] schedule+0x3ef/0x5ed
 [<c485a27c>] gatekeeper_thread+0x0/0x179 [xeno_nucleus]
 [<c485a316>] gatekeeper_thread+0x9a/0x179 [xeno_nucleus]
 [<c010dd8b>] default_wake_function+0x0/0x12
 [<c0124fbc>] kthread+0x68/0x95
 [<c0124f54>] kthread+0x0/0x95
 [<c0100d71>] kernel_thread_helper+0x5/0xb

Any bells already ringing?

Will try Gilles' patch now...

Jan

#4 lore raw
Quoted 48 lines · Jan Kiszka
Quoted 4 lines · Jan Kiszka

...
[Update] While writing this mail and letting your test run for a while, I *did* get a hard lock-up. Hold on, digging deeper...

And here are its last words, spoken via serial console:

c31dfab0 00000086 c30d1a90 c02a2500 c482a360 00000001 00000001 00200000

       c012e564 00000022 ffffffff 00000246 c30d1a90 c4866ce0 00000033
c4820000
       c482a360 c4866ca0 ffffffff c48293a4 c48524e1 00000000 00000000
00000002
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c4820000>] e100_hw_init+0x3ad/0xa81 [e100]
 [<c48524e1>] xnpod_suspend_thread+0x714/0x76d [xeno_nucleus]
 [<c4856946>] xnsynch_sleep_on+0x76d/0x7a7 [xeno_nucleus]
 [<c4a09b29>] rt_sem_p+0xa6/0x10a [xeno_native]
 [<c4a03c62>] __rt_sem_p+0x5d/0x66 [xeno_native]
 [<c485b207>] hisyscall_event+0x1cb/0x2d3 [xeno_nucleus]
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c010b3ea>] __ipipe_syscall_root+0x53/0xbe
 [<c01029c0>] system_call+0x20/0x41
Xenomai: fatal: blocked thread main[863] rescheduled?! (status=0x300082,
sig=0, prev=gatekeeper/0[809])
 CPU  PID    PRI  TIMEOUT  STAT      NAME
>  0  0      30   0        00500080  ROOT
   0  864    30   0        00300180  task0
   0  865    29   0        00300288  task1
   0  863    1    0        00300082  main

Timer: oneshot [tickval=1 ns, elapsed=175144731477]

c31e1f14 c4860572 c3188000 c31dfab0 00300082 c02a2500 00000286 c02a2500

       c030cbec c012e564 00000022 c02a2500 c30d1a90 c30d1a90 00000022
00000001
       c02a2500 c30d1a90 c08e4623 00000028 c31e1fa0 c0266ed5 0000f610
c030cd80
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c0266ed5>] schedule+0x3ef/0x5ed
 [<c485a27c>] gatekeeper_thread+0x0/0x179 [xeno_nucleus]
 [<c485a316>] gatekeeper_thread+0x9a/0x179 [xeno_nucleus]
 [<c010dd8b>] default_wake_function+0x0/0x12
 [<c0124fbc>] kthread+0x68/0x95
 [<c0124f54>] kthread+0x0/0x95
 [<c0100d71>] kernel_thread_helper+0x5/0xb
Quoted 4 lines

Any bells already ringing?

Will try Gilles' patch now...

Nope, this didn't help.

Ok, this is migration magic. Someone around who hacks this part blindly?

Jan

#5 lore raw
In reply to Jan Kiszka
Quoted 52 lines · Jan Kiszka
Quoted 4 lines · Jan Kiszka

...
[Update] While writing this mail and letting your test run for a while, I *did* get a hard lock-up. Hold on, digging deeper...

And here are its last words, spoken via serial console:

c31dfab0 00000086 c30d1a90 c02a2500 c482a360 00000001 00000001 00200000

       c012e564 00000022 ffffffff 00000246 c30d1a90 c4866ce0 00000033
c4820000
       c482a360 c4866ca0 ffffffff c48293a4 c48524e1 00000000 00000000
00000002
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c4820000>] e100_hw_init+0x3ad/0xa81 [e100]
 [<c48524e1>] xnpod_suspend_thread+0x714/0x76d [xeno_nucleus]
 [<c4856946>] xnsynch_sleep_on+0x76d/0x7a7 [xeno_nucleus]
 [<c4a09b29>] rt_sem_p+0xa6/0x10a [xeno_native]
 [<c4a03c62>] __rt_sem_p+0x5d/0x66 [xeno_native]
 [<c485b207>] hisyscall_event+0x1cb/0x2d3 [xeno_nucleus]
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c010b3ea>] __ipipe_syscall_root+0x53/0xbe
 [<c01029c0>] system_call+0x20/0x41

Xenomai: fatal: blocked thread main[863] rescheduled?! (status=0x300082, sig=0, prev=gatekeeper/0[809])
CPU PID PRI TIMEOUT STAT NAME

Quoted 1 line

0 0 30 0 00500080 ROOT

   0  864    30   0        00300180  task0
   0  865    29   0        00300288  task1
   0  863    1    0        00300082  main

Timer: oneshot [tickval=1 ns, elapsed=175144731477]

c31e1f14 c4860572 c3188000 c31dfab0 00300082 c02a2500 00000286 c02a2500

       c030cbec c012e564 00000022 c02a2500 c30d1a90 c30d1a90 00000022
00000001
       c02a2500 c30d1a90 c08e4623 00000028 c31e1fa0 c0266ed5 0000f610
c030cd80
Call Trace:
 [<c012e564>] __ipipe_dispatch_event+0x56/0xdd
 [<c0266ed5>] schedule+0x3ef/0x5ed
 [<c485a27c>] gatekeeper_thread+0x0/0x179 [xeno_nucleus]
 [<c485a316>] gatekeeper_thread+0x9a/0x179 [xeno_nucleus]
 [<c010dd8b>] default_wake_function+0x0/0x12
 [<c0124fbc>] kthread+0x68/0x95
 [<c0124f54>] kthread+0x0/0x95
 [<c0100d71>] kernel_thread_helper+0x5/0xb
Quoted 1 line

Any bells already ringing?

Yes; the bad news is that this looks like the same bug than you reported recently, which I only partially fixed, it seems. xnshadow_harden() is still not working properly under certain preemption situation induced by CONFIG_PREEMPT, and the hardening thread is likely unexpectedly moved back to the Linux runqueue while transitioning to Xenomai. The good news is that it's a well identified issue, at least...

Quoted 13 lines

Will try Gilles' patch now...

Jan

------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.
#7 lore raw
In reply to Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 11 lines · Jeroen Van den Keybus

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

Quoted 5 lines

I'm still wondering if there's a programming error in the mutex test program. After I sent my previous message, and before I turned nucleus debugging on, I managed (by reducing the sleeptimes to max. 5.0e4) to fatally crash the computer, while spewing out countless 'scheduling while atomic messages'. Is the mutex error reproducible ?

Quoted 5 lines

I was not able to crash my box or generate that scheduler warnings, but the attached patch fixes the false positive warnings of unlocked mutexes. We had a "leak" in the unlock path when someone was already waiting. Anyway, *this* issues should not have caused any other problems then the wrong report of rt_mutex_inquire().

Actually the patch seem insufficient, the whole block :

	{
	xnsynch_set_owner(&mutex->synch_base,&task->thread_base);
	mutex->owner = task;
	mutex->lockcnt = 1;
	goto unlock_and_exit;
	}

should be done after xnsynch_sleep_on in rt_mutex_lock.

Signature · 1 line
					    Gilles Chanteperdrix.
#8 lore raw
Quoted 26 lines · Gilles Chanteperdrix
Quoted 18 lines · Jan Kiszka
Quoted 11 lines · Jeroen Van den Keybus

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

Quoted 5 lines

I'm still wondering if there's a programming error in the mutex test program. After I sent my previous message, and before I turned nucleus debugging on, I managed (by reducing the sleeptimes to max. 5.0e4) to fatally crash the computer, while spewing out countless 'scheduling while atomic messages'. Is the mutex error reproducible ?

Quoted 5 lines

I was not able to crash my box or generate that scheduler warnings, but the attached patch fixes the false positive warnings of unlocked mutexes. We had a "leak" in the unlock path when someone was already waiting. Anyway, *this* issues should not have caused any other problems then the wrong report of rt_mutex_inquire().

Actually the patch seem insufficient, the whole block :

Quoted 9 lines
	{
	xnsynch_set_owner(&mutex->synch_base,&task->thread_base);
	mutex->owner = task;
	mutex->lockcnt = 1;
	goto unlock_and_exit;
	}

should be done after xnsynch_sleep_on in rt_mutex_lock.

Damn, of course - except for "mutex->owner = task". Then this missing xnsync_set_owner() may have caused serious issues? Will test...

Jan

#9 lore raw
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Gilles Chanteperdrix
Quoted 18 lines · Jan Kiszka
Quoted 11 lines · Jeroen Van den Keybus

Gilles,

I cannot reproduce those messages after turning nucleus debugging on. Instead, I now either get relatively more failing mutexes or even hard lockups with the test program I sent to you. If the computer didn't crash, dmesg contains 3 Xenomai messages relating to a task being movend to secondary domain after exception #14. As when the computer crashes: I have written the last kernel panic message on a paper. Please tell if you want also the addresses or (part of) the call stack.

Quoted 5 lines

I'm still wondering if there's a programming error in the mutex test program. After I sent my previous message, and before I turned nucleus debugging on, I managed (by reducing the sleeptimes to max. 5.0e4) to fatally crash the computer, while spewing out countless 'scheduling while atomic messages'. Is the mutex error reproducible ?

Quoted 5 lines

I was not able to crash my box or generate that scheduler warnings, but the attached patch fixes the false positive warnings of unlocked mutexes. We had a "leak" in the unlock path when someone was already waiting. Anyway, *this* issues should not have caused any other problems then the wrong report of rt_mutex_inquire().

Actually the patch seem insufficient, the whole block :

	{
	xnsynch_set_owner(&mutex->synch_base,&task->thread_base);
	mutex->owner = task;
	mutex->lockcnt = 1;
	goto unlock_and_exit;
	}
Quoted 5 lines
Quoted 2 lines

should be done after xnsynch_sleep_on in rt_mutex_lock.

Damn, of course - except for "mutex->owner = task". Then this missing xnsync_set_owner() may have caused serious issues? Will test...

Correction: xnsynch_wakeup_one_sleeper() updates synch->owner, so all fine with my patch in this regard. I guess it is really some migration issue again.

Jan

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Interesting, when writing to 2 different files, I get the same crashes.
Will test with only one task/fd.

Quoted 17 lines

In fact, my last crash report did contain a difference with yours:

Quoted 7 lines

ROOT task was at priority 0
main was at 1
task0 was at 30 timeout 3.7ms
task1 was at 29 timeout 4.9 ms

Does this mean that both tasks were actually not even inside the

critical

Quoted 2 lines

section ?

Yep, and this clearly indicates that there is no issue with mutexes, semaphores, or whatever. Please try to capture the full trace and post it to the list. As I said, this kind of topic here is not my home domain...

#15 lore raw
Quoted 2 lines · Jeroen Van den Keybus

Interesting, when writing to 2 different files, I get the same crashes.
Will test with only one task/fd.

File ops doesn't matter for me. I took them out of task0/1, and I still got the crashes. (BTW, this may explain the difference in your backtrace you reported privately.)

Jan - now really leaving...

#19 lore raw

Turned off:

  o  nucleus debugging
  o  ipipe stats
  o  ipipe tracing
  o  ishield

The problem persists. Also tried three tasks, with same result. With one task, there is no problem.

Jeroen.