Re: [PATCH v6 1/2] printk: Factor out buffering and irq work queuing in printk_deferred

From: Byungchul Park
Date: Mon Mar 14 2016 - 00:45:52 EST


On Mon, Mar 14, 2016 at 10:21:57AM +0900, Sergey Senozhatsky wrote:
> Hello Byungchul,
>
> Sorry, I'll make sure I Cc you next time. Jan Kara's updated patch set
>
> http://marc.info/?l=linux-kernel&m=145787625506342

Hello Sergey,

It would be appreciated if you or Jan Cc me from now.

>
> it's quite close to what you have done in this patch, but Jan's
> patch also solves a number of more likely to happen cases.
>
> have time to take a look?

I checked it now. I hope it will be accepted, then I can work mine based on
the Jan's patch.

>
> the lock debug patch in your series is different. can we settle
> down async printk first and then return to it? it's not so simple...
>
>
> On (03/11/16 19:37), Byungchul Park wrote:
> [..]
> > int printk_deferred(const char *fmt, ...)
> > {
> > va_list args;
> > int r;
> >
> > preempt_disable();
> > +
> > va_start(args, fmt);
> > - r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, 0, fmt, args);
> > + r = vprintk_deferred(fmt, args);
> > va_end(args);
> > + printk_pending_output();
> >
> > - __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
> > - irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
> > preempt_enable();
> >
> > return r;
>
> vprintk_deferred() does vprintk_emit()->{spin_lock()} again? cosole_lock() is
> moved out of sight, but logbug_lock is still there. wouldn't this (in the worst

We have to ensure the critical section by logbug_lock will not call
printk() or try to obtain the lock again. Current code works well in those
regards. logbuf_lock is not the thing we have to care when considering
the problem this patch deal with.

What do you think?

> case) result in endless loop after all? sorry if I'm missing something.

As long as we ensure it, the endless loop by logbuf_lock cannot happen.

>
> -ss