* [PATCH -rt] printk: Disable migration instead of preemption
@ 2011-12-12 13:35 Richard Weinberger
2011-12-12 15:25 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2011-12-12 13:35 UTC (permalink / raw)
To: linux-kernel; +Cc: tglx, Richard Weinberger
There is no need do disable preemption in vprintk(),
disable_migrate() is sufficient.
This fixes also a the following bug in -rt:
[ 14.759233] BUG: sleeping function called from invalid context
at /home/rw/linux-rt/kernel/rtmutex.c:645
[ 14.759235] in_atomic(): 1, irqs_disabled(): 0, pid: 547, name: bash
[ 14.759244] Pid: 547, comm: bash Not tainted 3.0.12-rt29+ #3
[ 14.759246] Call Trace:
[ 14.759301] [<ffffffff8106fade>] __might_sleep+0xeb/0xf0
[ 14.759318] [<ffffffff810ad784>] rt_spin_lock_fastlock.constprop.9+0x21/0x43
[ 14.759336] [<ffffffff8161fef0>] rt_spin_lock+0xe/0x10
[ 14.759354] [<ffffffff81347ad1>] serial8250_console_write+0x81/0x121
[ 14.759366] [<ffffffff8107ecd3>] __call_console_drivers+0x7c/0x93
[ 14.759369] [<ffffffff8107ef31>] _call_console_drivers+0x5c/0x60
[ 14.759372] [<ffffffff8107f7e5>] console_unlock+0x147/0x1a2
[ 14.759374] [<ffffffff8107fd33>] vprintk+0x3ea/0x462
[ 14.759383] [<ffffffff816160e0>] printk+0x51/0x53
[ 14.759399] [<ffffffff811974e4>] ? proc_reg_poll+0x9a/0x9a
[ 14.759403] [<ffffffff81335b42>] __handle_sysrq+0x50/0x14d
[ 14.759406] [<ffffffff81335c8a>] write_sysrq_trigger+0x4b/0x53
[ 14.759408] [<ffffffff81335c3f>] ? __handle_sysrq+0x14d/0x14d
[ 14.759410] [<ffffffff81197583>] proc_reg_write+0x9f/0xbe
[ 14.759426] [<ffffffff811497ec>] vfs_write+0xac/0xf3
[ 14.759429] [<ffffffff8114a9b3>] ? fget_light+0x3a/0x9b
[ 14.759431] [<ffffffff811499db>] sys_write+0x4a/0x6e
[ 14.759438] [<ffffffff81625d52>] system_call_fastpath+0x16/0x1b
Signed-off-by: Richard Weinberger <rw@linutronix.de>
---
kernel/printk.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/printk.c b/kernel/printk.c
index a50af4e..13d0825 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -898,7 +898,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
boot_delay_msec();
printk_delay();
- preempt_disable();
+ migrate_disable();
/* This stops the holder of console_sem just where we want him */
raw_local_irq_save(flags);
this_cpu = smp_processor_id();
@@ -1029,7 +1029,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
out_restore_irqs:
raw_local_irq_restore(flags);
- preempt_enable();
+ migrate_enable();
return printed_len;
}
EXPORT_SYMBOL(printk);
--
1.7.7
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -rt] printk: Disable migration instead of preemption
2011-12-12 13:35 [PATCH -rt] printk: Disable migration instead of preemption Richard Weinberger
@ 2011-12-12 15:25 ` Peter Zijlstra
2011-12-12 16:35 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2011-12-12 15:25 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-kernel, tglx
On Mon, 2011-12-12 at 14:35 +0100, Richard Weinberger wrote:
> There is no need do disable preemption in vprintk(),
> disable_migrate() is sufficient.
> This fixes also a the following bug in -rt:
>
> [ 14.759233] BUG: sleeping function called from invalid context
> at /home/rw/linux-rt/kernel/rtmutex.c:645
> ---
> kernel/printk.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/printk.c b/kernel/printk.c
> index a50af4e..13d0825 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -898,7 +898,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> boot_delay_msec();
> printk_delay();
>
> - preempt_disable();
> + migrate_disable();
> /* This stops the holder of console_sem just where we want him */
> raw_local_irq_save(flags);
> this_cpu = smp_processor_id();
> @@ -1029,7 +1029,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> out_restore_irqs:
> raw_local_irq_restore(flags);
>
> - preempt_enable();
> + migrate_enable();
> return printed_len;
> }
> EXPORT_SYMBOL(printk);
One has to wonder why this patch makes any difference what so ever, note
how right after/before the preempt_disable/enable there's a
raw_local_irq_save/restore and last time I checked those really did
disable IRQs, even on -rt.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -rt] printk: Disable migration instead of preemption
2011-12-12 15:25 ` Peter Zijlstra
@ 2011-12-12 16:35 ` Thomas Gleixner
2011-12-12 16:47 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2011-12-12 16:35 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Richard Weinberger, linux-kernel
On Mon, 12 Dec 2011, Peter Zijlstra wrote:
> On Mon, 2011-12-12 at 14:35 +0100, Richard Weinberger wrote:
> > There is no need do disable preemption in vprintk(),
> > disable_migrate() is sufficient.
> > This fixes also a the following bug in -rt:
> >
> > [ 14.759233] BUG: sleeping function called from invalid context
> > at /home/rw/linux-rt/kernel/rtmutex.c:645
>
> > ---
> > kernel/printk.c | 4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/printk.c b/kernel/printk.c
> > index a50af4e..13d0825 100644
> > --- a/kernel/printk.c
> > +++ b/kernel/printk.c
> > @@ -898,7 +898,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> > boot_delay_msec();
> > printk_delay();
> >
> > - preempt_disable();
> > + migrate_disable();
> > /* This stops the holder of console_sem just where we want him */
> > raw_local_irq_save(flags);
> > this_cpu = smp_processor_id();
> > @@ -1029,7 +1029,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> > out_restore_irqs:
> > raw_local_irq_restore(flags);
> >
> > - preempt_enable();
> > + migrate_enable();
> > return printed_len;
> > }
> > EXPORT_SYMBOL(printk);
>
> One has to wonder why this patch makes any difference what so ever, note
> how right after/before the preempt_disable/enable there's a
> raw_local_irq_save/restore and last time I checked those really did
> disable IRQs, even on -rt.
The point is that we drop that lock further down and on RT we also
reenable interrupts, so we have to prevent that we get migrated away.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -rt] printk: Disable migration instead of preemption
2011-12-12 16:35 ` Thomas Gleixner
@ 2011-12-12 16:47 ` Peter Zijlstra
0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2011-12-12 16:47 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: Richard Weinberger, linux-kernel
On Mon, 2011-12-12 at 17:35 +0100, Thomas Gleixner wrote:
>
> The point is that we drop that lock further down and on RT we also
> reenable interrupts, so we have to prevent that we get migrated away.
>
Oh ok. I missed -rt reenabling interrupts somewhere down there.
Do note that these preempt_disable/enable calls are gone upstream.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-12 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12 13:35 [PATCH -rt] printk: Disable migration instead of preemption Richard Weinberger
2011-12-12 15:25 ` Peter Zijlstra
2011-12-12 16:35 ` Thomas Gleixner
2011-12-12 16:47 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®