aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2010-02-26 01:36:12 -0500
committerPekka Enberg <penberg@cs.helsinki.fi>2010-02-26 12:19:39 -0500
commit4c13dd3b48fcb6fbe44f241eb11a057ecd1cba75 (patch)
treed9875477b9eb48ad598da8cbc36b473c941828ae /mm/slub.c
parent60b341b778cc2929df16c0a504c91621b3c6a4ad (diff)
failslab: add ability to filter slab caches
This patch allow to inject faults only for specific slabs. In order to preserve default behavior cache filter is off by default (all caches are faulty). One may define specific set of slabs like this: # mark skbuff_head_cache as faulty echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab # Turn on cache filter (off by default) echo 1 > /sys/kernel/debug/failslab/cache-filter # Turn on fault injection echo 1 > /sys/kernel/debug/failslab/times echo 1 > /sys/kernel/debug/failslab/probability Acked-by: David Rientjes <rientjes@google.com> Acked-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Christoph Lameter <cl@linux-foundation.org> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 8d71aaf888d7..cab5288736c8 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -151,7 +151,8 @@
151 * Set of flags that will prevent slab merging 151 * Set of flags that will prevent slab merging
152 */ 152 */
153#define SLUB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ 153#define SLUB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
154 SLAB_TRACE | SLAB_DESTROY_BY_RCU | SLAB_NOLEAKTRACE) 154 SLAB_TRACE | SLAB_DESTROY_BY_RCU | SLAB_NOLEAKTRACE | \
155 SLAB_FAILSLAB)
155 156
156#define SLUB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_RECLAIM_ACCOUNT | \ 157#define SLUB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_RECLAIM_ACCOUNT | \
157 SLAB_CACHE_DMA | SLAB_NOTRACK) 158 SLAB_CACHE_DMA | SLAB_NOTRACK)
@@ -1020,6 +1021,9 @@ static int __init setup_slub_debug(char *str)
1020 case 't': 1021 case 't':
1021 slub_debug |= SLAB_TRACE; 1022 slub_debug |= SLAB_TRACE;
1022 break; 1023 break;
1024 case 'a':
1025 slub_debug |= SLAB_FAILSLAB;
1026 break;
1023 default: 1027 default:
1024 printk(KERN_ERR "slub_debug option '%c' " 1028 printk(KERN_ERR "slub_debug option '%c' "
1025 "unknown. skipped\n", *str); 1029 "unknown. skipped\n", *str);
@@ -1718,7 +1722,7 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
1718 lockdep_trace_alloc(gfpflags); 1722 lockdep_trace_alloc(gfpflags);
1719 might_sleep_if(gfpflags & __GFP_WAIT); 1723 might_sleep_if(gfpflags & __GFP_WAIT);
1720 1724
1721 if (should_failslab(s->objsize, gfpflags)) 1725 if (should_failslab(s->objsize, gfpflags, s->flags))
1722 return NULL; 1726 return NULL;
1723 1727
1724 local_irq_save(flags); 1728 local_irq_save(flags);
@@ -4171,6 +4175,23 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
4171} 4175}
4172SLAB_ATTR(trace); 4176SLAB_ATTR(trace);
4173 4177
4178#ifdef CONFIG_FAILSLAB
4179static ssize_t failslab_show(struct kmem_cache *s, char *buf)
4180{
4181 return sprintf(buf, "%d\n", !!(s->flags & SLAB_FAILSLAB));
4182}
4183
4184static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
4185 size_t length)
4186{
4187 s->flags &= ~SLAB_FAILSLAB;
4188 if (buf[0] == '1')
4189 s->flags |= SLAB_FAILSLAB;
4190 return length;
4191}
4192SLAB_ATTR(failslab);
4193#endif
4194
4174static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf) 4195static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf)
4175{ 4196{
4176 return sprintf(buf, "%d\n", !!(s->flags & SLAB_RECLAIM_ACCOUNT)); 4197 return sprintf(buf, "%d\n", !!(s->flags & SLAB_RECLAIM_ACCOUNT));
@@ -4467,6 +4488,10 @@ static struct attribute *slab_attrs[] = {
4467 &deactivate_remote_frees_attr.attr, 4488 &deactivate_remote_frees_attr.attr,
4468 &order_fallback_attr.attr, 4489 &order_fallback_attr.attr,
4469#endif 4490#endif
4491#ifdef CONFIG_FAILSLAB
4492 &failslab_attr.attr,
4493#endif
4494
4470 NULL 4495 NULL
4471}; 4496};
4472 4497