From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964813AbcCNIQD (ORCPT ); Mon, 14 Mar 2016 04:16:03 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36803 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933959AbcCNIPw (ORCPT ); Mon, 14 Mar 2016 04:15:52 -0400 Date: Mon, 14 Mar 2016 17:17:13 +0900 From: Sergey Senozhatsky To: Jan Kara Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , Petr Mladek , Tejun Heo , Tetsuo Handa , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCH v3 1/2] printk: Make printk() completely async Message-ID: <20160314081713.GD542@swordfish> References: <1457876087-26929-1-git-send-email-sergey.senozhatsky@gmail.com> <1457876087-26929-2-git-send-email-sergey.senozhatsky@gmail.com> <20160314071111.GB5213@quack.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160314071111.GB5213@quack.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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