From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Thu, 8 Feb 2001 06:47:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Thu, 8 Feb 2001 06:47:22 -0500 Received: from mailout03.sul.t-online.com ([194.25.134.81]:34310 "EHLO mailout03.sul.t-online.com") by vger.kernel.org with ESMTP id ; Thu, 8 Feb 2001 06:47:07 -0500 From: Stefani Seibold Date: Thu, 8 Feb 2001 12:44:20 +0100 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="US-ASCII" To: torvalds@transmeta.com, alan@lxorguk.ukuu.org.uk, D.A.Fedorov@inp.nsk.su In-Reply-To: In-Reply-To: Subject: Re: patch for 2.4.1 disable printk and panic messages Cc: linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-Id: <01020812442100.01574@deepthought.seibold.net> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org > I think it is better to remove statements about rescue discs from patch > because rescue discs are often interactive systems and needs messages even > more than desktops. > And statement about saving disk space by removing messages can irritate > some kernel people. I write it now a little bit lightweight - or maybe for recuse disks - okay? >> To Linus: What must i do, to get this patch in the offical kernel? > You should forward patch to Linus directly - I'm see that it is normal > practice in list. Hi Linus, do you think it is possible to get this patch in the offical kernel? I had it tested now very well, and it should have no side effects with the new macro expantion. All arguments of the printk and panic macro will be evaulated. > Your mail client program wraps around long lines and patch fails > without editing it in two places. Sorry, here is the correct version of the patch, without line wraps: -----patch for 2.4.1disable printk and panic ----- diff -u --recursive --new-file linux/CREDITS linux.noprintk/CREDITS --- linux/CREDITS Sun Dec 31 18:27:57 2000 +++ linux.noprintk/CREDITS Fri Jan 26 10:51:19 2001 @@ -2396,6 +2396,14 @@ S: Oldenburg S: Germany +N: Stefani Seibold +E: Stefani@Seibold.net +D: Option to disable all kernel messages by overload printk with a +D: dummy macro (saves a lot of disk- and ramspace for deeply embedded +D: systems and maybe for rescue disks). +S: Munich +S: Germany + N: Darren Senn E: sinster@darkwater.com D: Whatever I notice needs doing (so far: itimers, /proc) diff -u --recursive --new-file linux/Documentation/Configure.help linux.noprintk/Documentation/Configure.help --- linux/Documentation/Configure.help Thu Jan 4 22:00:55 2001 +++ linux.noprintk/Documentation/Configure.help Sun Jan 28 10:57:29 2001 @@ -12224,6 +12224,14 @@ If unsure, say Y, or else you won't be able to do much with your new shiny Linux system :-) +Disable kernel messages +CONFIG_NOPRINTK + This option allows you to disable all kernel messages by overriding + the printk function a dummy macro. + On small embedded systems, this save a lot of rom and ram space. On + server or desktop systems you want human readable outputs, so it is + normally the best choice to say N to this option. + Support for console on virtual terminal CONFIG_VT_CONSOLE The system console is the device which receives all kernel messages diff -u --recursive --new-file linux/arch/alpha/config.in linux.noprintk/arch/alpha/config.in --- linux/arch/alpha/config.in Fri Dec 29 23:07:19 2000 +++ linux.noprintk/arch/alpha/config.in Sun Jan 28 10:56:21 2001 @@ -359,6 +359,7 @@ fi bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK bool 'Legacy kernel start address' CONFIG_ALPHA_LEGACY_START_ADDRESS diff -u --recursive --new-file linux/arch/arm/config.in linux.noprintk/arch/arm/config.in --- linux/arch/arm/config.in Thu Nov 16 21:51:28 2000 +++ linux.noprintk/arch/arm/config.in Sun Jan 28 10:55:58 2001 @@ -414,6 +414,7 @@ bool 'Verbose user fault messages' CONFIG_DEBUG_USER bool 'Include debugging information in kernel binary' CONFIG_DEBUG_INFO bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK if [ "$CONFIG_CPU_26" = "y" ]; then bool 'Disable pgtable cache' CONFIG_NO_PGT_CACHE fi diff -u --recursive --new-file linux/arch/i386/config.in linux.noprintk/arch/i386/config.in --- linux/arch/i386/config.in Fri Dec 29 23:35:47 2000 +++ linux.noprintk/arch/i386/config.in Sun Jan 28 10:56:04 2001 @@ -366,4 +366,5 @@ #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/ia64/config.in linux.noprintk/arch/ia64/config.in --- linux/arch/ia64/config.in Thu Jan 4 21:50:17 2001 +++ linux.noprintk/arch/ia64/config.in Sun Jan 28 10:56:07 2001 @@ -249,6 +249,7 @@ fi bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK bool 'Early printk support (requires VGA!)' CONFIG_IA64_EARLY_PRINTK bool 'Turn on compare-and-exchange bug checking (slow!)' CONFIG_IA64_DEBUG_CMPXCHG bool 'Turn on irq debug checks (slow!)' CONFIG_IA64_DEBUG_IRQ diff -u --recursive --new-file linux/arch/m68k/config.in linux.noprintk/arch/m68k/config.in --- linux/arch/m68k/config.in Thu Jan 4 22:00:55 2001 +++ linux.noprintk/arch/m68k/config.in Sun Jan 28 10:56:09 2001 @@ -538,4 +538,5 @@ #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/mips/config.in linux.noprintk/arch/mips/config.in --- linux/arch/mips/config.in Thu Nov 16 21:51:28 2000 +++ linux.noprintk/arch/mips/config.in Sun Jan 28 10:56:12 2001 @@ -397,4 +397,5 @@ bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG fi bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/mips64/config.in linux.noprintk/arch/mips64/config.in --- linux/arch/mips64/config.in Wed Nov 29 06:42:04 2000 +++ linux.noprintk/arch/mips64/config.in Sun Jan 28 10:56:31 2001 @@ -266,4 +266,5 @@ fi bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/parisc/config.in linux.noprintk/arch/parisc/config.in --- linux/arch/parisc/config.in Tue Dec 5 21:29:39 2000 +++ linux.noprintk/arch/parisc/config.in Sun Jan 28 10:56:34 2001 @@ -204,5 +204,6 @@ #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/ppc/config.in linux.noprintk/arch/ppc/config.in --- linux/arch/ppc/config.in Thu Nov 16 21:51:28 2000 +++ linux.noprintk/arch/ppc/config.in Sun Jan 28 10:56:01 2001 @@ -332,6 +332,7 @@ comment 'Kernel hacking' bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK bool 'Include kgdb kernel debugger' CONFIG_KGDB bool 'Include xmon kernel debugger' CONFIG_XMON endmenu diff -u --recursive --new-file linux/arch/sh/config.in linux.noprintk/arch/sh/config.in --- linux/arch/sh/config.in Thu Jan 4 22:19:13 2001 +++ linux.noprintk/arch/sh/config.in Sun Jan 28 10:55:55 2001 @@ -260,6 +260,7 @@ comment 'Kernel hacking' bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK bool 'Use LinuxSH standard BIOS' CONFIG_SH_STANDARD_BIOS if [ "$CONFIG_SH_STANDARD_BIOS" = "y" ]; then bool 'GDB Stub kernel debug' CONFIG_DEBUG_KERNEL_WITH_GDB_STUB diff -u --recursive --new-file linux/arch/sparc/config.in linux.noprintk/arch/sparc/config.in --- linux/arch/sparc/config.in Wed Nov 29 06:53:44 2000 +++ linux.noprintk/arch/sparc/config.in Sun Jan 28 10:56:26 2001 @@ -261,4 +261,5 @@ comment 'Kernel hacking' bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK endmenu diff -u --recursive --new-file linux/arch/sparc64/config.in linux.noprintk/arch/sparc64/config.in --- linux/arch/sparc64/config.in Thu Nov 16 21:51:28 2000 +++ linux.noprintk/arch/sparc64/config.in Sun Jan 28 10:56:29 2001 @@ -335,5 +335,6 @@ comment 'Kernel hacking' bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Disable kernel messages' CONFIG_NOPRINTK #bool 'ECache flush trap support at ta 0x72' CONFIG_EC_FLUSH_TRAP endmenu diff -u --recursive --new-file linux/include/asm-i386/spinlock.h linux.noprintk/include/asm-i386/spinlock.h --- linux/include/asm-i386/spinlock.h Thu Jan 4 23:50:46 2001 +++ linux.noprintk/include/asm-i386/spinlock.h Sun Jan 28 12:16:17 2001 @@ -5,8 +5,10 @@ #include #include +#ifndef CONFIG_NOPRINTK extern int printk(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))); +#endif /* It seems that people are forgetting to * initialize their spinlocks properly, tsk tsk. diff -u --recursive --new-file linux/include/linux/kernel.h linux.noprintk/include/linux/kernel.h --- linux/include/linux/kernel.h Mon Dec 11 21:49:54 2000 +++ linux.noprintk/include/linux/kernel.h Mon Jan 29 21:03:40 2001 @@ -48,8 +48,15 @@ struct semaphore; extern struct notifier_block *panic_notifier_list; +#ifdef CONFIG_NOPRINTK + +#define panic(format, args...) ((format ,## args),panic_nomsg()) + +NORET_TYPE void panic_nomsg(void) ATTRIB_NORET; +#else NORET_TYPE void panic(const char * fmt, ...) __attribute__ ((NORET_AND format (printf, 1, 2))); +#endif NORET_TYPE void do_exit(long error_code) ATTRIB_NORET; NORET_TYPE void up_and_exit(struct semaphore *, long) @@ -68,8 +75,15 @@ extern int session_of_pgrp(int pgrp); +#ifdef CONFIG_NOPRINTK +#define printk(format, args...) ((format ,## args),(int)0) + +#else + asmlinkage int printk(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))); +#endif + extern int console_loglevel; diff -u --recursive --new-file linux/kernel/ksyms.c linux.noprintk/kernel/ksyms.c --- linux/kernel/ksyms.c Wed Jan 3 01:45:37 2001 +++ linux.noprintk/kernel/ksyms.c Sun Jan 28 10:56:51 2001 @@ -440,8 +440,10 @@ EXPORT_SYMBOL(nr_running); /* misc */ +#ifndef CONFIG_NOPRINTK EXPORT_SYMBOL(panic); EXPORT_SYMBOL(printk); +#endif EXPORT_SYMBOL(sprintf); EXPORT_SYMBOL(vsprintf); EXPORT_SYMBOL(kdevname); diff -u --recursive --new-file linux/kernel/panic.c linux.noprintk/kernel/panic.c --- linux/kernel/panic.c Mon Oct 16 21:58:51 2000 +++ linux.noprintk/kernel/panic.c Sun Jan 28 12:13:47 2001 @@ -43,18 +43,25 @@ * This function never returns. */ +#ifdef CONFIG_NOPRINTK +NORET_TYPE void panic_nomsg(void) +#else NORET_TYPE void panic(const char * fmt, ...) +#endif { - static char buf[1024]; - va_list args; #if defined(CONFIG_ARCH_S390) unsigned long caller = (unsigned long) __builtin_return_address(0); #endif +#ifndef CONFIG_NOPRINTK + static char buf[1024]; + va_list args; + va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); printk(KERN_EMERG "Kernel panic: %s\n",buf); +#endif if (in_interrupt()) printk(KERN_EMERG "In interrupt handler - not syncing\n"); else if (!current->pid) @@ -70,6 +77,9 @@ notifier_call_chain(&panic_notifier_list, 0, NULL); +#ifdef CONFIG_NOPRINTK + machine_restart(NULL); +#else if (panic_timeout > 0) { /* @@ -93,6 +103,7 @@ printk("Press L1-A to return to the boot prom\n"); } #endif +#endif #if defined(CONFIG_ARCH_S390) disabled_wait(caller); #endif @@ -101,3 +112,18 @@ CHECK_EMERGENCY_SYNC } } + +#ifdef CONFIG_NOPRINTK +#undef panic + +#include + +NORET_TYPE void panic(const char * fmt, ...) +{ + panic_nomsg(); +} + +EXPORT_SYMBOL_NOVERS(panic); + +#endif + diff -u --recursive --new-file linux/kernel/printk.c linux.noprintk/kernel/printk.c --- linux/kernel/printk.c Sun Dec 31 03:16:13 2000 +++ linux.noprintk/kernel/printk.c Sun Jan 28 10:57:23 2001 @@ -25,7 +25,9 @@ #define LOG_BUF_LEN (16384) #define LOG_BUF_MASK (LOG_BUF_LEN-1) +#ifndef CONFIG_NOPRINTK static char buf[1024]; +#endif /* printk's without a loglevel use this.. */ #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */ @@ -251,6 +253,20 @@ return do_syslog(type, buf, len); } + +#ifdef CONFIG_NOPRINTK +#undef printk + +#include + +asmlinkage int printk(const char *fmt, ...) +{ + return 0; +} + +EXPORT_SYMBOL_NOVERS(printk); + +#else asmlinkage int printk(const char *fmt, ...) { va_list args; @@ -311,6 +327,7 @@ wake_up_interruptible(&log_wait); return i; } +#endif void console_print(const char *s) { diff -u --recursive --new-file linux/Makefile linux.noprintk/Makefile --- linux/Makefile Thu Jan 4 22:48:13 2001 +++ linux.noprintk/Makefile Mon Jan 29 20:51:51 2001 @@ -89,6 +90,10 @@ CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) + +ifneq ($(CONFIG_NOPRINTK),) +CFLAGS += -Wno-unused +endif # # ROOT_DEV specifies the default root-device when making the image. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/