From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755282AbdC2J3U (ORCPT ); Wed, 29 Mar 2017 05:29:20 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33088 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754972AbdC2J3S (ORCPT ); Wed, 29 Mar 2017 05:29:18 -0400 From: Sergey Senozhatsky To: Steven Rostedt , Petr Mladek Cc: Jan Kara , Andrew Morton , Linus Torvalds , Peter Zijlstra , "Rafael J . Wysocki" , Eric Biederman , Greg Kroah-Hartman , Jiri Slaby , Pavel Machek , Len Brown , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: [RFC][PATCHv2 3/8] printk: offload printing from wake_up_klogd_work_func() Date: Wed, 29 Mar 2017 18:25:06 +0900 Message-Id: <20170329092511.3958-4-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170329092511.3958-1-sergey.senozhatsky@gmail.com> References: <20170329092511.3958-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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ab6b3b2a68c6..1927b5cb5cbe 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2741,8 +2741,16 @@ static void wake_up_klogd_work_func(struct irq_work *irq_work) * If trylock fails, someone else is doing the printing. * PRINTK_PENDING_OUTPUT bit is cleared by console_unlock(). */ - 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 (test_and_clear_bit(PRINTK_PENDING_WAKEUP, &printk_pending)) -- 2.12.2