Re: [RFC][PATCH v3 1/2] printk: Make printk() completely async

From: Sergey Senozhatsky
Date: Mon Mar 14 2016 - 04:16:07 EST


On (03/14/16 08:11), Jan Kara wrote:
[..]
> > + if (!sync_print) {
> > + if (printk_thread && !in_panic) {
> > + /*
> > + * Wakeup the printing kthread and offload printing
> > + * to a schedulable context.
> > + */
> > + wake_up(&printing_wait);
> > + } else if (in_sched) {
> > + /*
> > + * @in_sched messages may come too early, when we don't
> > + * yet have @printk_thread. We can't print deferred
> > + * messages directly, because this may deadlock, route
> > + * them via IRQ context.
> > + */
> > + __this_cpu_or(printk_pending,
> > + PRINTK_PENDING_OUTPUT);
> > + irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
>
> You cannot call wake_up() from a scheduler context - i.e., if in_sched is
> true, you have to use irq work unconditionally. You can wake up kthread
> from irq work or just directly print the message there. Otherwise the patch
> looks fine.

oh, thanks for catching this! you are right.

-ss