Commit 6adc4a22 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Linus Torvalds

fault-inject: add ratelimit option

Current debug levels are not optimal.  Especially if one want to provoke
big numbers of faults(broken device simulator) then any verbose level will
produce giant numbers of identical logging messages.  Let's add ratelimit
parameter for that purpose.
Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Acked-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 89e3f909
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/ratelimit.h>
#include <linux/atomic.h> #include <linux/atomic.h>
/* /*
...@@ -25,6 +26,8 @@ struct fault_attr { ...@@ -25,6 +26,8 @@ struct fault_attr {
unsigned long reject_end; unsigned long reject_end;
unsigned long count; unsigned long count;
struct ratelimit_state ratelimit_state;
struct dentry *dname;
}; };
#define FAULT_ATTR_INITIALIZER { \ #define FAULT_ATTR_INITIALIZER { \
...@@ -32,7 +35,9 @@ struct fault_attr { ...@@ -32,7 +35,9 @@ struct fault_attr {
.times = ATOMIC_INIT(1), \ .times = ATOMIC_INIT(1), \
.require_end = ULONG_MAX, \ .require_end = ULONG_MAX, \
.stacktrace_depth = 32, \ .stacktrace_depth = 32, \
.ratelimit_state = RATELIMIT_STATE_INIT_DISABLED, \
.verbose = 2, \ .verbose = 2, \
.dname = NULL, \
} }
#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
......
...@@ -40,10 +40,16 @@ EXPORT_SYMBOL_GPL(setup_fault_attr); ...@@ -40,10 +40,16 @@ EXPORT_SYMBOL_GPL(setup_fault_attr);
static void fail_dump(struct fault_attr *attr) static void fail_dump(struct fault_attr *attr)
{ {
if (attr->verbose > 0) if (attr->verbose > 0 && __ratelimit(&attr->ratelimit_state)) {
printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure\n"); printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure.\n"
"name %pd, interval %lu, probability %lu, "
"space %d, times %d\n", attr->dname,
attr->probability, attr->interval,
atomic_read(&attr->space),
atomic_read(&attr->times));
if (attr->verbose > 1) if (attr->verbose > 1)
dump_stack(); dump_stack();
}
} }
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
...@@ -202,6 +208,12 @@ struct dentry *fault_create_debugfs_attr(const char *name, ...@@ -202,6 +208,12 @@ struct dentry *fault_create_debugfs_attr(const char *name,
goto fail; goto fail;
if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose)) if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose))
goto fail; goto fail;
if (!debugfs_create_u32("verbose_ratelimit_interval_ms", mode, dir,
&attr->ratelimit_state.interval))
goto fail;
if (!debugfs_create_u32("verbose_ratelimit_burst", mode, dir,
&attr->ratelimit_state.burst))
goto fail;
if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter)) if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter))
goto fail; goto fail;
...@@ -222,6 +234,7 @@ struct dentry *fault_create_debugfs_attr(const char *name, ...@@ -222,6 +234,7 @@ struct dentry *fault_create_debugfs_attr(const char *name,
#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
attr->dname = dget(dir);
return dir; return dir;
fail: fail:
debugfs_remove_recursive(dir); debugfs_remove_recursive(dir);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment