2005-01-31 07:25:58

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 0/8] 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.


2005-01-31 07:28:25

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 2/8] base-small: shrink major_names hash

CONFIG_BASE_SMALL degrade genhd major names hash to linked list

Signed-off-by: Matt Mackall <[email protected]>

Index: tq/drivers/block/genhd.c
===================================================================
--- tq.orig/drivers/block/genhd.c 2005-01-26 13:06:16.000000000 -0800
+++ tq/drivers/block/genhd.c 2005-01-26 13:08:23.000000000 -0800
@@ -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;

2005-01-31 07:28:29

by Matt Mackall

[permalink] [raw]
Subject: [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.

Signed-off-by: Matt Mackall <[email protected]>

Index: mm2/init/Kconfig
===================================================================
--- mm2.orig/init/Kconfig 2005-01-30 21:26:29.000000000 -0800
+++ mm2/init/Kconfig 2005-01-30 21:51:08.000000000 -0800
@@ -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

2005-01-31 07:32:31

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 3/8] base-small: shrink chrdevs hash

CONFIG_BASE_SMALL degrade char dev hash table to linked list

Signed-off-by: Matt Mackall <[email protected]>

Index: tq/fs/char_dev.c
===================================================================
--- tq.orig/fs/char_dev.c 2005-01-26 13:06:15.000000000 -0800
+++ tq/fs/char_dev.c 2005-01-26 13:08:37.000000000 -0800
@@ -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);

2005-01-31 07:32:30

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 5/8] base-small: shrink UID hash

CONFIG_BASE_SMALL reduce UID lookup hash

Signed-off-by: Matt Mackall <[email protected]>

Index: tq/kernel/user.c
===================================================================
--- tq.orig/kernel/user.c 2005-01-25 09:31:58.000000000 -0800
+++ tq/kernel/user.c 2005-01-26 13:11:10.000000000 -0800
@@ -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)

2005-01-31 07:32:36

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 4/8] base-small: shrink PID tables

CONFIG_BASE_SMALL reduce size of pidmap table for small machines

Signed-off-by: Matt Mackall <[email protected]>

Index: tq/include/linux/threads.h
===================================================================
--- tq.orig/include/linux/threads.h 2005-01-25 09:26:16.000000000 -0800
+++ tq/include/linux/threads.h 2005-01-26 15:16:55.000000000 -0800
@@ -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

2005-01-31 07:32:33

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 7/8] base-small: shrink timer hashes

CONFIG_BASE_SMALL reduce timer list hashes

Signed-off-by: Matt Mackall <[email protected]>

Index: mm2/kernel/timer.c
===================================================================
--- mm2.orig/kernel/timer.c 2005-01-30 21:26:28.000000000 -0800
+++ mm2/kernel/timer.c 2005-01-30 21:51:16.000000000 -0800
@@ -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)

2005-01-31 07:32:32

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 8/8] base-small: shrink console buffer

CONFIG_BASE_SMALL reduce console transfer buffer

Signed-off-by: Matt Mackall <[email protected]>

Index: mm2/include/linux/vt_kern.h
===================================================================
--- mm2.orig/include/linux/vt_kern.h 2005-01-30 21:26:28.000000000 -0800
+++ mm2/include/linux/vt_kern.h 2005-01-30 21:51:19.000000000 -0800
@@ -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;

2005-01-31 07:28:30

by Matt Mackall

[permalink] [raw]
Subject: [PATCH 6/8] base-small: shrink futex queues

CONFIG_BASE_SMALL reduce futex hash table

Signed-off-by: Matt Mackall <[email protected]>

Index: tq/kernel/futex.c
===================================================================
--- tq.orig/kernel/futex.c 2005-01-25 09:26:18.000000000 -0800
+++ tq/kernel/futex.c 2005-01-26 13:11:43.000000000 -0800
@@ -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.

2005-02-01 04:03:26

by Horst H. von Brand

[permalink] [raw]
Subject: Re: [PATCH 0/8] base-small: CONFIG_BASE_SMALL for small systems

Matt Mackall <[email protected]> said:
> 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?
--
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

2005-02-01 04:19:14

by Matt Mackall

[permalink] [raw]
Subject: Re: [PATCH 0/8] base-small: CONFIG_BASE_SMALL for small systems

On Mon, Jan 31, 2005 at 09:55:32PM -0300, Horst von Brand wrote:
> Matt Mackall <[email protected]> said:
> > 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

--
Mathematics is the supreme nostalgia of our time.