Skip to contentSkip to conversation

patch for suppress printk messages

PATCH Stefani Seibold 2 participants 4 messages Dec 4, 2001 Documentation

lore
Share & tools
lore
#0 lore raw

Hi everybody,

this is my new version for suppressing kernel printk messages. This will shrink the kernel by an average of 10 percent (for example my desktop kernel will shrink about 90K).
It is usefull on deeply embedded systems with no human interactions  and for rescue discs where the diskspace is always to less.

This patch has the following features:

- The macro printk will evalute all parameters, than throw it away and return 0 as result. So it should be do the same from the callers view, like the original printk function, but all arguments will be removed by compiler optimatzion if possible.

- The macro panic will also evaluate the parameters and throw it away by compiler optimatzion if possible.

- No compiler warnings also on max. compiler warning level.

- Up to 16 arguments will be evaluated. This can be simply extended by adding additional DOARG_xx Macros.

- For backward compatibility the functions printk and panic will be also implemented and exported as functions with no output .

- The name of the config variable is CONFIG_DEBUG_SUPPRESS.

- The option for disabling the printk and panic messages in the menu kernel hacking.

The complexity for the printk and panic macro is still necessary, because this is the only way, to evaluate a macro with variable arguments without compiler warnings.

I hope this will it now do in the developer kernel release 2.5, because no side effects should be now expect.

Thanks,
Stefani Seibold

-----patch for suppress printk messages against 2.4.16  -----

Documentation/Configure.help  Tue Dec  4 16:40:24 2001 renamed from home/stefani/soft/kernel/linux/Documentation/Configure.help        Thu Nov 22 19:52:44 2001 +0 -0
diff -u --recursive --new-file linux.orig/Documentation/Configure.help linux.new/Documentation/Configure.help
@@ -23590,11 +23590,19 @@

   best used in conjunction with the NMI watchdog so that spinlock deadlocks are also debuggable.

-Verbose BUG() reporting (adds 70K)
-CONFIG_DEBUG_BUGVERBOSE
-  Say Y here to make BUG() panics output the file name and line number
-  of the BUG call as well as the EIP and oops trace.  This aids
-  debugging but costs about 70-100K of memory.
+Kernel debug output
+CONFIG_DEBUG_DEFAULT
+  Which this option, you can specify the kernel verbosity.
+
+  - default is the normal setting for most linux boxes (Server, Desktop)
+  - verbose will aids debugging and is the recommended setting for kernel
+    hackers. Say Y here to make BUG() panics output the file name and line
+    number of the BUG call as well as the EIP and oops trace.
+    (this options adds 70K-100K to your kernel)
+  - suppress wil be useful for deeply embedded system where nobody will
+    see any kernel output
+    (this option will save a lot of rom and ram space >70K)
+

 Include kgdb kernel debugger
 CONFIG_KGDB

kernel/panic.c        Tue Dec  4 14:10:45 2001 renamed from home/stefani/soft/kernel/linux/kernel/panic.c      Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/kernel/panic.c linux.new/kernel/panic.c
@@ -8,14 +8,17 @@

  * This function is used through-out the kernel (including mm and fs)
  * to indicate a major problem.
  */
-#include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/reboot.h>
 #include <linux/notifier.h>
-#include <linux/init.h>
 #include <linux/sysrq.h>
-#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>                   /* For in_interrupt() */ +#include <linux/config.h>
+
+#include <asm/uaccess.h>

 asmlinkage void sys_sync(void);        /* it's really int */

@@ -31,6 +34,12 @@

 __setup("panic=", panic_setup);

+#ifdef CONFIG_DEBUG_SUPPRESS
+#undef panic
+
+NORET_TYPE void panic_nomsg(void) __attribute__ ((alias("panic"))); +#endif
+
 /**
  *     panic - halt the system
  *     @fmt: The text string to print
@@ -43,17 +52,21 @@

 NORET_TYPE void panic(const char * fmt, ...)
 {
-       static char buf[1024];
-       va_list args;
 #if defined(CONFIG_ARCH_S390)
         unsigned long caller = (unsigned long) __builtin_return_address(0); #endif
+#ifndef CONFIG_DEBUG_SUPPRESS
+       static char buf[1024];
+       va_list args;

-       bust_spinlocks(1);
        va_start(args, fmt);
        vsprintf(buf, fmt, args);
        va_end(args);
        printk(KERN_EMERG "Kernel panic: %s\n",buf);
+#else
+       (void)(fmt);
+#endif
+       bust_spinlocks(1);
        if (in_interrupt())
                printk(KERN_EMERG "In interrupt handler - not syncing\n"); else if (!current->pid)
@@ -100,7 +113,9 @@
        }
 }

-/**
+EXPORT_SYMBOL(panic);
+
+/*
  *     print_tainted - return a string to represent the kernel taint state. *
  *     The string is overwritten by the next call to print_taint().

kernel/printk.c       Tue Dec  4 16:07:20 2001 renamed from home/stefani/soft/kernel/linux/kernel/printk.c     Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/kernel/printk.c linux.new/kernel/printk.c
@@ -371,6 +371,22 @@

        _call_console_drivers(start_print, end, msg_level); }

+#ifdef CONFIG_DEBUG_SUPPRESS
+
+/*
+ * Disable printk function calls
+ * This is useful for deeply embedded system where nobody will see the
+ * kernel output
+ * Stefani Seibold <[email protected]>
+ */
+
+#undef printk
+asmlinkage int printk(const char *fmt, ...)
+{
+       (void)(fmt);
+       return 0;
+}
+#else
 static void emit_log_char(char c)
 {
        LOG_BUF(log_end) = c;
@@ -456,6 +472,8 @@
        }
        return printed_len;
 }
+#endif
+
 EXPORT_SYMBOL(printk);

 /**

kernel/ksyms.c        Tue Dec  4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c      Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/kernel/ksyms.c linux.new/kernel/ksyms.c
@@ -449,7 +449,6 @@

 EXPORT_SYMBOL(nr_running);

 /* misc */
-EXPORT_SYMBOL(panic);
 EXPORT_SYMBOL(sprintf);
 EXPORT_SYMBOL(snprintf);
 EXPORT_SYMBOL(sscanf);

kernel/Makefile       Tue Dec  4 13:52:24 2001 renamed from home/stefani/soft/kernel/linux/kernel/Makefile     Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/kernel/Makefile linux.new/kernel/Makefile
@@ -9,7 +9,7 @@


 O_TARGET := kernel.o

-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o +export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o panic.o
 obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
            module.o exit.o itimer.o info.o time.o softirq.o resource.o \

include/linux/kernel.h        Tue Dec  4 16:31:23 2001 renamed from home/stefani/soft/kernel/linux/include/linux/kernel.h      Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/include/linux/kernel.h linux.new/include/linux/kernel.h
@@ -49,8 +49,16 @@

 struct completion;

 extern struct notifier_block *panic_notifier_list;
+
 NORET_TYPE void panic(const char * fmt, ...)
        __attribute__ ((NORET_AND format (printf, 1, 2)));
+
+#ifdef CONFIG_DEBUG_SUPPRESS
+#define panic(format ,args...) (DOARG_0(format, ## args ,0),panic_nomsg()) +
+NORET_TYPE void panic_nomsg(void) ATTRIB_NORET;
+#endif
+
 asmlinkage NORET_TYPE void do_exit(long error_code)
        ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
@@ -79,8 +87,35 @@

 extern int session_of_pgrp(int pgrp);

+#ifdef CONFIG_DEBUG_SUPPRESS
+static __inline__ int printk_nomsg(void)
+{
+       return 0;
+}
+
+#define DOARG_15(arg, args...) ((void)(arg))
+#define DOARG_14(arg, args...) (DOARG_15(args,0),((void)(arg))) +#define DOARG_13(arg, args...) (DOARG_14(args,0),((void)(arg))) +#define DOARG_12(arg, args...) (DOARG_13(args,0),((void)(arg))) +#define DOARG_11(arg, args...) (DOARG_12(args,0),((void)(arg))) +#define DOARG_10(arg, args...) (DOARG_11(args,0),((void)(arg))) +#define DOARG_9(arg, args...)  (DOARG_10(args,0),((void)(arg))) +#define DOARG_8(arg, args...)  (DOARG_9(args,0),((void)(arg))) +#define DOARG_7(arg, args...)  (DOARG_8(args,0),((void)(arg))) +#define DOARG_6(arg, args...)  (DOARG_7(args,0),((void)(arg))) +#define DOARG_5(arg, args...)  (DOARG_6(args,0),((void)(arg))) +#define DOARG_4(arg, args...)  (DOARG_5(args,0),((void)(arg))) +#define DOARG_3(arg, args...)  (DOARG_5(args,0),((void)(arg))) +#define DOARG_2(arg, args...)  (DOARG_3(args,0),((void)(arg))) +#define DOARG_1(arg, args...)  (DOARG_2(args,0),((void)(arg))) +#define DOARG_0(arg, args...)  (DOARG_1(args,0),((void)(arg)))
+
+#define printk(format ,args...)        (DOARG_0(format, ## args ,0),printk_nomsg()) +#else
+
 asmlinkage int printk(const char * fmt, ...)
        __attribute__ ((format (printf, 1, 2)));
+#endif

 extern int console_loglevel;

include/asm-i386/spinlock.h   Tue Dec  4 14:12:00 2001 renamed from home/stefani/soft/kernel/linux/include/asm-i386/spinlock.h Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/include/asm-i386/spinlock.h linux.new/include/asm-i386/spinlock.h
@@ -6,8 +6,12 @@

 #include <asm/page.h>
 #include <linux/config.h>

+#ifdef CONFIG_DEBUG_SUPPRESS
+inline int printk(const char * fmt, ...) { (void)(fmt); } +#else
 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.

arch/i386/kernel/head.S       Tue Dec  4 16:11:19 2001 renamed from home/stefani/soft/kernel/linux/arch/i386/kernel/head.S     Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/arch/i386/kernel/head.S linux.new/arch/i386/kernel/head.S
@@ -324,6 +324,7 @@

        .long __KERNEL_DS

 /* This is the default interrupt "handler" :-) */ +#ifndef CONFIG_DEBUG_SUPPRESS
 int_msg:
        .asciz "Unknown interrupt\n"
        ALIGN
@@ -345,6 +346,11 @@
        popl %edx
        popl %ecx
        popl %eax
+#else
+ignore_int:
+       ALIGN
+       cld
+#endif
        iret

 /*

arch/i386/config.in   Tue Dec  4 16:37:02 2001 renamed from home/stefani/soft/kernel/linux/arch/i386/config.in Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/arch/i386/config.in linux.new/arch/i386/config.in
@@ -406,7 +406,10 @@

    bool '  Memory mapped I/O debugging' CONFIG_DEBUG_IOVIRT bool '  Magic SysRq key' CONFIG_MAGIC_SYSRQ
    bool '  Spinlock debugging' CONFIG_DEBUG_SPINLOCK
-   bool '  Verbose BUG() reporting (adds 70K)' CONFIG_DEBUG_BUGVERBOSE
+   choice 'Kernel debug output' \
+       "default                CONFIG_DEBUG_DEFAULT \
+        verbose                CONFIG_DEBUG_BUGVERBOSE \
+        suppress               CONFIG_DEBUG_SUPPRESS" default fi

 endmenu

arch/ppc/config.in    Tue Dec  4 14:42:33 2001 renamed from home/stefani/soft/kernel/linux/arch/ppc/config.in  Tue Dec  4 16:10:36 2001 +0 -0
diff -u --recursive --new-file linux.orig/arch/ppc/config.in linux.new/arch/ppc/config.in
@@ -392,4 +392,8 @@

 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
 bool 'Include kgdb kernel debugger' CONFIG_KGDB bool 'Include xmon kernel debugger' CONFIG_XMON +choice 'Kernel debug output' \
+       "default                CONFIG_DEBUG_DEFAULT \
+        verbose                CONFIG_DEBUG_BUGVERBOSE \
+        suppress               CONFIG_DEBUG_SUPPRESS" default endmenu

#1 lore raw

Can you show an example what is printed now?

Thanks
----- Original Message -----
From: "Stefani Seibold" <[email protected]>
To: <[email protected]>; <[email protected]>
Cc: <[email protected]>; <[email protected]>
Sent: Tuesday, December 04, 2001 5:40 PM
Subject: patch for suppress printk messages

Quoted 3 lines

Hi everybody,

this is my new version for suppressing kernel printk messages. This will

shrink

Quoted 1 line

the kernel by an average of 10 percent (for example my desktop kernel will

shrink

Quoted 2 lines

about 90K).
It is usefull on deeply embedded systems with no human interactions and

for rescue

Quoted 5 lines

discs where the diskspace is always to less.

This patch has the following features:

- The macro printk will evalute all parameters, than throw it away and

return 0 as

Quoted 1 line

result. So it should be do the same from the callers view, like the

original printk

Quoted 1 line

function, but all arguments will be removed by compiler optimatzion if

possible.

Quoted 2 lines

- The macro panic will also evaluate the parameters and throw it away by

compiler

Quoted 5 lines

optimatzion if possible.

- No compiler warnings also on max. compiler warning level.

- Up to 16 arguments will be evaluated. This can be simply extended by

adding

Quoted 3 lines

additional DOARG_xx Macros.

- For backward compatibility the functions printk and panic will be also

implemented and

Quoted 5 lines

exported as functions with no output .

- The name of the config variable is CONFIG_DEBUG_SUPPRESS.

- The option for disabling the printk and panic messages in the menu

kernel

Quoted 3 lines

hacking.

The complexity for the printk and panic macro is still necessary, because

this

Quoted 4 lines

is the only way, to evaluate a macro with variable arguments without compiler warnings.

I hope this will it now do in the developer kernel release 2.5, because no

side

Quoted 8 lines

effects should be now expect.

Thanks,
Stefani Seibold

-----patch for suppress printk messages against 2.4.16 -----

diff -u --recursive --new-file linux.orig/Documentation/Configure.help

linux.new/Documentation/Configure.help

Quoted 1 line

--- /home/stefani/soft/kernel/linux/Documentation/Configure.help Thu Nov

22 19:52:44 2001

Quoted 24 lines

+++ linux/Documentation/Configure.help Tue Dec 4 16:40:24 2001

(quoted diff) +0 -0
@@ -23590,11 +23590,19 @@

best used in conjunction with the NMI watchdog so that spinlock deadlocks are also debuggable.

(quoted diff) +13 -5
-Verbose BUG() reporting (adds 70K)
-CONFIG_DEBUG_BUGVERBOSE
- Say Y here to make BUG() panics output the file name and line number
- of the BUG call as well as the EIP and oops trace. This aids
- debugging but costs about 70-100K of memory.
+Kernel debug output
+CONFIG_DEBUG_DEFAULT
+ Which this option, you can specify the kernel verbosity.
+
+ - default is the normal setting for most linux boxes (Server, Desktop)
+ - verbose will aids debugging and is the recommended setting for kernel
+ hackers. Say Y here to make BUG() panics output the file name and line
+ number of the BUG call as well as the EIP and oops trace.
+ (this options adds 70K-100K to your kernel)
+ - suppress wil be useful for deeply embedded system where nobody will
+ see any kernel output
+ (this option will save a lot of rom and ram space >70K)
+
Quoted 3 lines

Include kgdb kernel debugger
CONFIG_KGDB
diff -u --recursive --new-file linux.orig/kernel/panic.c

linux.new/kernel/panic.c

Quoted 72 lines
kernel/panic.c Tue Dec 4 14:10:45 2001 renamed from home/stefani/soft/kernel/linux/kernel/panic.c Tue Dec 4 16:10:36 2001 +6 -3
@@ -8,14 +8,17 @@
 * This function is used through-out the kernel (including mm and fs)
 * to indicate a major problem.
 */
-#include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/reboot.h>
 #include <linux/notifier.h>
-#include <linux/init.h>
 #include <linux/sysrq.h>
-#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h> /* For in_interrupt() */
+#include <linux/config.h>
+
+#include <asm/uaccess.h>
 

asmlinkage void sys_sync(void); /* it's really int */

kernel/panic.c Tue Dec 4 14:10:45 2001 renamed from home/stefani/soft/kernel/linux/kernel/panic.c Tue Dec 4 16:10:36 2001 +16 -4
@@ -31,6 +34,12 @@
 
 __setup("panic=", panic_setup);
 
+#ifdef CONFIG_DEBUG_SUPPRESS
+#undef panic
+
+NORET_TYPE void panic_nomsg(void) __attribute__ ((alias("panic")));
+#endif
+
 /**
 * panic - halt the system
 * @fmt: The text string to print
@@ -43,17 +52,21 @@
 
 NORET_TYPE void panic(const char * fmt, ...)
 {
- static char buf[1024];
- va_list args;
 #if defined(CONFIG_ARCH_S390)
 unsigned long caller = (unsigned long) __builtin_return_address(0);
 #endif
+#ifndef CONFIG_DEBUG_SUPPRESS
+ static char buf[1024];
+ va_list args;
 
- bust_spinlocks(1);
 va_start(args, fmt);
 vsprintf(buf, fmt, args);
 va_end(args);
 printk(KERN_EMERG "Kernel panic: %s\n",buf);
+#else
+ (void)(fmt);
+#endif
+ bust_spinlocks(1);
 if (in_interrupt())
 printk(KERN_EMERG "In interrupt handler - not syncing\n");
 else if (!current->pid)
@@ -100,7 +113,9 @@
 }
 }
 
-/**
+EXPORT_SYMBOL(panic);
+
+/*
 * print_tainted - return a string to represent the kernel taint state.
 *
 * The string is overwritten by the next call to print_taint().
Quoted 1 line

diff -u --recursive --new-file linux.orig/kernel/printk.c

linux.new/kernel/printk.c

Quoted 1 line

--- /home/stefani/soft/kernel/linux/kernel/printk.c Tue Dec 4 16:10:36

2001

Quoted 33 lines

+++ linux/kernel/printk.c Tue Dec 4 16:07:20 2001

kernel/panic.c Tue Dec 4 14:10:45 2001 renamed from home/stefani/soft/kernel/linux/kernel/panic.c Tue Dec 4 16:10:36 2001 +18 -0
@@ -371,6 +371,22 @@
 _call_console_drivers(start_print, end, msg_level);
 }
 
+#ifdef CONFIG_DEBUG_SUPPRESS
+
+/*
+ * Disable printk function calls
+ * This is useful for deeply embedded system where nobody will see the
+ * kernel output
+ * Stefani Seibold <[email protected]>
+ */
+
+#undef printk
+asmlinkage int printk(const char *fmt, ...)
+{
+ (void)(fmt);
+ return 0;
+}
+#else
 static void emit_log_char(char c)
 {
 LOG_BUF(log_end) = c;
@@ -456,6 +472,8 @@
 }
 return printed_len;
 }
+#endif
+
 EXPORT_SYMBOL(printk);
 
 /**
Quoted 1 line

diff -u --recursive --new-file linux.orig/kernel/ksyms.c

linux.new/kernel/ksyms.c

Quoted 11 lines
kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -1
@@ -449,7 +449,6 @@
 EXPORT_SYMBOL(nr_running);
 
 /* misc */
-EXPORT_SYMBOL(panic);
 EXPORT_SYMBOL(sprintf);
 EXPORT_SYMBOL(snprintf);
 EXPORT_SYMBOL(sscanf);

diff -u --recursive --new-file linux.orig/kernel/Makefile

linux.new/kernel/Makefile

Quoted 1 line

--- /home/stefani/soft/kernel/linux/kernel/Makefile Tue Dec 4 16:10:36

2001

Quoted 6 lines

+++ linux/kernel/Makefile Tue Dec 4 13:52:24 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -0
@@ -9,7 +9,7 @@
 

O_TARGET := kernel.o

-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o

printk.o

Quoted 1 line

+export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o

printk.o panic.o

Quoted 4 lines

obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
module.o exit.o itimer.o info.o time.o softirq.o resource.o \
diff -u --recursive --new-file linux.orig/include/linux/kernel.h

linux.new/include/linux/kernel.h

Quoted 1 line

--- /home/stefani/soft/kernel/linux/include/linux/kernel.h Tue Dec 4

16:10:36 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 line 57

Quoted 11 lines

+++ linux/include/linux/kernel.h Tue Dec 4 16:31:23 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +4 -0
@@ -49,8 +49,16 @@
 struct completion;
 
 extern struct notifier_block *panic_notifier_list;
+
 NORET_TYPE void panic(const char * fmt, ...)
 __attribute__ ((NORET_AND format (printf, 1, 2)));
+
+#ifdef CONFIG_DEBUG_SUPPRESS
+#define panic(format ,args...) (DOARG_0(format, ## args

,0),panic_nomsg())

Quoted 25 lines
kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +18 -0
+
+NORET_TYPE void panic_nomsg(void) ATTRIB_NORET;
+#endif
+
 asmlinkage NORET_TYPE void do_exit(long error_code)
 ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
@@ -79,8 +87,35 @@
 
 extern int session_of_pgrp(int pgrp);
 
+#ifdef CONFIG_DEBUG_SUPPRESS
+static __inline__ int printk_nomsg(void)
+{
+ return 0;
+}
+
+#define DOARG_15(arg, args...) ((void)(arg))
+#define DOARG_14(arg, args...) (DOARG_15(args,0),((void)(arg)))
+#define DOARG_13(arg, args...) (DOARG_14(args,0),((void)(arg)))
+#define DOARG_12(arg, args...) (DOARG_13(args,0),((void)(arg)))
+#define DOARG_11(arg, args...) (DOARG_12(args,0),((void)(arg)))
+#define DOARG_10(arg, args...) (DOARG_11(args,0),((void)(arg)))
+#define DOARG_9(arg, args...) (DOARG_10(args,0),((void)(arg)))
+#define DOARG_8(arg, args...) (DOARG_9(args,0),((void)(arg)))

kernel/ksyms.c Tue Dec 4 14:03:53 2001 line 113

Quoted 10 lines
kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +10 -0
+#define DOARG_7(arg, args...) (DOARG_8(args,0),((void)(arg)))
+#define DOARG_6(arg, args...) (DOARG_7(args,0),((void)(arg)))
+#define DOARG_5(arg, args...) (DOARG_6(args,0),((void)(arg)))
+#define DOARG_4(arg, args...) (DOARG_5(args,0),((void)(arg)))
+#define DOARG_3(arg, args...) (DOARG_5(args,0),((void)(arg)))
+#define DOARG_2(arg, args...) (DOARG_3(args,0),((void)(arg)))
+#define DOARG_1(arg, args...) (DOARG_2(args,0),((void)(arg)))
+#define DOARG_0(arg, args...) (DOARG_1(args,0),((void)(arg)))
+
+#define printk(format ,args...) (DOARG_0(format, ## args

,0),printk_nomsg())

Quoted 9 lines
kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +3 -0
+#else
+
 asmlinkage int printk(const char * fmt, ...)
 __attribute__ ((format (printf, 1, 2)));
+#endif
 
 extern int console_loglevel;
 

diff -u --recursive --new-file linux.orig/include/asm-i386/spinlock.h

linux.new/include/asm-i386/spinlock.h

Quoted 1 line

--- /home/stefani/soft/kernel/linux/include/asm-i386/spinlock.h Tue Dec 4

16:10:36 2001

Quoted 14 lines

+++ linux/include/asm-i386/spinlock.h Tue Dec 4 14:12:00 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +4 -0
@@ -6,8 +6,12 @@
 #include <asm/page.h>
 #include <linux/config.h>
 
+#ifdef CONFIG_DEBUG_SUPPRESS
+inline int printk(const char * fmt, ...) { (void)(fmt); }
+#else
 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.
Quoted 1 line

diff -u --recursive --new-file linux.orig/arch/i386/kernel/head.S

linux.new/arch/i386/kernel/head.S

Quoted 1 line

--- /home/stefani/soft/kernel/linux/arch/i386/kernel/head.S Tue Dec 4

16:10:36 2001

Quoted 20 lines

+++ linux/arch/i386/kernel/head.S Tue Dec 4 16:11:19 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -0
@@ -324,6 +324,7 @@

.long __KERNEL_DS

/* This is the default interrupt "handler" :-) */
+#ifndef CONFIG_DEBUG_SUPPRESS
int_msg:
.asciz "Unknown interrupt\n"
ALIGN

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -0
@@ -345,6 +346,11 @@

popl %edx
popl %ecx
popl %eax

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +5 -0
+#else
+ignore_int:
+ ALIGN
+ cld
+#endif

iret

Quoted 2 lines

/*
diff -u --recursive --new-file linux.orig/arch/i386/config.in

linux.new/arch/i386/config.in

Quoted 1 line

--- /home/stefani/soft/kernel/linux/arch/i386/config.in Tue Dec 4 16:10:36

2001

Quoted 12 lines

+++ linux/arch/i386/config.in Tue Dec 4 16:37:02 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -0
@@ -406,7 +406,10 @@

bool ' Memory mapped I/O debugging' CONFIG_DEBUG_IOVIRT bool ' Magic SysRq key' CONFIG_MAGIC_SYSRQ
bool ' Spinlock debugging' CONFIG_DEBUG_SPINLOCK
- bool ' Verbose BUG() reporting (adds 70K)' CONFIG_DEBUG_BUGVERBOSE
+ choice 'Kernel debug output' \
+ "default CONFIG_DEBUG_DEFAULT \
+ verbose CONFIG_DEBUG_BUGVERBOSE \
+ suppress CONFIG_DEBUG_SUPPRESS" default
fi

Quoted 2 lines

endmenu
diff -u --recursive --new-file linux.orig/arch/ppc/config.in

linux.new/arch/ppc/config.in

Quoted 1 line

--- /home/stefani/soft/kernel/linux/arch/ppc/config.in Tue Dec 4 16:10:36

2001

Quoted 11 lines

+++ linux/arch/ppc/config.in Tue Dec 4 14:42:33 2001

kernel/ksyms.c Tue Dec 4 14:03:53 2001 renamed from home/stefani/soft/kernel/linux/kernel/ksyms.c Tue Dec 4 16:10:36 2001 +0 -0
@@ -392,4 +392,8 @@

bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
bool 'Include kgdb kernel debugger' CONFIG_KGDB
bool 'Include xmon kernel debugger' CONFIG_XMON
+choice 'Kernel debug output' \
+ "default CONFIG_DEBUG_DEFAULT \
+ verbose CONFIG_DEBUG_BUGVERBOSE \
+ suppress CONFIG_DEBUG_SUPPRESS" default
endmenu

#2 lore raw
In reply to Stefani Seibold

The kernel will not do any printk debug output. The kernel will boot silently. Only the output of userland processes will make outputs to the console.
This patch is not for big systems like desktop or server. It is designed for systems with a very small footprint, like a toaster or a dvd player.
On this kind of systems the hardware normaly never change and there is not very much memory.

Am Dienstag, 4. Dezember 2001 18:40 schrieb Tommy Faasen:

Quoted 10 lines

Can you show an example what is printed now?

Thanks
----- Original Message -----
From: "Stefani Seibold" <[email protected]>
To: <[email protected]>; <[email protected]>
Cc: <[email protected]>; <[email protected]>
Sent: Tuesday, December 04, 2001 5:40 PM
Subject: patch for suppress printk messages