Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/mm/failslab.c

  1 #include <linux/fault-inject.h>
  2 #include <linux/slab.h>
  3 #include <linux/mm.h>
  4 #include "slab.h"
  5 
  6 static struct {
  7         struct fault_attr attr;
  8         bool ignore_gfp_reclaim;
  9         bool cache_filter;
 10 } failslab = {
 11         .attr = FAULT_ATTR_INITIALIZER,
 12         .ignore_gfp_reclaim = true,
 13         .cache_filter = false,
 14 };
 15 
 16 bool should_failslab(struct kmem_cache *s, gfp_t gfpflags)
 17 {
 18         /* No fault-injection for bootstrap cache */
 19         if (unlikely(s == kmem_cache))
 20                 return false;
 21 
 22         if (gfpflags & __GFP_NOFAIL)
 23                 return false;
 24 
 25         if (failslab.ignore_gfp_reclaim && (gfpflags & __GFP_RECLAIM))
 26                 return false;
 27 
 28         if (failslab.cache_filter && !(s->flags & SLAB_FAILSLAB))
 29                 return false;
 30 
 31         return should_fail(&failslab.attr, s->object_size);
 32 }
 33 
 34 static int __init setup_failslab(char *str)
 35 {
 36         return setup_fault_attr(&failslab.attr, str);
 37 }
 38 __setup("failslab=", setup_failslab);
 39 
 40 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
 41 static int __init failslab_debugfs_init(void)
 42 {
 43         struct dentry *dir;
 44         umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
 45 
 46         dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr);
 47         if (IS_ERR(dir))
 48                 return PTR_ERR(dir);
 49 
 50         if (!debugfs_create_bool("ignore-gfp-wait", mode, dir,
 51                                 &failslab.ignore_gfp_reclaim))
 52                 goto fail;
 53         if (!debugfs_create_bool("cache-filter", mode, dir,
 54                                 &failslab.cache_filter))
 55                 goto fail;
 56 
 57         return 0;
 58 fail:
 59         debugfs_remove_recursive(dir);
 60 
 61         return -ENOMEM;
 62 }
 63 
 64 late_initcall(failslab_debugfs_init);
 65 
 66 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
 67 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us