tipc: Increase frequency of load distribution over broadcast link
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / mm / failslab.c
blobbb41f98dd8b700d7ecf1765aa7e76e6cbd6ad97a
1 #include <linux/fault-inject.h>
2 #include <linux/gfp.h>
3 #include <linux/slab.h>
5 static struct {
6 struct fault_attr attr;
7 u32 ignore_gfp_wait;
8 int cache_filter;
9 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
10 struct dentry *ignore_gfp_wait_file;
11 struct dentry *cache_filter_file;
12 #endif
13 } failslab = {
14 .attr = FAULT_ATTR_INITIALIZER,
15 .ignore_gfp_wait = 1,
16 .cache_filter = 0,
19 bool should_failslab(size_t size, gfp_t gfpflags, unsigned long cache_flags)
21 if (gfpflags & __GFP_NOFAIL)
22 return false;
24 if (failslab.ignore_gfp_wait && (gfpflags & __GFP_WAIT))
25 return false;
27 if (failslab.cache_filter && !(cache_flags & SLAB_FAILSLAB))
28 return false;
30 return should_fail(&failslab.attr, size);
33 static int __init setup_failslab(char *str)
35 return setup_fault_attr(&failslab.attr, str);
37 __setup("failslab=", setup_failslab);
39 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
40 static int __init failslab_debugfs_init(void)
42 mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
43 struct dentry *dir;
44 int err;
46 err = init_fault_attr_dentries(&failslab.attr, "failslab");
47 if (err)
48 return err;
49 dir = failslab.attr.dentries.dir;
51 failslab.ignore_gfp_wait_file =
52 debugfs_create_bool("ignore-gfp-wait", mode, dir,
53 &failslab.ignore_gfp_wait);
55 failslab.cache_filter_file =
56 debugfs_create_bool("cache-filter", mode, dir,
57 &failslab.cache_filter);
59 if (!failslab.ignore_gfp_wait_file ||
60 !failslab.cache_filter_file) {
61 err = -ENOMEM;
62 debugfs_remove(failslab.cache_filter_file);
63 debugfs_remove(failslab.ignore_gfp_wait_file);
64 cleanup_fault_attr_dentries(&failslab.attr);
67 return err;
70 late_initcall(failslab_debugfs_init);
72 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */