From patchwork Fri Jul 3 16:22:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 491123 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A1A2914077B for ; Sat, 4 Jul 2015 02:23:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=xhD10iC/; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755849AbbGCQXG (ORCPT ); Fri, 3 Jul 2015 12:23:06 -0400 Received: from mail-yk0-f177.google.com ([209.85.160.177]:35065 "EHLO mail-yk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755760AbbGCQWz (ORCPT ); Fri, 3 Jul 2015 12:22:55 -0400 Received: by ykdy1 with SMTP id y1so99564202ykd.2; Fri, 03 Jul 2015 09:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=6NgurffQisKHdngwcPE2pmGVr2TXdrKvJ/djCgHSCHI=; b=xhD10iC/2eVlWiV8RGfHUDl3+wTAS3XIOiYTiVaTHlHtSTFCc6Rzaw1CIS/iUZE+TC B7k+PIiMbCv5p8O8vz2EL2bJCd2pTwmKPhtoe2S5c+6SdwcJPvCzL8sg1nVVIJHz6EGc jT3DtvddaSnJyIUSC8zrnMfuQyYNUpDbeZFtVfUDLjtS3FZg2jMbmTVHm3QxozFyaKj4 TA6EvoFtFGQL9snkDe54txu8LCdILh/OqktD+ZaPWWybEPpx9Nbxh89RcAnxuZzJKxTN qof/1epvyJpCjVmJSM2dxMaMVw50XIu2XULtj9rlAbXIGfv1kXOsj0XdLpyeV0SaWGWB ujcQ== X-Received: by 10.129.146.71 with SMTP id j68mr45133133ywg.68.1435940574271; Fri, 03 Jul 2015 09:22:54 -0700 (PDT) Received: from mtj.duckdns.org ([2620:10d:c0a3:10fb:3602:86ff:fe00:dead]) by mx.google.com with ESMTPSA id f2sm9494920ywf.5.2015.07.03.09.22.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2015 09:22:53 -0700 (PDT) Date: Fri, 3 Jul 2015 12:22:51 -0400 From: Tejun Heo To: Linus Torvalds , Andrew Morton Cc: pmladek@suse.cz, "David S. Miller" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , Kay Sievers , Josh Triplett , Linux Embedded , Geert Uytterhoeven Subject: [PATCH v3 v4.2-rc1] printk: make extended printk support conditional on netconsole Message-ID: <20150703162251.GB5273@mtj.duckdns.org> References: <1430318704-32374-1-git-send-email-tj@kernel.org> <1430318704-32374-4-git-send-email-tj@kernel.org> <20150629152805.GM15805@mtj.duckdns.org> <20150629154914.GQ15805@mtj.duckdns.org> <20150629161355.GS15805@mtj.duckdns.org> <20150629233140.GA7711@mtj.duckdns.org> <20150702162141.GC30677@mtj.duckdns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150702162141.GC30677@mtj.duckdns.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 6fe29354befe ("printk: implement support for extended console drivers") implemented extended printk support for extended netconsole. The code added was miniscule but it added static 8k buffer unconditionally unnecessarily bloating the kernel for cases where extended netconsole is not used. This patch introduces CONFIG_PRINTK_CON_EXTENDED which is selected by CONFIG_NETCONSOLE. If the config option is not set, extended printk support is compiled out along with the static buffer. Verified 8k reduction in vmlinux bss when !CONFIG_NETCONSOLE. v2: Added a warning for cases where CON_EXTENDED is requested while CONFIG_PRINTK_CON_EXTENDED is disabled as suggested by Petr. v3: Moved ext console enable info messages into the inc function. Signed-off-by: Tejun Heo Reported-and-suggested-by: Geert Uytterhoeven Reviewed-by: Petr Mladek --- drivers/net/Kconfig | 1 + init/Kconfig | 3 +++ kernel/printk/printk.c | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 019fcef..39587f1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -195,6 +195,7 @@ config GENEVE config NETCONSOLE tristate "Network console logging support" + select PRINTK_CON_EXTENDED ---help--- If you want to log kernel messages over the network, enable this. See for details. diff --git a/init/Kconfig b/init/Kconfig index bcc41bd..cd281ab 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1438,6 +1438,9 @@ config PRINTK very difficult to diagnose system problems, saying N here is strongly discouraged. +config PRINTK_CON_EXTENDED + bool + config BUG bool "BUG() support" if EXPERT default y diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index cf8c242..841ea4d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -84,6 +84,10 @@ static struct lockdep_map console_lock_dep_map = { }; #endif +#ifdef CONFIG_PRINTK_CON_EXTENDED + +#define CONSOLE_EXT_LOG_BUF_LEN CONSOLE_EXT_LOG_MAX + /* * Number of registered extended console drivers. * @@ -96,6 +100,33 @@ static struct lockdep_map console_lock_dep_map = { */ static int nr_ext_console_drivers; +static void inc_nr_ext_console_drivers(void) +{ + if (!nr_ext_console_drivers++) + pr_info("printk: continuation disabled due to ext consoles, expect more fragments in /dev/kmsg\n"); +} + +static void dec_nr_ext_console_drivers(void) +{ + nr_ext_console_drivers--; +} + +#else /* CONFIG_PRINTK_CON_EXTENDED */ + +#define CONSOLE_EXT_LOG_BUF_LEN 0 +#define nr_ext_console_drivers 0 + +static void inc_nr_ext_console_drivers(void) +{ + WARN_ONCE(true, "printk: CON_EXTENDED requested when !CONFIG_PRINTK_CON_EXTENDED\n"); +} + +static void dec_nr_ext_console_drivers(void) +{ +} + +#endif /* CONFIG_PRINTK_CON_EXTENDED */ + /* * Helper macros to handle lockdep when locking/unlocking console_sem. We use * macros instead of functions so that _RET_IP_ contains useful information. @@ -2224,7 +2255,7 @@ static void console_cont_flush(char *text, size_t size) */ void console_unlock(void) { - static char ext_text[CONSOLE_EXT_LOG_MAX]; + static char ext_text[CONSOLE_EXT_LOG_BUF_LEN]; static char text[LOG_LINE_MAX + PREFIX_MAX]; static u64 seen_seq; unsigned long flags; @@ -2562,8 +2593,7 @@ void register_console(struct console *newcon) } if (newcon->flags & CON_EXTENDED) - if (!nr_ext_console_drivers++) - pr_info("printk: continuation disabled due to ext consoles, expect more fragments in /dev/kmsg\n"); + inc_nr_ext_console_drivers(); if (newcon->flags & CON_PRINTBUFFER) { /* @@ -2638,7 +2668,7 @@ int unregister_console(struct console *console) } if (!res && (console->flags & CON_EXTENDED)) - nr_ext_console_drivers--; + dec_nr_ext_console_drivers(); /* * If this isn't the last console and it has CON_CONSDEV set, we