Re: [RT] sysrq Z: sleeping function called from invalid context

From: Frank Rowand
Date: Fri Dec 02 2011 - 19:33:42 EST


On 12/02/11 15:49, Steven Rostedt wrote:
> On Fri, 2011-12-02 at 15:08 -0800, Frank Rowand wrote:
>> Hi Steve,
>>
>> I get a "sleeping function called from invalid context" when I invoke sysrq Z.
>>
>> I get this both with CONFIG_MAGIC_SYSRQ_FORCE_PRINTK enabled and disabled.
>
> Patient: Hey doctor, it hurts when I do this
>
> Doctor: Don't do that.

I had similar thoughts as I was writing my email.

< snip >

>
> Oh! looking into the ring_buffer code, could you add this:
> (totally untested)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 2467714..2ffbb9d 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -1045,7 +1045,7 @@ static inline int ok_to_lock(void)
> if (in_nmi())
> return 0;
> #ifdef CONFIG_PREEMPT_RT_FULL
> - if (in_atomic())
> + if (in_atomic() || irqs_disabled())
> return 0;
> #endif
> return 1;

I would say the result is good with the patch applied.

If CONFIG_MAGIC_SYSRQ_FORCE_PRINTK is disabled then the splat does not occur
and the ftrace buffer is printed on the console.

If CONFIG_MAGIC_SYSRQ_FORCE_PRINTK is enabled, then the splat does not occur
and the ftrace buffer sometimes is printed on the console. I think that
this is good enough, given that sysrq when CONFIG_PREEMPT_RT_FULL is enabled
is somewhat dicey to begin with.

-Frank

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/