~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/fault-inject.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_FAULT_INJECT_H
  3 #define _LINUX_FAULT_INJECT_H
  4 
  5 #ifdef CONFIG_FAULT_INJECTION
  6 
  7 #include <linux/types.h>
  8 #include <linux/debugfs.h>
  9 #include <linux/configfs.h>
 10 #include <linux/ratelimit.h>
 11 #include <linux/atomic.h>
 12 
 13 /*
 14  * For explanation of the elements of this struct, see
 15  * Documentation/fault-injection/fault-injection.rst
 16  */
 17 struct fault_attr {
 18         unsigned long probability;
 19         unsigned long interval;
 20         atomic_t times;
 21         atomic_t space;
 22         unsigned long verbose;
 23         bool task_filter;
 24         unsigned long stacktrace_depth;
 25         unsigned long require_start;
 26         unsigned long require_end;
 27         unsigned long reject_start;
 28         unsigned long reject_end;
 29 
 30         unsigned long count;
 31         struct ratelimit_state ratelimit_state;
 32         struct dentry *dname;
 33 };
 34 
 35 enum fault_flags {
 36         FAULT_NOWARN =  1 << 0,
 37 };
 38 
 39 #define FAULT_ATTR_INITIALIZER {                                        \
 40                 .interval = 1,                                          \
 41                 .times = ATOMIC_INIT(1),                                \
 42                 .require_end = ULONG_MAX,                               \
 43                 .stacktrace_depth = 32,                                 \
 44                 .ratelimit_state = RATELIMIT_STATE_INIT_DISABLED,       \
 45                 .verbose = 2,                                           \
 46                 .dname = NULL,                                          \
 47         }
 48 
 49 #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
 50 int setup_fault_attr(struct fault_attr *attr, char *str);
 51 bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags);
 52 bool should_fail(struct fault_attr *attr, ssize_t size);
 53 
 54 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
 55 
 56 struct dentry *fault_create_debugfs_attr(const char *name,
 57                         struct dentry *parent, struct fault_attr *attr);
 58 
 59 #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
 60 
 61 static inline struct dentry *fault_create_debugfs_attr(const char *name,
 62                         struct dentry *parent, struct fault_attr *attr)
 63 {
 64         return ERR_PTR(-ENODEV);
 65 }
 66 
 67 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
 68 
 69 #ifdef CONFIG_FAULT_INJECTION_CONFIGFS
 70 
 71 struct fault_config {
 72         struct fault_attr attr;
 73         struct config_group group;
 74 };
 75 
 76 void fault_config_init(struct fault_config *config, const char *name);
 77 
 78 #else /* CONFIG_FAULT_INJECTION_CONFIGFS */
 79 
 80 struct fault_config {
 81 };
 82 
 83 static inline void fault_config_init(struct fault_config *config,
 84                         const char *name)
 85 {
 86 }
 87 
 88 #endif /* CONFIG_FAULT_INJECTION_CONFIGFS */
 89 
 90 #endif /* CONFIG_FAULT_INJECTION */
 91 
 92 struct kmem_cache;
 93 
 94 #ifdef CONFIG_FAIL_PAGE_ALLOC
 95 bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
 96 #else
 97 static inline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
 98 {
 99         return false;
100 }
101 #endif /* CONFIG_FAIL_PAGE_ALLOC */
102 
103 #ifdef CONFIG_FAILSLAB
104 int should_failslab(struct kmem_cache *s, gfp_t gfpflags);
105 #else
106 static inline int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
107 {
108         return false;
109 }
110 #endif /* CONFIG_FAILSLAB */
111 
112 #endif /* _LINUX_FAULT_INJECT_H */
113 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php