[RFC 3/9] printk: Add printk_emit_ratelimited macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Needed so we can add structured data to the block layer
logging.

Signed-off-by: Tony Asleson <tasleson@xxxxxxxxxx>
---
 include/linux/printk.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 06c3ba5b695e..dd41b79e6f06 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -172,6 +172,18 @@ int printk_emit(int facility, int level,
 		const char *dict, size_t dictlen,
 		const char *fmt, ...);
 
+#define printk_emit_ratelimited(facility, level,			\
+		dict, dict_len, fmt, ...)				\
+({									\
+	static DEFINE_RATELIMIT_STATE(_ers,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_ers))						\
+		printk_emit(facility, level,				\
+				dict, dict_len, fmt, ##__VA_ARGS__);	\
+})
+
 asmlinkage __printf(1, 2) __cold
 int printk(const char *fmt, ...);
 
-- 
2.21.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux