[lkml]   [2007]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PREEMPT_RT] [PATCH] scheduling with irqs disabled: strace/0x00000000/2011

While running strace on some testcase running on -rt kernel (2.6.20-rt8 and
2.6.21-rc6-rt0), I have seen the following BUG:

BUG: scheduling with irqs disabled: strace/0x00000000/2011
caller is rt_spin_lock_slowlock+0x102/0x1af

Call Trace:
[<ffffffff8026d828>] dump_trace+0xbd/0x3d8
[<ffffffff8026db87>] show_trace+0x44/0x6d
[<ffffffff8026ddc8>] dump_stack+0x13/0x15
[<ffffffff80264dc6>] schedule+0x87/0x10b
[<ffffffff80265b06>] rt_spin_lock_slowlock+0x102/0x1af
[<ffffffff802661af>] rt_spin_lock+0x1f/0x21
[<ffffffff8029af0c>] force_sig_info+0x26/0xb5
[<ffffffff8029b018>] force_sig_specific+0x11/0x13
[<ffffffff80298659>] ptrace_attach+0xdf/0x10b
[<ffffffff802986d7>] sys_ptrace+0x52/0xb8
[<ffffffff8025f42c>] tracesys+0x151/0x1be

| preempt count: 00000000 ]
| 0-level deep critical section nesting:

In ptrace_attach, this is what happens:

write_lock(tasklist_lock) Using trylocks.
Some work
Send SIGSTOP to target thread

On -rt, write_unlock_irq doesn't do local_irq_enable. Even if it did, we are
calling it after sending SIGSTOP to target thread. To fix the problem, I
think we should call write_unlock(tasklist_lock) and local_irq_enable()
instead of write_unlock_irq. Also, we should call them before calling
force_sig_specific(). I think there is no need to hold the tasklist lock
while calling force_sig_specific(). Is my understanding correct?
Alternatively, can we remove the call to local_irq_disable() in -rt kernel?

For the non-rt kernel too, I think we should do
write_unlock_irq(tasklist_lock) before sending SIGSTOP.

The following patch solves the problem for me.

Thanks and regards,

Signed-off-by: Sripathi Kodi <>

--- linux-2.6.21-rc6-rt0-org/kernel/ptrace.c 2007-04-06 08:06:56.000000000
+++ linux-2.6.21-rc6-rt0/kernel/ptrace.c 2007-04-19 18:18:40.000000000 +0530
@@ -205,10 +205,16 @@ repeat:

__ptrace_link(task, current);

+ write_unlock(&tasklist_lock);
+ local_irq_enable();
force_sig_specific(SIGSTOP, task);
+ goto out2;

- write_unlock_irq(&tasklist_lock);
+ write_unlock(&tasklist_lock);
+ local_irq_enable();
return retval;
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2007-04-20 08:19    [W:0.028 / U:8.888 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site