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