diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-05 12:50:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-05 12:50:22 -0500 |
commit | d0b093a8b5ae34ee8be1f7e0dd197fe4788fa1d5 (patch) | |
tree | deaed4192d440b6afb7470b0c36e69d9d65dd119 /include | |
parent | 3e72b810e30cdf4655279dd767eb798ac7a8fe5e (diff) | |
parent | 5c828713358cb9df8aa174371edcbbb62203a490 (diff) |
Merge branch 'core-printk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-printk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
ratelimit: Make suppressed output messages more useful
printk: Remove ratelimit.h from kernel.h
ratelimit: Fix/allow use in atomic contexts
ratelimit: Use per ratelimit context locking
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kernel.h | 5 | ||||
-rw-r--r-- | include/linux/net.h | 1 | ||||
-rw-r--r-- | include/linux/ratelimit.h | 33 |
3 files changed, 25 insertions, 14 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index f4e3184fa054..3fa4c590cf12 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -15,7 +15,6 @@ | |||
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> | ||
19 | #include <linux/dynamic_debug.h> | 18 | #include <linux/dynamic_debug.h> |
20 | #include <asm/byteorder.h> | 19 | #include <asm/byteorder.h> |
21 | #include <asm/bug.h> | 20 | #include <asm/bug.h> |
@@ -241,8 +240,8 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
241 | asmlinkage int printk(const char * fmt, ...) | 240 | asmlinkage int printk(const char * fmt, ...) |
242 | __attribute__ ((format (printf, 1, 2))) __cold; | 241 | __attribute__ ((format (printf, 1, 2))) __cold; |
243 | 242 | ||
244 | extern struct ratelimit_state printk_ratelimit_state; | 243 | extern int __printk_ratelimit(const char *func); |
245 | extern int printk_ratelimit(void); | 244 | #define printk_ratelimit() __printk_ratelimit(__func__) |
246 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | 245 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
247 | unsigned int interval_msec); | 246 | unsigned int interval_msec); |
248 | 247 | ||
diff --git a/include/linux/net.h b/include/linux/net.h index 529a0931711d..d7e26e30c8c2 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -358,6 +358,7 @@ static const struct proto_ops name##_ops = { \ | |||
358 | 358 | ||
359 | #ifdef CONFIG_SYSCTL | 359 | #ifdef CONFIG_SYSCTL |
360 | #include <linux/sysctl.h> | 360 | #include <linux/sysctl.h> |
361 | #include <linux/ratelimit.h> | ||
361 | extern struct ratelimit_state net_ratelimit_state; | 362 | extern struct ratelimit_state net_ratelimit_state; |
362 | #endif | 363 | #endif |
363 | 364 | ||
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h index 00044b856453..668cf1bef030 100644 --- a/include/linux/ratelimit.h +++ b/include/linux/ratelimit.h | |||
@@ -1,20 +1,31 @@ | |||
1 | #ifndef _LINUX_RATELIMIT_H | 1 | #ifndef _LINUX_RATELIMIT_H |
2 | #define _LINUX_RATELIMIT_H | 2 | #define _LINUX_RATELIMIT_H |
3 | |||
3 | #include <linux/param.h> | 4 | #include <linux/param.h> |
5 | #include <linux/spinlock_types.h> | ||
4 | 6 | ||
5 | #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) | 7 | #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) |
6 | #define DEFAULT_RATELIMIT_BURST 10 | 8 | #define DEFAULT_RATELIMIT_BURST 10 |
7 | 9 | ||
8 | struct ratelimit_state { | 10 | struct ratelimit_state { |
9 | int interval; | 11 | spinlock_t lock; /* protect the state */ |
10 | int burst; | 12 | |
11 | int printed; | 13 | int interval; |
12 | int missed; | 14 | int burst; |
13 | unsigned long begin; | 15 | int printed; |
16 | int missed; | ||
17 | unsigned long begin; | ||
14 | }; | 18 | }; |
15 | 19 | ||
16 | #define DEFINE_RATELIMIT_STATE(name, interval, burst) \ | 20 | #define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ |
17 | struct ratelimit_state name = {interval, burst,} | 21 | \ |
22 | struct ratelimit_state name = { \ | ||
23 | .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ | ||
24 | .interval = interval_init, \ | ||
25 | .burst = burst_init, \ | ||
26 | } | ||
27 | |||
28 | extern int ___ratelimit(struct ratelimit_state *rs, const char *func); | ||
29 | #define __ratelimit(state) ___ratelimit(state, __func__) | ||
18 | 30 | ||
19 | extern int __ratelimit(struct ratelimit_state *rs); | 31 | #endif /* _LINUX_RATELIMIT_H */ |
20 | #endif | ||