Re: [RFC][PATCH -next 1/2] printk: move can_use_console out of console_trylock_for_printk

From: Petr Mladek
Date: Wed Jan 20 2016 - 05:09:18 EST


On Wed 2016-01-20 13:18:04, Sergey Senozhatsky wrote:
> On (01/19/16 17:16), Petr Mladek wrote:
> > do_cond_resched = console_may_schedule;
> > console_may_schedule = 0;
> >
> > +again:
> > + if (!can_use_console()) {
> > + console_locked = 0;
> > + up_console_sem();
> > + return;
> > }
> >
> > /* flush buffered message fragment immediately to console */
> > console_cont_flush(text, sizeof(text));
> > -again:
> > for (;;) {
> > struct printk_log *msg;
> >
>
> looks better. we do extra IRQ disable/enable (spin lock irq) when we jump
> to `again' label, but I don't think this introduces any significant overhead.
> however, if it does, we always can avoid extra console_cont_flush() by simply
> checking @retry -- it's `false' only once, when we execute this part for
> the first time in the current console_unlock() call; all goto-jumps imply
> that @retry is `true'.

IMHO, the extra spin_lock/unlock does not harm much. We do this
for each line in the for(;;) cycle anyway. But the check for retry
value is clever. We could use this if others would want to preserve
the existing behavior and call console_cont_flush() only once.

Best Regards,
Petr