This set of patches introduces a new config option CONFIG_CORE_SMALL
from the -tiny tree for small systems. This series should apply
cleanly against 2.6.11-rc1-mm2.
When selected, it enables various tweaks to miscellaneous core data
structures to shrink their size on small systems. While each tweak is
fairly small, in aggregate they can save a substantial amount of
memory.
1 Add option to embedded menu
2 Collapse major names hash
3 Collapse chrdevs hash
4 Shrink PID lookup tables
5 Shrink uid hash
6 Shrink futex queue hash
7 Shrink timer lists
8 Shrink console buffer
CONFIG_CORE_SMALL reduce UID lookup hash
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny/kernel/user.c
===================================================================
--- tiny.orig/kernel/user.c 2004-12-04 15:42:41.000000000 -0800
+++ tiny/kernel/user.c 2004-12-04 19:42:32.462123939 -0800
@@ -18,7 +18,11 @@
* UID task count cache, to get fast user lookup in "alloc_uid"
* when changing user ID's (ie setuid() and friends).
*/
+#ifdef CONFIG_CORE_SMALL
+#define UIDHASH_BITS 3
+#else
#define UIDHASH_BITS 8
+#endif
#define UIDHASH_SZ (1 << UIDHASH_BITS)
#define UIDHASH_MASK (UIDHASH_SZ - 1)
#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
CONFIG_CORE_SMALL degrade char dev hash table to linked list
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny-queue/fs/char_dev.c
===================================================================
--- tiny-queue.orig/fs/char_dev.c 2005-01-21 09:59:45.000000000 -0800
+++ tiny-queue/fs/char_dev.c 2005-01-21 15:31:52.000000000 -0800
@@ -26,7 +26,11 @@
static struct kobj_map *cdev_map;
+#ifdef CONFIG_CORE_SMALL
+#define MAX_PROBE_HASH 1 /* degrade to linked list */
+#else
#define MAX_PROBE_HASH 255 /* random */
+#endif
static DEFINE_RWLOCK(chrdevs_lock);
CONFIG_CORE_SMALL reduce timer list hashes
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny-queue/kernel/timer.c
===================================================================
--- tiny-queue.orig/kernel/timer.c 2005-01-21 09:59:50.000000000 -0800
+++ tiny-queue/kernel/timer.c 2005-01-21 15:31:58.000000000 -0800
@@ -50,8 +50,14 @@
/*
* per-CPU timer vector definitions:
*/
+
+#ifdef CONFIG_CORE_SMALL
+#define TVN_BITS 4
+#define TVR_BITS 6
+#else
#define TVN_BITS 6
#define TVR_BITS 8
+#endif
#define TVN_SIZE (1 << TVN_BITS)
#define TVR_SIZE (1 << TVR_BITS)
#define TVN_MASK (TVN_SIZE - 1)
CONFIG_CORE_SMALL reduce console transfer buffer
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny-queue/include/linux/vt_kern.h
===================================================================
--- tiny-queue.orig/include/linux/vt_kern.h 2005-01-21 09:59:49.000000000 -0800
+++ tiny-queue/include/linux/vt_kern.h 2005-01-21 15:48:39.000000000 -0800
@@ -84,7 +84,11 @@
* 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
+#ifdef CONFIG_CORE_SMALL
+#define CON_BUF_SIZE 512
+#else
+#define CON_BUF_SIZE PAGE_SIZE
+#endif
extern char con_buf[CON_BUF_SIZE];
extern struct semaphore con_buf_sem;
Add CONFIG_CORE_SMALL for miscellaneous core size that don't warrant
their own options. Example users to follow.
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny/init/Kconfig
===================================================================
--- tiny.orig/init/Kconfig 2004-12-04 15:42:40.394703286 -0800
+++ tiny/init/Kconfig 2004-12-04 19:24:36.404346070 -0800
@@ -287,6 +287,12 @@
reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
you wait for kallsyms to be fixed.
+config CORE_SMALL
+ default n
+ bool "Enable various size reductions for core" if EMBEDDED
+ help
+ This reduces the size of miscellaneous core kernel data structures.
+
config FUTEX
bool "Enable futex support" if EMBEDDED
default y
CONFIG_CORE_SMALL degrade genhd major names hash to linked list
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny-new/drivers/block/genhd.c
===================================================================
--- tiny-new.orig/drivers/block/genhd.c 2004-11-17 00:04:36.000000000 -0800
+++ tiny-new/drivers/block/genhd.c 2004-11-17 10:30:10.992098381 -0800
@@ -15,7 +15,11 @@
#include <linux/kmod.h>
#include <linux/kobj_map.h>
+#ifdef CONFIG_CORE_SMALL
+#define MAX_PROBE_HASH 1 /* degrade to linked list */
+#else
#define MAX_PROBE_HASH 255 /* random */
+#endif
static struct subsystem block_subsys;
CONFIG_CORE_SMALL reduce size of pidmap table for small machines
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny/include/linux/threads.h
===================================================================
--- tiny.orig/include/linux/threads.h 2004-12-04 15:42:35.000000000 -0800
+++ tiny/include/linux/threads.h 2004-12-04 19:42:19.032212529 -0800
@@ -25,11 +25,19 @@
/*
* This controls the default maximum pid allocated to a process
*/
+#ifdef CONFIG_CORE_SMALL
+#define PID_MAX_DEFAULT 0x1000
+#else
#define PID_MAX_DEFAULT 0x8000
+#endif
/*
* A maximum of 4 million PIDs should be enough for a while:
*/
+#ifdef CONFIG_CORE_SMALL
+#define PID_MAX_LIMIT (PAGE_SIZE*8) /* one pidmap entry */
+#else
#define PID_MAX_LIMIT (sizeof(long) > 4 ? 4*1024*1024 : PID_MAX_DEFAULT)
+#endif
#endif
CONFIG_CORE_SMALL reduce futex hash table
Signed-off-by: Matt Mackall <[email protected]>
Index: tiny-new/kernel/futex.c
===================================================================
--- tiny-new.orig/kernel/futex.c 2004-11-17 00:04:03.000000000 -0800
+++ tiny-new/kernel/futex.c 2004-11-17 10:30:20.749824672 -0800
@@ -40,7 +40,11 @@
#include <linux/pagemap.h>
#include <linux/syscalls.h>
+#ifdef CONFIG_CORE_SMALL
+#define FUTEX_HASHBITS 4
+#else
#define FUTEX_HASHBITS 8
+#endif
/*
* Futexes are matched on equal values of this key.
Matt Mackall <[email protected]> wrote:
>
> This set of patches introduces a new config option CONFIG_CORE_SMALL
> from the -tiny tree for small systems. This series should apply
> cleanly against 2.6.11-rc1-mm2.
>
> When selected, it enables various tweaks to miscellaneous core data
> structures to shrink their size on small systems. While each tweak is
> fairly small, in aggregate they can save a substantial amount of
> memory.
You know what I'm going to ask ;) How much memory?
I wish it didn't have "core" in the name. A little misleading.
Did you think of making CONFIG_CORE_SMALL an integer which has values zero
or one?
Then you can lose all those ifdefs:
#define MAX_PROBE_HASH (255 - CONFIG_CORE_SMALL * 254) /* dorky */
#define PID_MAX_DEFAULT (CONFIG_CORE_SMALL ? 0x1000 : 0x8000)
#define UIDHASH_BITS (CONFIG_CORE_SMALL ? 3 : 8)
#define FUTEX_HASHBITS (CONFIG_CORE_SMALL ? 4 : 8)
etc.
I think the ?: thing will work everywhere:
#define XX 1
char xx[XX ? 10 : 20];
even this works...
On Sun, Jan 23, 2005 at 12:40:42AM -0800, Andrew Morton wrote:
> Matt Mackall <[email protected]> wrote:
> >
> > This set of patches introduces a new config option CONFIG_CORE_SMALL
> > from the -tiny tree for small systems. This series should apply
> > cleanly against 2.6.11-rc1-mm2.
> >
> > When selected, it enables various tweaks to miscellaneous core data
> > structures to shrink their size on small systems. While each tweak is
> > fairly small, in aggregate they can save a substantial amount of
> > memory.
>
> You know what I'm going to ask ;) How much memory?
This stuff is mostly pretty small, a few K per patch. I think these 8
are about 40k total but my notes are several months old.
> I wish it didn't have "core" in the name. A little misleading.
Well I've got another set called NET_SMALL. BASE?
> Did you think of making CONFIG_CORE_SMALL an integer which has values zero
> or one?
>
> Then you can lose all those ifdefs:
>
> #define MAX_PROBE_HASH (255 - CONFIG_CORE_SMALL * 254) /* dorky */
Ew.
> #define PID_MAX_DEFAULT (CONFIG_CORE_SMALL ? 0x1000 : 0x8000)
> #define UIDHASH_BITS (CONFIG_CORE_SMALL ? 3 : 8)
> #define FUTEX_HASHBITS (CONFIG_CORE_SMALL ? 4 : 8)
> etc.
Hmm. I think we'd want a hidden config variable for this and I'm not
sure how well the config language allows setting an int from a bool.
And then it would need another name. On the whole, seems more complex
than what I've done.
--
Mathematics is the supreme nostalgia of our time.
Matt Mackall <[email protected]> wrote:
>
> > I wish it didn't have "core" in the name. A little misleading.
>
> Well I've got another set called NET_SMALL. BASE?
BASE works, I guess.
> > #define PID_MAX_DEFAULT (CONFIG_CORE_SMALL ? 0x1000 : 0x8000)
> > #define UIDHASH_BITS (CONFIG_CORE_SMALL ? 3 : 8)
> > #define FUTEX_HASHBITS (CONFIG_CORE_SMALL ? 4 : 8)
> > etc.
>
> Hmm. I think we'd want a hidden config variable for this and I'm not
> sure how well the config language allows setting an int from a bool.
config AKPM_BOOL
bool "akpm"
config AKPM_INT
int
default 1 if AKPM_BOOL
default 0 if !AKPM_BOOL
seems to do everything which it should.
> And then it would need another name. On the whole, seems more complex
> than what I've done.
No, it's quite simple and avoids lots of ifdeffing.
On Sun, Jan 23, 2005 at 01:05:14PM -0800, Andrew Morton wrote:
> Matt Mackall <[email protected]> wrote:
> >
> > > I wish it didn't have "core" in the name. A little misleading.
> >
> > Well I've got another set called NET_SMALL. BASE?
>
> BASE works, I guess.
>
> > > #define PID_MAX_DEFAULT (CONFIG_CORE_SMALL ? 0x1000 : 0x8000)
> > > #define UIDHASH_BITS (CONFIG_CORE_SMALL ? 3 : 8)
> > > #define FUTEX_HASHBITS (CONFIG_CORE_SMALL ? 4 : 8)
> > > etc.
> >
> > Hmm. I think we'd want a hidden config variable for this and I'm not
> > sure how well the config language allows setting an int from a bool.
>
> config AKPM_BOOL
> bool "akpm"
>
> config AKPM_INT
> int
> default 1 if AKPM_BOOL
> default 0 if !AKPM_BOOL
>
> seems to do everything which it should.
>
> > And then it would need another name. On the whole, seems more complex
> > than what I've done.
>
> No, it's quite simple and avoids lots of ifdeffing.
Ok, will respin these Monday.
--
Mathematics is the supreme nostalgia of our time.
On Sul, 2005-01-23 at 17:52, Matt Mackall wrote:
> > Then you can lose all those ifdefs:
> >
> > #define MAX_PROBE_HASH (255 - CONFIG_CORE_SMALL * 254) /* dorky */
>
> Ew.
#define SIZE_HASH(small, large) CONFIG_CORE_SMALL ? (small):(large)
Perhaps ?
Alan Cox wrote:
> #define SIZE_HASH(small, large) CONFIG_CORE_SMALL ? (small):(large)
I hate to be a "ditto-head", but I like this a lot.
=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Electronics
=============================