aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2008-12-29 04:47:05 -0500
committerPekka Enberg <penberg@cs.helsinki.fi>2008-12-29 04:47:05 -0500
commit3c506efd7e0f615bd9603ce8c06bc4a896952599 (patch)
tree6ebc840535e9d93bf60e21e940a5f4558275a89d /mm/slab.c
parentfd37617e69fb865348d012eb1413aef0141ae2de (diff)
parent773ff60e841461cb1f9374a713ffcda029b8c317 (diff)
Merge branch 'topic/failslab' into for-linus
Conflicts: mm/slub.c Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c75
1 files changed, 5 insertions, 70 deletions
diff --git a/mm/slab.c b/mm/slab.c
index cb2e411d93a9..f97e564bdf11 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3108,79 +3108,14 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3108#define cache_alloc_debugcheck_after(a,b,objp,d) (objp) 3108#define cache_alloc_debugcheck_after(a,b,objp,d) (objp)
3109#endif 3109#endif
3110 3110
3111#ifdef CONFIG_FAILSLAB 3111static bool slab_should_failslab(struct kmem_cache *cachep, gfp_t flags)
3112
3113static struct failslab_attr {
3114
3115 struct fault_attr attr;
3116
3117 u32 ignore_gfp_wait;
3118#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
3119 struct dentry *ignore_gfp_wait_file;
3120#endif
3121
3122} failslab = {
3123 .attr = FAULT_ATTR_INITIALIZER,
3124 .ignore_gfp_wait = 1,
3125};
3126
3127static int __init setup_failslab(char *str)
3128{
3129 return setup_fault_attr(&failslab.attr, str);
3130}
3131__setup("failslab=", setup_failslab);
3132
3133static int should_failslab(struct kmem_cache *cachep, gfp_t flags)
3134{ 3112{
3135 if (cachep == &cache_cache) 3113 if (cachep == &cache_cache)
3136 return 0; 3114 return false;
3137 if (flags & __GFP_NOFAIL)
3138 return 0;
3139 if (failslab.ignore_gfp_wait && (flags & __GFP_WAIT))
3140 return 0;
3141 3115
3142 return should_fail(&failslab.attr, obj_size(cachep)); 3116 return should_failslab(obj_size(cachep), flags);
3143} 3117}
3144 3118
3145#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
3146
3147static int __init failslab_debugfs(void)
3148{
3149 mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
3150 struct dentry *dir;
3151 int err;
3152
3153 err = init_fault_attr_dentries(&failslab.attr, "failslab");
3154 if (err)
3155 return err;
3156 dir = failslab.attr.dentries.dir;
3157
3158 failslab.ignore_gfp_wait_file =
3159 debugfs_create_bool("ignore-gfp-wait", mode, dir,
3160 &failslab.ignore_gfp_wait);
3161
3162 if (!failslab.ignore_gfp_wait_file) {
3163 err = -ENOMEM;
3164 debugfs_remove(failslab.ignore_gfp_wait_file);
3165 cleanup_fault_attr_dentries(&failslab.attr);
3166 }
3167
3168 return err;
3169}
3170
3171late_initcall(failslab_debugfs);
3172
3173#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
3174
3175#else /* CONFIG_FAILSLAB */
3176
3177static inline int should_failslab(struct kmem_cache *cachep, gfp_t flags)
3178{
3179 return 0;
3180}
3181
3182#endif /* CONFIG_FAILSLAB */
3183
3184static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags) 3119static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
3185{ 3120{
3186 void *objp; 3121 void *objp;
@@ -3383,7 +3318,7 @@ __cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
3383 unsigned long save_flags; 3318 unsigned long save_flags;
3384 void *ptr; 3319 void *ptr;
3385 3320
3386 if (should_failslab(cachep, flags)) 3321 if (slab_should_failslab(cachep, flags))
3387 return NULL; 3322 return NULL;
3388 3323
3389 cache_alloc_debugcheck_before(cachep, flags); 3324 cache_alloc_debugcheck_before(cachep, flags);
@@ -3459,7 +3394,7 @@ __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
3459 unsigned long save_flags; 3394 unsigned long save_flags;
3460 void *objp; 3395 void *objp;
3461 3396
3462 if (should_failslab(cachep, flags)) 3397 if (slab_should_failslab(cachep, flags))
3463 return NULL; 3398 return NULL;
3464 3399
3465 cache_alloc_debugcheck_before(cachep, flags); 3400 cache_alloc_debugcheck_before(cachep, flags);