Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756544AbcDGQeW (ORCPT ); Thu, 7 Apr 2016 12:34:22 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34584 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756885AbcDGQeU (ORCPT ); Thu, 7 Apr 2016 12:34:20 -0400 From: Sergey Senozhatsky To: Andrew Morton Cc: Jan Kara , Petr Mladek , Tejun Heo , Tetsuo Handa , linux-kernel@vger.kernel.org, Byungchul Park , Sergey Senozhatsky , Sergey Senozhatsky , Jan Kara Subject: [PATCH v11 2/3] printk: Make wake_up_klogd_work_func() async Date: Fri, 8 Apr 2016 02:31:46 +0900 Message-Id: <1460050307-3718-3-git-send-email-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1460050307-3718-1-git-send-email-sergey.senozhatsky@gmail.com> References: <1460050307-3718-1-git-send-email-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1240 Lines: 40 From: Jan Kara Offload printing of scheduler deferred messages from IRQ context to a schedulable printing kthread, when possible (the same way we do it in vprintk_emit()). Otherwise, the CPU can spend unbounded amount of time doing printing in console_unlock() from IRQ. Signed-off-by: Jan Kara Signed-off-by: Sergey Senozhatsky Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 64a98ea..89f5441 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2820,9 +2820,16 @@ static void wake_up_klogd_work_func(struct irq_work *irq_work) int pending = __this_cpu_xchg(printk_pending, 0); if (pending & PRINTK_PENDING_OUTPUT) { - /* If trylock fails, someone else is doing the printing */ - if (console_trylock()) - console_unlock(); + if (printk_kthread) { + wake_up_process(printk_kthread); + } else { + /* + * If trylock fails, someone else is doing + * the printing + */ + if (console_trylock()) + console_unlock(); + } } if (pending & PRINTK_PENDING_WAKEUP) -- 2.8.0