Skip to contentSkip to conversation

base-small: CONFIG_BASE_SMALL for small systems

PATCH In review Matt Mackall 2 participants 11 messages Jan 31, 2005 – Feb 1, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover base-small: CONFIG_BASE_SMALL for small systems

This patch series introduced a new pair of CONFIG_EMBEDDED options call CONFIG_BASE_FULL/CONFIG_BASE_SMALL. Disabling CONFIG_BASE_FULL sets the boolean CONFIG_BASE_SMALL to 1 and it is used to shrink a number of core data structures. The space savings for the current batch is around 14k.

#1 lore raw

PATCH 1/8 base-small: introduce the CONFIG_BASE_SMALL flag

Add CONFIG_BASE_SMALL for miscellaneous core size that don't warrant their own options. Example users to follow.

init/Kconfig +12 -0
Index: mm2/init/Kconfig
===================================================================
@@ -286,6 +286,18 @@
 	   reported.  KALLSYMS_EXTRA_PASS is only a temporary workaround while
 	   you wait for kallsyms to be fixed.
 
+config BASE_FULL
+	default y
+	bool "Enable full-sized data structures for core" if EMBEDDED
+	help
+	  Disabling this option reduces the size of miscellaneous core
+	  kernel data structures.
+
+config BASE_SMALL
+	int
+	default 0 if BASE_FULL
+	default 1 if !BASE_FULL
+
 config FUTEX
 	bool "Enable futex support" if EMBEDDED
 	default y
#2 lore raw

PATCH 2/8 base-small: shrink major_names hash

CONFIG_BASE_SMALL degrade genhd major names hash to linked list

drivers/block/genhd.c +2 -1
Index: tq/drivers/block/genhd.c
===================================================================
@@ -15,7 +15,8 @@
 #include <linux/kmod.h>
 #include <linux/kobj_map.h>
 
-#define MAX_PROBE_HASH 255	/* random */
+/* degrade to linked list for small systems */
+#define MAX_PROBE_HASH (CONFIG_BASE_SMALL ? 1 : 255)
 
 static struct subsystem block_subsys;
 
#3 lore raw

PATCH 3/8 base-small: shrink chrdevs hash

CONFIG_BASE_SMALL degrade char dev hash table to linked list

fs/char_dev.c +2 -1
Index: tq/fs/char_dev.c
===================================================================
@@ -26,7 +26,8 @@
 
 static struct kobj_map *cdev_map;
 
-#define MAX_PROBE_HASH 255	/* random */
+/* degrade to linked list for small systems */
+#define MAX_PROBE_HASH (CONFIG_BASE_SMALL ? 1 : 255)
 
 static DEFINE_RWLOCK(chrdevs_lock);
 
#4 lore raw

PATCH 4/8 base-small: shrink PID tables

CONFIG_BASE_SMALL reduce size of pidmap table for small machines

include/linux/threads.h +4 -3
Index: tq/include/linux/threads.h
===================================================================
@@ -7,7 +7,7 @@
  * The default limit for the nr of threads is now in
  * /proc/sys/kernel/threads-max.
  */
- 
+
 /*
  * Maximum supported processors that can run under SMP.  This value is
  * set via configure setting.  The maximum is equal to the size of the
@@ -25,11 +25,12 @@
 /*
  * This controls the default maximum pid allocated to a process
  */
-#define PID_MAX_DEFAULT 0x8000
+#define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)
 
 /*
  * A maximum of 4 million PIDs should be enough for a while:
  */
-#define PID_MAX_LIMIT (sizeof(long) > 4 ? 4*1024*1024 : PID_MAX_DEFAULT)
+#define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
+	(sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))
 
 #endif
#5 lore raw

PATCH 5/8 base-small: shrink UID hash

CONFIG_BASE_SMALL reduce UID lookup hash

kernel/user.c +2 -1
Index: tq/kernel/user.c
===================================================================
@@ -18,7 +18,8 @@
  * UID task count cache, to get fast user lookup in "alloc_uid"
  * when changing user ID's (ie setuid() and friends).
  */
-#define UIDHASH_BITS		8
+
+#define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
 #define UIDHASH_SZ		(1 << UIDHASH_BITS)
 #define UIDHASH_MASK		(UIDHASH_SZ - 1)
 #define __uidhashfn(uid)	(((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
#6 lore raw

PATCH 6/8 base-small: shrink futex queues

CONFIG_BASE_SMALL reduce futex hash table

kernel/futex.c +1 -1
Index: tq/kernel/futex.c
===================================================================
@@ -40,7 +40,7 @@
 #include <linux/pagemap.h>
 #include <linux/syscalls.h>
 
-#define FUTEX_HASHBITS 8
+#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
 
 /*
  * Futexes are matched on equal values of this key.
#7 lore raw

PATCH 7/8 base-small: shrink timer hashes

CONFIG_BASE_SMALL reduce timer list hashes

kernel/timer.c +3 -2
Index: mm2/kernel/timer.c
===================================================================
@@ -51,8 +51,9 @@
 /*
  * per-CPU timer vector definitions:
  */
-#define TVN_BITS 6
-#define TVR_BITS 8
+
+#define TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6)
+#define TVR_BITS (CONFIG_BASE_SMALL ? 6 : 8)
 #define TVN_SIZE (1 << TVN_BITS)
 #define TVR_SIZE (1 << TVR_BITS)
 #define TVN_MASK (TVN_SIZE - 1)
#8 lore raw

PATCH 8/8 base-small: shrink console buffer

CONFIG_BASE_SMALL reduce console transfer buffer

include/linux/vt_kern.h +2 -1
Index: mm2/include/linux/vt_kern.h
===================================================================
@@ -84,7 +84,8 @@
  * vc_screen.c shares this temporary buffer with the console write code so that
  * we can easily avoid touching user space while holding the console spinlock.
  */
-#define CON_BUF_SIZE	PAGE_SIZE
+
+#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
 extern char con_buf[CON_BUF_SIZE];
 extern struct semaphore con_buf_sem;
 
#9 lore raw
In reply to Matt Mackall
Quoted 5 lines · Matt Mackall

This patch series introduced a new pair of CONFIG_EMBEDDED options call CONFIG_BASE_FULL/CONFIG_BASE_SMALL. Disabling CONFIG_BASE_FULL sets the boolean CONFIG_BASE_SMALL to 1 and it is used to shrink a number of core data structures. The space savings for the current batch is around 14k.

Why _two_ config options?

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#10 lore raw
Quoted 8 lines · Horst von Brand
Quoted 5 lines · Matt Mackall

This patch series introduced a new pair of CONFIG_EMBEDDED options call CONFIG_BASE_FULL/CONFIG_BASE_SMALL. Disabling CONFIG_BASE_FULL sets the boolean CONFIG_BASE_SMALL to 1 and it is used to shrink a number of core data structures. The space savings for the current batch is around 14k.

Why _two_ config options?

Um, Andrew made me do it?

One option is an int and is used thusly:

#define FOO (CONFIG_BASE_SMALL ? 1 : 1000)

But it's also sometimes useful to have two opposing options so that you can use:

obj-(CONFIG_OBJ_A) += a.obj obj-(CONFIG_OBJ_B) += b.obj

Signature · 1 line
Mathematics is the supreme nostalgia of our time.