linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: torvalds@transmeta.com, alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org, Stefani@seibold.net
Subject: patch for 2.4.0 disable printk
Date: Fri, 26 Jan 2001 21:46:02 +0100	[thread overview]
Message-ID: <01012621460200.01354@deepthought.seibold.net> (raw)

Hi Linus,
Hi Alan,
Hi everybody,

this kernel patch allows to disable all printk messages, by overloading the 
printk function with a dummy printk macro.

This patch is usefull for embedded systems, where the hardware never changes 
and normaly no textconsole is attachted nor any user will see the boot 
messages. Also, it is nice for rescue disks.

On my system this saves about 10% of disk- and ramspace.

For example: My standart desktop kernel is 994834 bytes, without printk 
messages it is only 899664 bytes long. The basic kernel ram usage is also 10% 
less than the same kernel with printk messages.

Greetings,
Stefani

BTW: this is my first try to submit a kernel patch

-----patch for 2.4.0 disable printk-----

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 Thu Jan 18 12:14:41 2001
@@ -12139,6 +12179,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_PRINTK
+  This option allows you to disable all kernel messages by overriding
+  the printk function with an empty 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
+  normaly the best choice to say N to this option.
 
 Support for console on virtual terminal
 CONFIG_VT_CONSOLE
diff -u --recursive --new-file linux/drivers/char/Config.in 
linux.noprintk/drivers/char/Config.in
--- linux/drivers/char/Config.in        Fri Dec 29 23:07:21 2000
+++ linux.noprintk/drivers/char/Config.in       Thu Jan 18 10:33:07 2001
@@ -4,6 +4,7 @@
 mainmenu_option next_comment
 comment 'Character devices'
 
+bool 'Disable kernel messages' CONFIG_PRINTK
 bool 'Virtual terminal' CONFIG_VT
 if [ "$CONFIG_VT" = "y" ]; then
    bool '  Support for console on virtual terminal' CONFIG_VT_CONSOLE
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  Thu Jan 25 23:07:43 2001
@@ -5,8 +5,10 @@
 #include <asm/rwlock.h>
 #include <asm/page.h>
 
+#ifndef CONFIG_PRINTK
 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       Thu Jan 25 16:15:17 2001
@@ -68,8 +68,13 @@
 
 extern int session_of_pgrp(int pgrp);
 
+#ifdef CONFIG_PRINTK
+#define        printk(x...)    ((void)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       Thu Jan 18 12:14:41 2001
@@ -439,7 +440,9 @@
 
 /* misc */
 EXPORT_SYMBOL(panic);
+#ifndef CONFIG_PRINTK
 EXPORT_SYMBOL(printk);
+#endif
 EXPORT_SYMBOL(sprintf);
 EXPORT_SYMBOL(vsprintf);
 EXPORT_SYMBOL(kdevname);
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      Thu Jan 25 23:03:37 2001
@@ -25,7 +25,9 @@
 #define LOG_BUF_LEN    (16384)
 #define LOG_BUF_MASK   (LOG_BUF_LEN-1)
 
+#ifndef CONFIG_PRINTK
 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_PRINTK
+#undef printk
+
+#include <linux/module.h>
+
+asmlinkage int printk(const char *fmt, ...)
+{
+       return 0;
+}
+
+EXPORT_SYMBOL_NOVERS(printk);
+
+#else
 asmlinkage int printk(const char *fmt, ...)
 {
        va_list args;
@@ -311,6 +322,7 @@
        wake_up_interruptible(&log_wait);
        return i;
 }
+#endif
 
 void console_print(const char *s)
 {
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
@@ -2395,6 +2395,14 @@
 S: Oldenburg
 S: Germany
 
+N: Stefani Seibold
+E: Stefani@Seibold.net
+D: Possibility to disable all kernel messages by overload printk with a
+D: dummy macro (saves a lot of disk- and ramspace for embedded systems
+D: and rescue disks)
+S: Munich
+S: Germany
+
 N: Darren Senn
 E: sinster@darkwater.com
 D: Whatever I notice needs doing (so far: itimers, /proc)
-
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/

             reply	other threads:[~2001-01-26 20:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-26 20:46 Stefani Seibold [this message]
2001-01-26 21:13 ` patch for 2.4.0 disable printk David Weinehall
  -- strict thread matches above, loose matches on Subject: below --
2001-01-27 22:31 Stefani Seibold
2001-01-28  0:44 ` Andrew Morton
2001-01-28  9:27   ` Stefani Seibold
2001-01-28 17:32     ` Jamie Lokier
2001-01-29  2:48   ` Paul Gortmaker
2001-01-26 11:05 Stefani Seibold
2001-01-27  0:09 ` Thunder from the hill
2001-01-27 10:57   ` Stefani Seibold
2001-01-29 17:40     ` James Simmons
2001-01-29 20:17       ` Stefani Seibold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01012621460200.01354@deepthought.seibold.net \
    --to=stefani@seibold.net \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).