diff options
Diffstat (limited to 'include/linux/ratelimit.h')
-rw-r--r-- | include/linux/ratelimit.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h new file mode 100644 index 000000000000..18a5b9ba9d40 --- /dev/null +++ b/include/linux/ratelimit.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef _LINUX_RATELIMIT_H | ||
2 | #define _LINUX_RATELIMIT_H | ||
3 | #include <linux/param.h> | ||
4 | |||
5 | #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) | ||
6 | #define DEFAULT_RATELIMIT_BURST 10 | ||
7 | |||
8 | struct ratelimit_state { | ||
9 | int interval; | ||
10 | int burst; | ||
11 | int printed; | ||
12 | int missed; | ||
13 | unsigned long begin; | ||
14 | }; | ||
15 | |||
16 | #define DEFINE_RATELIMIT_STATE(name, interval, burst) \ | ||
17 | struct ratelimit_state name = {interval, burst,} | ||
18 | |||
19 | extern int __ratelimit(struct ratelimit_state *rs); | ||
20 | |||
21 | static inline int ratelimit(void) | ||
22 | { | ||
23 | static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, | ||
24 | DEFAULT_RATELIMIT_BURST); | ||
25 | return __ratelimit(&rs); | ||
26 | } | ||
27 | #endif | ||