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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Dec 25 02:34:56 PST 2015


Kirill, please review the patch.

Dima, please send an additional patch to actually use this new functions in nla_parse()
which was the initial reason of https://jira.sw.ru/browse/PSBM-42313

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 12/11/2015 07:02 PM, Dmitry Safonov wrote:
> Simple ratelimit for ve_printk & level.
>
> https://jira.sw.ru/browse/PSBM-42313
>
> Signed-off-by: Dmitry Safonov <dsafonov at odin.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..13784a2 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