Lines Matching refs:attr
19 int setup_fault_attr(struct fault_attr *attr, char *str) in setup_fault_attr() argument
34 attr->probability = probability; in setup_fault_attr()
35 attr->interval = interval; in setup_fault_attr()
36 atomic_set(&attr->times, times); in setup_fault_attr()
37 atomic_set(&attr->space, space); in setup_fault_attr()
43 static void fail_dump(struct fault_attr *attr) in fail_dump() argument
45 if (attr->verbose > 0 && __ratelimit(&attr->ratelimit_state)) { in fail_dump()
48 "space %d, times %d\n", attr->dname, in fail_dump()
49 attr->interval, attr->probability, in fail_dump()
50 atomic_read(&attr->space), in fail_dump()
51 atomic_read(&attr->times)); in fail_dump()
52 if (attr->verbose > 1) in fail_dump()
59 static bool fail_task(struct fault_attr *attr, struct task_struct *task) in fail_task() argument
68 static bool fail_stacktrace(struct fault_attr *attr) in fail_stacktrace() argument
70 int depth = attr->stacktrace_depth; in fail_stacktrace()
73 bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX); in fail_stacktrace()
75 if (depth == 0 || (found && !attr->reject_start && !attr->reject_end)) in fail_stacktrace()
80 if (attr->reject_start <= entries[n] && in fail_stacktrace()
81 entries[n] < attr->reject_end) in fail_stacktrace()
83 if (attr->require_start <= entries[n] && in fail_stacktrace()
84 entries[n] < attr->require_end) in fail_stacktrace()
92 static inline bool fail_stacktrace(struct fault_attr *attr) in fail_stacktrace() argument
104 bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) in should_fail_ex() argument
112 if (!fail_stacktrace(attr)) in should_fail_ex()
126 if (attr->probability == 0) in should_fail_ex()
129 if (attr->task_filter && !fail_task(attr, current)) in should_fail_ex()
132 if (atomic_read(&attr->times) == 0) in should_fail_ex()
135 if (!stack_checked && !fail_stacktrace(attr)) in should_fail_ex()
138 if (atomic_read(&attr->space) > size) { in should_fail_ex()
139 atomic_sub(size, &attr->space); in should_fail_ex()
143 if (attr->interval > 1) { in should_fail_ex()
144 attr->count++; in should_fail_ex()
145 if (attr->count % attr->interval) in should_fail_ex()
149 if (attr->probability <= get_random_u32_below(100)) in should_fail_ex()
154 fail_dump(attr); in should_fail_ex()
156 if (atomic_read(&attr->times) != -1) in should_fail_ex()
157 atomic_dec_not_zero(&attr->times); in should_fail_ex()
162 bool should_fail(struct fault_attr *attr, ssize_t size) in should_fail() argument
164 return should_fail_ex(attr, size, 0); in should_fail()
213 struct dentry *parent, struct fault_attr *attr) in fault_create_debugfs_attr() argument
222 debugfs_create_ul("probability", mode, dir, &attr->probability); in fault_create_debugfs_attr()
223 debugfs_create_ul("interval", mode, dir, &attr->interval); in fault_create_debugfs_attr()
224 debugfs_create_atomic_t("times", mode, dir, &attr->times); in fault_create_debugfs_attr()
225 debugfs_create_atomic_t("space", mode, dir, &attr->space); in fault_create_debugfs_attr()
226 debugfs_create_ul("verbose", mode, dir, &attr->verbose); in fault_create_debugfs_attr()
228 &attr->ratelimit_state.interval); in fault_create_debugfs_attr()
230 &attr->ratelimit_state.burst); in fault_create_debugfs_attr()
231 debugfs_create_bool("task-filter", mode, dir, &attr->task_filter); in fault_create_debugfs_attr()
235 &attr->stacktrace_depth); in fault_create_debugfs_attr()
236 debugfs_create_xul("require-start", mode, dir, &attr->require_start); in fault_create_debugfs_attr()
237 debugfs_create_xul("require-end", mode, dir, &attr->require_end); in fault_create_debugfs_attr()
238 debugfs_create_xul("reject-start", mode, dir, &attr->reject_start); in fault_create_debugfs_attr()
239 debugfs_create_xul("reject-end", mode, dir, &attr->reject_end); in fault_create_debugfs_attr()
242 attr->dname = dget(dir); in fault_create_debugfs_attr()
342 return fault_##TYPE##_attr_show(to_fault_config(item)->attr.MEMBER, page); \
347 return fault_##TYPE##_attr_store(&config->attr.MEMBER, page, count); \
369 return fault_ulong_attr_show(to_fault_config(item)->attr.stacktrace_depth, page); in fault_stacktrace_depth_show()
382 to_fault_config(item)->attr.stacktrace_depth = in fault_stacktrace_depth_store()