diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kernel.h | 8 | ||||
-rw-r--r-- | include/linux/net.h | 3 | ||||
-rw-r--r-- | include/linux/ratelimit.h | 27 | ||||
-rw-r--r-- | include/linux/rcupreempt.h | 9 |
4 files changed, 37 insertions, 10 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5c4b1251e110..fdbbf72ca2eb 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bitops.h> | 15 | #include <linux/bitops.h> |
16 | #include <linux/log2.h> | 16 | #include <linux/log2.h> |
17 | #include <linux/typecheck.h> | 17 | #include <linux/typecheck.h> |
18 | #include <linux/ratelimit.h> | ||
18 | #include <asm/byteorder.h> | 19 | #include <asm/byteorder.h> |
19 | #include <asm/bug.h> | 20 | #include <asm/bug.h> |
20 | 21 | ||
@@ -189,11 +190,8 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
189 | asmlinkage int printk(const char * fmt, ...) | 190 | asmlinkage int printk(const char * fmt, ...) |
190 | __attribute__ ((format (printf, 1, 2))) __cold; | 191 | __attribute__ ((format (printf, 1, 2))) __cold; |
191 | 192 | ||
192 | extern int printk_ratelimit_jiffies; | 193 | extern struct ratelimit_state printk_ratelimit_state; |
193 | extern int printk_ratelimit_burst; | ||
194 | extern int printk_ratelimit(void); | 194 | extern int printk_ratelimit(void); |
195 | extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst); | ||
196 | extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); | ||
197 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | 195 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
198 | unsigned int interval_msec); | 196 | unsigned int interval_msec); |
199 | #else | 197 | #else |
@@ -204,8 +202,6 @@ static inline int printk(const char *s, ...) | |||
204 | __attribute__ ((format (printf, 1, 2))); | 202 | __attribute__ ((format (printf, 1, 2))); |
205 | static inline int __cold printk(const char *s, ...) { return 0; } | 203 | static inline int __cold printk(const char *s, ...) { return 0; } |
206 | static inline int printk_ratelimit(void) { return 0; } | 204 | static inline int printk_ratelimit(void) { return 0; } |
207 | static inline int __printk_ratelimit(int ratelimit_jiffies, \ | ||
208 | int ratelimit_burst) { return 0; } | ||
209 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | 205 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ |
210 | unsigned int interval_msec) \ | 206 | unsigned int interval_msec) \ |
211 | { return false; } | 207 | { return false; } |
diff --git a/include/linux/net.h b/include/linux/net.h index 2f999fbb188d..4a9a30f2d68f 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -351,8 +351,7 @@ static const struct proto_ops name##_ops = { \ | |||
351 | 351 | ||
352 | #ifdef CONFIG_SYSCTL | 352 | #ifdef CONFIG_SYSCTL |
353 | #include <linux/sysctl.h> | 353 | #include <linux/sysctl.h> |
354 | extern int net_msg_cost; | 354 | extern struct ratelimit_state net_ratelimit_state; |
355 | extern int net_msg_burst; | ||
356 | #endif | 355 | #endif |
357 | 356 | ||
358 | #endif /* __KERNEL__ */ | 357 | #endif /* __KERNEL__ */ |
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 | ||
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h index f04b64eca636..0967f03b0705 100644 --- a/include/linux/rcupreempt.h +++ b/include/linux/rcupreempt.h | |||
@@ -115,16 +115,21 @@ DECLARE_PER_CPU(struct rcu_dyntick_sched, rcu_dyntick_sched); | |||
115 | 115 | ||
116 | static inline void rcu_enter_nohz(void) | 116 | static inline void rcu_enter_nohz(void) |
117 | { | 117 | { |
118 | static DEFINE_RATELIMIT_STATE(rs, 10 * HZ, 1); | ||
119 | |||
118 | smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */ | 120 | smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */ |
119 | __get_cpu_var(rcu_dyntick_sched).dynticks++; | 121 | __get_cpu_var(rcu_dyntick_sched).dynticks++; |
120 | WARN_ON(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1); | 122 | WARN_ON_RATELIMIT(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1, &rs); |
121 | } | 123 | } |
122 | 124 | ||
123 | static inline void rcu_exit_nohz(void) | 125 | static inline void rcu_exit_nohz(void) |
124 | { | 126 | { |
127 | static DEFINE_RATELIMIT_STATE(rs, 10 * HZ, 1); | ||
128 | |||
125 | smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */ | 129 | smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */ |
126 | __get_cpu_var(rcu_dyntick_sched).dynticks++; | 130 | __get_cpu_var(rcu_dyntick_sched).dynticks++; |
127 | WARN_ON(!(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1)); | 131 | WARN_ON_RATELIMIT(!(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1), |
132 | &rs); | ||
128 | } | 133 | } |
129 | 134 | ||
130 | #else /* CONFIG_NO_HZ */ | 135 | #else /* CONFIG_NO_HZ */ |