diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fault-inject.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 244782940349..5da665ac2d89 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -53,6 +53,8 @@ static bool fail_task(struct fault_attr *attr, struct task_struct *task) | |||
53 | return !in_interrupt() && task->make_it_fail; | 53 | return !in_interrupt() && task->make_it_fail; |
54 | } | 54 | } |
55 | 55 | ||
56 | #define MAX_STACK_TRACE_DEPTH 32 | ||
57 | |||
56 | #ifdef CONFIG_STACK_UNWIND | 58 | #ifdef CONFIG_STACK_UNWIND |
57 | 59 | ||
58 | static asmlinkage int fail_stacktrace_callback(struct unwind_frame_info *info, | 60 | static asmlinkage int fail_stacktrace_callback(struct unwind_frame_info *info, |
@@ -98,8 +100,7 @@ static bool fail_stacktrace(struct fault_attr *attr) | |||
98 | 100 | ||
99 | trace.nr_entries = 0; | 101 | trace.nr_entries = 0; |
100 | trace.entries = entries; | 102 | trace.entries = entries; |
101 | trace.max_entries = (depth < MAX_STACK_TRACE_DEPTH) ? | 103 | trace.max_entries = depth; |
102 | depth : MAX_STACK_TRACE_DEPTH; | ||
103 | trace.skip = 1; | 104 | trace.skip = 1; |
104 | trace.all_contexts = 0; | 105 | trace.all_contexts = 0; |
105 | 106 | ||
@@ -179,6 +180,13 @@ static void debugfs_ul_set(void *data, u64 val) | |||
179 | *(unsigned long *)data = val; | 180 | *(unsigned long *)data = val; |
180 | } | 181 | } |
181 | 182 | ||
183 | static void debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val) | ||
184 | { | ||
185 | *(unsigned long *)data = | ||
186 | val < MAX_STACK_TRACE_DEPTH ? | ||
187 | val : MAX_STACK_TRACE_DEPTH; | ||
188 | } | ||
189 | |||
182 | static u64 debugfs_ul_get(void *data) | 190 | static u64 debugfs_ul_get(void *data) |
183 | { | 191 | { |
184 | return *(unsigned long *)data; | 192 | return *(unsigned long *)data; |
@@ -192,6 +200,17 @@ static struct dentry *debugfs_create_ul(const char *name, mode_t mode, | |||
192 | return debugfs_create_file(name, mode, parent, value, &fops_ul); | 200 | return debugfs_create_file(name, mode, parent, value, &fops_ul); |
193 | } | 201 | } |
194 | 202 | ||
203 | DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get, | ||
204 | debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n"); | ||
205 | |||
206 | static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH( | ||
207 | const char *name, mode_t mode, | ||
208 | struct dentry *parent, unsigned long *value) | ||
209 | { | ||
210 | return debugfs_create_file(name, mode, parent, value, | ||
211 | &fops_ul_MAX_STACK_TRACE_DEPTH); | ||
212 | } | ||
213 | |||
195 | static void debugfs_atomic_t_set(void *data, u64 val) | 214 | static void debugfs_atomic_t_set(void *data, u64 val) |
196 | { | 215 | { |
197 | atomic_set((atomic_t *)data, val); | 216 | atomic_set((atomic_t *)data, val); |
@@ -284,8 +303,8 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name) | |||
284 | mode, dir, &attr->task_filter); | 303 | mode, dir, &attr->task_filter); |
285 | 304 | ||
286 | attr->dentries.stacktrace_depth_file = | 305 | attr->dentries.stacktrace_depth_file = |
287 | debugfs_create_ul("stacktrace-depth", mode, dir, | 306 | debugfs_create_ul_MAX_STACK_TRACE_DEPTH( |
288 | &attr->stacktrace_depth); | 307 | "stacktrace-depth", mode, dir, &attr->stacktrace_depth); |
289 | 308 | ||
290 | attr->dentries.require_start_file = | 309 | attr->dentries.require_start_file = |
291 | debugfs_create_ul("require-start", mode, dir, &attr->require_start); | 310 | debugfs_create_ul("require-start", mode, dir, &attr->require_start); |