Re: Debug: sleeping function called from invalid context

Andrew Morton
2003-08-19T00:30:37Z

Dave Jones <davej@redhat.com> wrote:
>
> How spooky. now I got one too, (minus the noise).
>
> Call Trace:
> [<c0120022>] __might_sleep+0x5b/0x5f

It would be useful to know whether this was triggered by in_atomic() or by
irqs_disabled(). We're suspecting the latter.

diff -puN kernel/sched.c~might_sleep-diags kernel/sched.c
--- 25/kernel/sched.c~might_sleep-diags Mon Aug 18 14:09:41 2003
+++ 25-akpm/kernel/sched.c Mon Aug 18 14:11:55 2003
@@ -2795,13 +2795,19 @@ void __might_sleep(char *file, int line)
{
#if defined(in_atomic)
static unsigned long prev_jiffy; /* ratelimiting */
+ char *msg = NULL;

- if (in_atomic() || irqs_disabled()) {
+ if (in_atomic())
+ msg = "in atomic section";
+ else if (irqs_disabled())
+ msg = "with interrupts disabled";
+
+ if (msg) {
if (time_before(jiffies, prev_jiffy + HZ))
return;
prev_jiffy = jiffies;
- printk(KERN_ERR "Debug: sleeping function called from invalid"
- " context at %s:%d\n", file, line);
+ printk(KERN_ERR "Debug: sleeping function "
+ "called %s at %s:%d\n", msg, file, line);
dump_stack();
}
#endif

_