From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753278AbdCFMyr (ORCPT ); Mon, 6 Mar 2017 07:54:47 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33646 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752590AbdCFMyl (ORCPT ); Mon, 6 Mar 2017 07:54:41 -0500 From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky To: Steven Rostedt , Petr Mladek Cc: Andrew Morton , Linus Torvalds , Peter Zijlstra , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: [RFC][PATCH 2/4] printk: offload printing from wake_up_klogd_work_func() Date: Mon, 6 Mar 2017 21:45:52 +0900 Message-Id: <20170306124554.828-3-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170306124554.828-1-sergey.senozhatsky@gmail.com> References: <20170306124554.828-1-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Offload printing of printk_deferred() messages from IRQ context to a schedulable printing kthread, when possible (the same way we do it in vprintk_emit()). Otherwise, console_unlock() can force the printing CPU to spend unbound amount of time flushing kernel messages from IRQ context. Signed-off-by: Sergey Senozhatsky --- 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 1c4232ca2e6a..6e00073a7331 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2735,9 +2735,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_enabled()) { + 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.12.0