[Devel] [PATCH RHEL7 COMMIT] ve_prink: introduce ve_pr_<level>_ratelimited

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 18 07:17:26 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.1
------>
commit 8aaf2b96ca1e8496ad890e868d7b3ec06c7d3707
Author: Dmitry Safonov <dsafonov at virtuozzo.com>
Date:   Mon Jan 18 19:17:26 2016 +0400

    ve_prink: introduce ve_pr_<level>_ratelimited
    
    ve_prink: introduce ve_pr_<level>_ratelimited
    
    Simple ratelimit for ve_printk & level.
    
    https://jira.sw.ru/browse/PSBM-42313
    
    Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/printk.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 87bc842..4db50c4 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -345,9 +345,21 @@ extern void dump_stack(void) __cold;
 	if (__ratelimit(&_rs))						\
 		printk(fmt, ##__VA_ARGS__);				\
 })
+
+#define ve_printk_ratelimited(dst, fmt, ...)				\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_rs))						\
+		ve_printk(dst, fmt, ##__VA_ARGS__);			\
+})
 #else
 #define printk_ratelimited(fmt, ...)					\
 	no_printk(fmt, ##__VA_ARGS__)
+#define ve_printk_ratelimited(dst, fmt, ...)				\
+	no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 #define pr_emerg_ratelimited(fmt, ...)					\
@@ -365,6 +377,20 @@ extern void dump_stack(void) __cold;
 #define pr_info_ratelimited(fmt, ...)					\
 	printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 /* no pr_cont_ratelimited, don't do that... */
+#define ve_pr_emerg_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_alert_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_crit_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_err_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_warn_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_notice_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_info_ratelimited(dst, fmt, ...)					\
+	ve_printk_ratelimited(dst, KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 
 #if defined(DEBUG)
 #define pr_devel_ratelimited(fmt, ...)					\


More information about the Devel mailing list