]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - mm/failslab.c
1 #include <linux/fault-inject.h>
2 #include <linux/slab.h>
7 struct fault_attr attr
;
8 bool ignore_gfp_reclaim
;
11 .attr
= FAULT_ATTR_INITIALIZER
,
12 .ignore_gfp_reclaim
= true,
13 .cache_filter
= false,
16 bool should_failslab(struct kmem_cache
*s
, gfp_t gfpflags
)
18 /* No fault-injection for bootstrap cache */
19 if (unlikely(s
== kmem_cache
))
22 if (gfpflags
& __GFP_NOFAIL
)
25 if (failslab
.ignore_gfp_reclaim
&& (gfpflags
& __GFP_RECLAIM
))
28 if (failslab
.cache_filter
&& !(s
->flags
& SLAB_FAILSLAB
))
31 return should_fail(&failslab
.attr
, s
->object_size
);
34 static int __init
setup_failslab(char *str
)
36 return setup_fault_attr(&failslab
.attr
, str
);
38 __setup("failslab=", setup_failslab
);
40 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
41 static int __init
failslab_debugfs_init(void)
44 umode_t mode
= S_IFREG
| S_IRUSR
| S_IWUSR
;
46 dir
= fault_create_debugfs_attr("failslab", NULL
, &failslab
.attr
);
50 if (!debugfs_create_bool("ignore-gfp-wait", mode
, dir
,
51 &failslab
.ignore_gfp_reclaim
))
53 if (!debugfs_create_bool("cache-filter", mode
, dir
,
54 &failslab
.cache_filter
))
59 debugfs_remove_recursive(dir
);
64 late_initcall(failslab_debugfs_init
);
66 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */