The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/mm/failslab.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: f414efced042bbb1deffb8543c877ef2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.