Re: [PATCH -rt] printk: Disable migration instead of preemption

From: Thomas Gleixner
Date: Mon Dec 12 2011 - 11:35:54 EST


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
--
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/