All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: Re: Reducing root filesystem
Date: Wed, 10 Apr 2002 17:38:58 +0200	[thread overview]
Message-ID: <20020410153858.GA8136@lug-owl.de> (raw)
In-Reply-To: <7CFD7CA8510CD6118F950002A519EA3001067D06@leonoid.in.ishoni.com>

[-- Attachment #1: Type: text/plain, Size: 5655 bytes --]

On Wed, 2002-04-10 19:38:09 +0530, Amol Kumar Lad <amolk@ishoni.com>
wrote in message <7CFD7CA8510CD6118F950002A519EA3001067D06@leonoid.in.ishoni.com>:
> Hi,
>   I am porting Linux to an embedded system. Currently my rootfilesystem is
> around 2.5 MB (after keeping it to minimal and adding tools like busybox). I
> want to furthur reduce it to say maximum of 1.5 MB. 
> Please suggest some link/references where I can find the details to optimise
> my root filesystem

I really can't help you with the root filesystem, but you can do sth
like this:


diff -Nur test-remove-me/linux-2.2.19-clean/Documentation/Configure.help linux-schlecker-2.2.19/Documentation/Configure.help
--- test-remove-me/linux-2.2.19-clean/Documentation/Configure.help	Sun Mar 25 18:37:29 2001
+++ linux-schlecker-2.2.19/Documentation/Configure.help	Mon Nov  5 12:42:46 2001
@@ -4942,6 +4942,14 @@
   important data. This is primarily of use to people trying to debug
   the middle and upper layers of the SCSI subsystem. If unsure, say N.
 
+Smaller kernel by omitting most messages
+CONFIG_NO_PRINTK
+  Enabling this option will result in a smaller kernel by removing
+  most text strings. This is only useful for emdedded systems where
+  you've got to live with <= 4MB of RAM. I386-only for now...
+
+  If unsure, say no.
+
 Fibre Channel support
 CONFIG_FC4
   This is an experimental support for storage arrays connected to
@@ -210,5 +221,6 @@
 
 #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+bool 'Eleminate *most* printk()s' CONFIG_NO_PRINTK
 endmenu
 
diff -Nur test-remove-me/linux-2.2.19-clean/arch/i386/kernel/head.S linux-schlecker-2.2.19/arch/i386/kernel/head.S
--- test-remove-me/linux-2.2.19-clean/arch/i386/kernel/head.S	Sun Mar 25 18:31:45 2001
+++ linux-schlecker-2.2.19/arch/i386/kernel/head.S	Fri Nov  2 11:21:42 2001
@@ -315,7 +315,7 @@
 	movl %ax,%ds
 	movl %ax,%es
 	pushl $int_msg
-	call SYMBOL_NAME(printk)
+	call SYMBOL_NAME(real_printk)
 	popl %eax
 	popl %ds
 	popl %es
diff -Nur test-remove-me/linux-2.2.19-clean/include/asm-i386/system.h linux-schlecker-2.2.19/include/asm-i386/system.h
--- test-remove-me/linux-2.2.19-clean/include/asm-i386/system.h	Sun Mar 25 18:31:05 2001
+++ linux-schlecker-2.2.19/include/asm-i386/system.h	Mon Dec 17 14:32:03 2001
@@ -135,21 +135,15 @@
 	switch (size) {
 		case 1:
 			__asm__("xchgb %b0,%1"
-				:"=q" (x)
-				:"m" (*__xg(ptr)), "0" (x)
-				:"memory");
+					:"+q" (x),"=m" (*__xg(ptr)));
 			break;
 		case 2:
 			__asm__("xchgw %w0,%1"
-				:"=r" (x)
-				:"m" (*__xg(ptr)), "0" (x)
-				:"memory");
+					:"+r" (x),"=m" (*__xg(ptr)));
 			break;
 		case 4:
 			__asm__("xchgl %0,%1"
-				:"=r" (x)
-				:"m" (*__xg(ptr)), "0" (x)
-				:"memory");
+					:"+r" (x), "=m" (*__xg(ptr)));
 			break;
 	}
 	return x;
diff -Nur test-remove-me/linux-2.2.19-clean/include/linux/kernel.h linux-schlecker-2.2.19/include/linux/kernel.h
--- test-remove-me/linux-2.2.19-clean/include/linux/kernel.h	Sun Mar 25 18:31:03 2001
+++ linux-schlecker-2.2.19/include/linux/kernel.h	Fri Dec 14 14:53:14 2001
@@ -9,6 +9,7 @@
 
 #include <stdarg.h>
 #include <linux/linkage.h>
+#include <linux/config.h>
 
 /* Optimization barrier */
 /* The "volatile" is due to gcc bugs */
@@ -54,8 +55,16 @@
 
 extern int session_of_pgrp(int pgrp);
 
-asmlinkage int printk(const char * fmt, ...)
+asmlinkage int real_printk(const char * fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
+
+#ifdef CONFIG_NO_PRINTK
+#	define printk(format, arg...) do {} while(0)
+#else
+#	define printk(format, arg...) real_printk(format, ## arg)
+#endif /* CONFIG_NO_PRINTK */
+
+#define oops_printk(format, arg...) real_printk(format, ## arg)
 
 #if DEBUG
 #define pr_debug(fmt,arg...) \
diff -Nur test-remove-me/linux-2.2.19-clean/kernel/ksyms.c linux-schlecker-2.2.19/kernel/ksyms.c
--- test-remove-me/linux-2.2.19-clean/kernel/ksyms.c	Sun Mar 25 18:31:02 2001
+++ linux-schlecker-2.2.19/kernel/ksyms.c	Fri Dec 14 15:24:52 2001
@@ -357,7 +357,7 @@
 
 /* misc */
 EXPORT_SYMBOL(panic);
-EXPORT_SYMBOL(printk);
+EXPORT_SYMBOL(real_printk);
 EXPORT_SYMBOL(sprintf);
 EXPORT_SYMBOL(vsprintf);
 EXPORT_SYMBOL(kdevname);
diff -Nur test-remove-me/linux-2.2.19-clean/kernel/printk.c linux-schlecker-2.2.19/kernel/printk.c
--- test-remove-me/linux-2.2.19-clean/kernel/printk.c	Sun Mar 25 18:31:02 2001
+++ linux-schlecker-2.2.19/kernel/printk.c	Fri Dec 14 14:52:50 2001
@@ -249,7 +249,7 @@
 	return do_syslog(type, buf, len);
 }
 
-asmlinkage int printk(const char *fmt, ...)
+asmlinkage int real_printk(const char *fmt, ...)
 {
 	va_list args;
 	int i;




This is for i386, but it can be implemented like this for other
architectures. Please note:

	- The patch to system.h is only neccessary because gcc will
	  magically miscompile the code if there's no printk()
	  resulting (at least) in a broken DMA (de)registering
	  functions rendering the floppy.o module useless. Maybe
	  you don't need this patch. It was _not_ developed by
	  me but send by Momchil Velikov <velco@fadata.bg>.
	- In 2.4.x, EXPORT_SYMBOL((real)printk) is not in
	  kernel/ksyms.c, but in kernel/printk.c
	- BigFatWarning: It shouldn't be, but there might
	  be code fragments that do more than only printing
	  in a printk call (like 'printk(KERN_ERR "%d\n", a=func(a))')
	  Things like this _will_ break!!!

MfG, JBG

-- 
Jan-Benedict Glaw   .   jbglaw@lug-owl.de   .   +49-172-7608481
	 -- New APT-Proxy written in shell script --
	   http://lug-owl.de/~jbglaw/software/ap2/

[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]

  parent reply	other threads:[~2002-04-10 15:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7CFD7CA8510CD6118F950002A519EA3001067D06@leonoid.in.ishoni.com>
2002-04-10 14:24 ` Reducing root filesystem Piotr Esden-Tempski
2002-04-10 15:28 ` Erik Andersen
2002-04-11 14:08   ` Erik Mouw
2002-04-10 15:38 ` Jan-Benedict Glaw [this message]
2002-04-10 19:09 ` Padraig Brady
2002-04-11  1:59   ` Miles Bader
2002-04-10 16:36 Kerl, John

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=20020410153858.GA8136@lug-owl.de \
    --to=jbglaw@lug-owl.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.