core-small: Introduce CONFIG_CORE_SMALL from -tiny
Subsystems (3)
cover core-small: Introduce CONFIG_CORE_SMALL from -tiny
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
PATCH 1/8 core-small: Add option to embedded menu
Add CONFIG_CORE_SMALL for miscellaneous core size that don't warrant their own options. Example users to follow.
init/Kconfig +6 -0
@@ -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
PATCH 2/8 core-small: Collapse major names hash
CONFIG_CORE_SMALL degrade genhd major names hash to linked list
drivers/block/genhd.c +4 -0
@@ -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;
PATCH 3/8 core-small: Collapse chrdevs hash
CONFIG_CORE_SMALL degrade char dev hash table to linked list
fs/char_dev.c +4 -0
@@ -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);
PATCH 4/8 core-small: Shrink PID lookup tables
CONFIG_CORE_SMALL reduce size of pidmap table for small machines
include/linux/threads.h +8 -0
@@ -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
PATCH 5/8 core-small: Shrink uid hash
CONFIG_CORE_SMALL reduce UID lookup hash
kernel/user.c +4 -0
@@ -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)
PATCH 6/8 core-small: Shrink futex queue hash
CONFIG_CORE_SMALL reduce futex hash table
kernel/futex.c +4 -0
@@ -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.
PATCH 7/8 core-small: Shrink timer lists
CONFIG_CORE_SMALL reduce timer list hashes
kernel/timer.c +6 -0
@@ -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)
PATCH 8/8 core-small: Shrink console buffer
CONFIG_CORE_SMALL reduce console transfer buffer
include/linux/vt_kern.h +5 -1
@@ -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;
Quoted 9 lines · Matt Mackall
This set of patches introduces a new config option
CONFIG_CORE_SMALLfrom 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...
Quoted 6 lines · Andrew Morton
Quoted 5 lines · Matt Mackall
This set of patches introduces a new config option
CONFIG_CORE_SMALLfrom the -tiny tree for small systems. This series should apply cleanly against 2.6.11-rc1-mm2.
Quoted 6 lines
Quoted 4 lines
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.
Quoted 1 line
I wish it didn't have "core" in the name. A little misleading.
Well I've got another set called NET_SMALL. BASE?
Quoted 6 lines
Did you think of making
CONFIG_CORE_SMALLan 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.
Quoted 4 lines
#define
PID_MAX_DEFAULT(CONFIG_CORE_SMALL?0x1000:0x8000) #defineUIDHASH_BITS(CONFIG_CORE_SMALL? 3 : 8) #defineFUTEX_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.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 4 lines · Matt Mackall
Quoted 2 lines
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.
Quoted 7 lines
Quoted 4 lines
#define
PID_MAX_DEFAULT(CONFIG_CORE_SMALL?0x1000:0x8000) #defineUIDHASH_BITS(CONFIG_CORE_SMALL? 3 : 8) #defineFUTEX_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.
Quoted 2 lines
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.
Quoted 24 lines · Andrew Morton
Quoted 4 lines · Matt Mackall
Quoted 2 lines
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.
Quoted 7 lines
Quoted 4 lines
#define
PID_MAX_DEFAULT(CONFIG_CORE_SMALL?0x1000:0x8000) #defineUIDHASH_BITS(CONFIG_CORE_SMALL? 3 : 8) #defineFUTEX_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 ifAKPM_BOOL
default 0 if !AKPM_BOOL
Quoted 6 lines
seems to do everything which it should.
Quoted 2 lines
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.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 5 lines · Matt Mackall
Quoted 3 lines
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 ?
Quoted 1 line · Alan Cox
#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
=============================