diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-07-16 02:38:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-16 12:05:36 -0400 |
commit | f0630fff54a239efbbd89faf6a62da071ef1ff78 (patch) | |
tree | 4004adc3adf4dbe1a6188ca0bbd56f7606d4d05f | |
parent | fc9a07e7bf1a76e710f5df017abb07628db1781d (diff) |
SLUB: support slub_debug on by default
Add a new configuration variable
CONFIG_SLUB_DEBUG_ON
If set then the kernel will be booted by default with slab debugging
switched on. Similar to CONFIG_SLAB_DEBUG. By default slab debugging
is available but must be enabled by specifying "slub_debug" as a
kernel parameter.
Also add support to switch off slab debugging for a kernel that was
built with CONFIG_SLUB_DEBUG_ON. This works by specifying
slub_debug=-
as a kernel parameter.
Dave Jones wanted this feature.
http://marc.info/?l=linux-kernel&m=118072189913045&w=2
[akpm@linux-foundation.org: clean up switch statement]
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/kernel-parameters.txt | 38 | ||||
-rw-r--r-- | Documentation/vm/slub.txt | 2 | ||||
-rw-r--r-- | lib/Kconfig.debug | 13 | ||||
-rw-r--r-- | mm/slub.c | 79 |
4 files changed, 87 insertions, 45 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 4344f69ae24a..8916410307f1 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1580,35 +1580,39 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1580 | 1580 | ||
1581 | slram= [HW,MTD] | 1581 | slram= [HW,MTD] |
1582 | 1582 | ||
1583 | slub_debug [MM, SLUB] | 1583 | slub_debug[=options[,slabs]] [MM, SLUB] |
1584 | Enabling slub_debug allows one to determine the culprit | 1584 | Enabling slub_debug allows one to determine the |
1585 | if slab objects become corrupted. Enabling slub_debug | 1585 | culprit if slab objects become corrupted. Enabling |
1586 | creates guard zones around objects and poisons objects | 1586 | slub_debug can create guard zones around objects and |
1587 | when not in use. Also tracks the last alloc / free. | 1587 | may poison objects when not in use. Also tracks the |
1588 | For more information see Documentation/vm/slub.txt. | 1588 | last alloc / free. For more information see |
1589 | Documentation/vm/slub.txt. | ||
1589 | 1590 | ||
1590 | slub_max_order= [MM, SLUB] | 1591 | slub_max_order= [MM, SLUB] |
1591 | Determines the maximum allowed order for slabs. Setting | 1592 | Determines the maximum allowed order for slabs. |
1592 | this too high may cause fragmentation. | 1593 | A high setting may cause OOMs due to memory |
1593 | For more information see Documentation/vm/slub.txt. | 1594 | fragmentation. For more information see |
1595 | Documentation/vm/slub.txt. | ||
1594 | 1596 | ||
1595 | slub_min_objects= [MM, SLUB] | 1597 | slub_min_objects= [MM, SLUB] |
1596 | The minimum objects per slab. SLUB will increase the | 1598 | The minimum number of objects per slab. SLUB will |
1597 | slab order up to slub_max_order to generate a | 1599 | increase the slab order up to slub_max_order to |
1598 | sufficiently big slab to satisfy the number of objects. | 1600 | generate a sufficiently large slab able to contain |
1599 | The higher the number of objects the smaller the overhead | 1601 | the number of objects indicated. The higher the number |
1600 | of tracking slabs. | 1602 | of objects the smaller the overhead of tracking slabs |
1603 | and the less frequently locks need to be acquired. | ||
1601 | For more information see Documentation/vm/slub.txt. | 1604 | For more information see Documentation/vm/slub.txt. |
1602 | 1605 | ||
1603 | slub_min_order= [MM, SLUB] | 1606 | slub_min_order= [MM, SLUB] |
1604 | Determines the mininum page order for slabs. Must be | 1607 | Determines the mininum page order for slabs. Must be |
1605 | lower than slub_max_order | 1608 | lower than slub_max_order. |
1606 | For more information see Documentation/vm/slub.txt. | 1609 | For more information see Documentation/vm/slub.txt. |
1607 | 1610 | ||
1608 | slub_nomerge [MM, SLUB] | 1611 | slub_nomerge [MM, SLUB] |
1609 | Disable merging of slabs of similar size. May be | 1612 | Disable merging of slabs with similar size. May be |
1610 | necessary if there is some reason to distinguish | 1613 | necessary if there is some reason to distinguish |
1611 | allocs to different slabs. | 1614 | allocs to different slabs. Debug options disable |
1615 | merging on their own. | ||
1612 | For more information see Documentation/vm/slub.txt. | 1616 | For more information see Documentation/vm/slub.txt. |
1613 | 1617 | ||
1614 | smart2= [HW] | 1618 | smart2= [HW] |
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt index 1523320abd87..df812b03b65d 100644 --- a/Documentation/vm/slub.txt +++ b/Documentation/vm/slub.txt | |||
@@ -41,6 +41,8 @@ Possible debug options are | |||
41 | P Poisoning (object and padding) | 41 | P Poisoning (object and padding) |
42 | U User tracking (free and alloc) | 42 | U User tracking (free and alloc) |
43 | T Trace (please only use on single slabs) | 43 | T Trace (please only use on single slabs) |
44 | - Switch all debugging off (useful if the kernel is | ||
45 | configured with CONFIG_SLUB_DEBUG_ON) | ||
44 | 46 | ||
45 | F.e. in order to boot just with sanity checks and red zoning one would specify: | 47 | F.e. in order to boot just with sanity checks and red zoning one would specify: |
46 | 48 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index fab32a286371..640844024ffd 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -152,6 +152,19 @@ config DEBUG_SLAB_LEAK | |||
152 | bool "Memory leak debugging" | 152 | bool "Memory leak debugging" |
153 | depends on DEBUG_SLAB | 153 | depends on DEBUG_SLAB |
154 | 154 | ||
155 | config SLUB_DEBUG_ON | ||
156 | bool "SLUB debugging on by default" | ||
157 | depends on SLUB && SLUB_DEBUG | ||
158 | default n | ||
159 | help | ||
160 | Boot with debugging on by default. SLUB boots by default with | ||
161 | the runtime debug capabilities switched off. Enabling this is | ||
162 | equivalent to specifying the "slub_debug" parameter on boot. | ||
163 | There is no support for more fine grained debug control like | ||
164 | possible with slub_debug=xxx. SLUB debugging may be switched | ||
165 | off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying | ||
166 | "slub_debug=-". | ||
167 | |||
155 | config DEBUG_PREEMPT | 168 | config DEBUG_PREEMPT |
156 | bool "Debug preemptible kernel" | 169 | bool "Debug preemptible kernel" |
157 | depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT | 170 | depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT |
@@ -323,7 +323,11 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr) | |||
323 | /* | 323 | /* |
324 | * Debug settings: | 324 | * Debug settings: |
325 | */ | 325 | */ |
326 | #ifdef CONFIG_SLUB_DEBUG_ON | ||
327 | static int slub_debug = DEBUG_DEFAULT_FLAGS; | ||
328 | #else | ||
326 | static int slub_debug; | 329 | static int slub_debug; |
330 | #endif | ||
327 | 331 | ||
328 | static char *slub_debug_slabs; | 332 | static char *slub_debug_slabs; |
329 | 333 | ||
@@ -888,38 +892,57 @@ fail: | |||
888 | 892 | ||
889 | static int __init setup_slub_debug(char *str) | 893 | static int __init setup_slub_debug(char *str) |
890 | { | 894 | { |
891 | if (!str || *str != '=') | 895 | slub_debug = DEBUG_DEFAULT_FLAGS; |
892 | slub_debug = DEBUG_DEFAULT_FLAGS; | 896 | if (*str++ != '=' || !*str) |
893 | else { | 897 | /* |
894 | str++; | 898 | * No options specified. Switch on full debugging. |
895 | if (*str == 0 || *str == ',') | 899 | */ |
896 | slub_debug = DEBUG_DEFAULT_FLAGS; | 900 | goto out; |
897 | else | 901 | |
898 | for( ;*str && *str != ','; str++) | 902 | if (*str == ',') |
899 | switch (*str) { | 903 | /* |
900 | case 'f' : case 'F' : | 904 | * No options but restriction on slabs. This means full |
901 | slub_debug |= SLAB_DEBUG_FREE; | 905 | * debugging for slabs matching a pattern. |
902 | break; | 906 | */ |
903 | case 'z' : case 'Z' : | 907 | goto check_slabs; |
904 | slub_debug |= SLAB_RED_ZONE; | 908 | |
905 | break; | 909 | slub_debug = 0; |
906 | case 'p' : case 'P' : | 910 | if (*str == '-') |
907 | slub_debug |= SLAB_POISON; | 911 | /* |
908 | break; | 912 | * Switch off all debugging measures. |
909 | case 'u' : case 'U' : | 913 | */ |
910 | slub_debug |= SLAB_STORE_USER; | 914 | goto out; |
911 | break; | 915 | |
912 | case 't' : case 'T' : | 916 | /* |
913 | slub_debug |= SLAB_TRACE; | 917 | * Determine which debug features should be switched on |
914 | break; | 918 | */ |
915 | default: | 919 | for ( ;*str && *str != ','; str++) { |
916 | printk(KERN_ERR "slub_debug option '%c' " | 920 | switch (tolower(*str)) { |
917 | "unknown. skipped\n",*str); | 921 | case 'f': |
918 | } | 922 | slub_debug |= SLAB_DEBUG_FREE; |
923 | break; | ||
924 | case 'z': | ||
925 | slub_debug |= SLAB_RED_ZONE; | ||
926 | break; | ||
927 | case 'p': | ||
928 | slub_debug |= SLAB_POISON; | ||
929 | break; | ||
930 | case 'u': | ||
931 | slub_debug |= SLAB_STORE_USER; | ||
932 | break; | ||
933 | case 't': | ||
934 | slub_debug |= SLAB_TRACE; | ||
935 | break; | ||
936 | default: | ||
937 | printk(KERN_ERR "slub_debug option '%c' " | ||
938 | "unknown. skipped\n",*str); | ||
939 | } | ||
919 | } | 940 | } |
920 | 941 | ||
942 | check_slabs: | ||
921 | if (*str == ',') | 943 | if (*str == ',') |
922 | slub_debug_slabs = str + 1; | 944 | slub_debug_slabs = str + 1; |
945 | out: | ||
923 | return 1; | 946 | return 1; |
924 | } | 947 | } |
925 | 948 | ||