public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Ooiwa <nooiwa@miraclelinux.com>
To: Ingo Molnar <mingo@elte.hu>, Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>,
	roland@redhat.com, Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	oleg@redhat.com, Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] kernel.h: Add printk_ratelimited and pr_<level>_rl
Date: Thu, 05 Nov 2009 23:16:13 +0900	[thread overview]
Message-ID: <4AF2DE2D.5060902@miraclelinux.com> (raw)
In-Reply-To: <20091102155823.GA31535@elte.hu>

Ingo Molnar wrote:
> * Joe Perches <joe@perches.com> wrote:
> 
>> Add a printk_ratelimited statement expression macro that uses a 
>> per-call ratelimit_state so that multiple subsystems output messages 
>> are not suppressed by a global __ratelimit state.
>>
>> Signed-off-by: Joe Perches <joe@perches.com>
>>
>> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
>> index f4e3184..555560c 100644
>> --- a/include/linux/kernel.h
>> +++ b/include/linux/kernel.h
>> @@ -407,6 +407,50 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
>>  #endif
>>  
>>  /*
>> + * ratelimited messages with local ratelimit_state,
>> + * no local ratelimit_state used in the !PRINTK case
>> + */
>> +#ifdef CONFIG_PRINTK
>> +#define printk_ratelimited(fmt, ...)  ({		\
>> +	static struct ratelimit_state _rs = {		\
>> +		.interval = DEFAULT_RATELIMIT_INTERVAL, \
>> +		.burst = DEFAULT_RATELIMIT_BURST,       \
>> +	};                                              \
>> +							\
>> +	if (!__ratelimit(&_rs))                         \
>> +		printk(fmt, ##__VA_ARGS__);		\
>> +})
>> +#else
>> +/* No effect, but we still get type checking even in the !PRINTK case: */
>> +#define printk_ratelimited printk
>> +#endif
>> +
>> +#define pr_emerg_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_alert_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_crit_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_err_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_warning_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_notice_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_info_rl(fmt, ...) \
>> +        printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
>> +/* no pr_cont_rl, don't do that... */
>> +/* If you are writing a driver, please use dev_dbg instead */
>> +#if defined(DEBUG)
>> +#define pr_debug_rl(fmt, ...) \
>> +	printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
>> +#else
>> +#define pr_debug_rl(fmt, ...) \
>> +	({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
>> +				     ##__VA_ARGS__); 0; })
>> +#endif
>> +
> 
> Looks like a useful addition. Somewhat bloatier, but then again, more 
> correct and the bloat problem can be solved by explicit state 
> definitions.
> 
> 	Ingo

I waiting for this patch to merge.
And then, I think I will remake my patch.

How do you delete printk_ratelimit() in this patch at a same time ?

I have a personal question.
Why aren't they codes in the include/linux/ratelimit.h ?


Thanks.
Naohiro Ooiwa


  reply	other threads:[~2009-11-05 14:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-30 11:36 [PATCH] show message when exceeded rlimit of pending signals Naohiro Ooiwa
2009-10-30 21:33 ` Andrew Morton
2009-10-30 21:45   ` Joe Perches
2009-10-30 23:21     ` [PATCH] kernel.h: Add printk_ratelimited and pr_<level>_rl Joe Perches
2009-11-02 15:58       ` Ingo Molnar
2009-11-05 14:16         ` Naohiro Ooiwa [this message]
2009-11-05 14:44           ` Naohiro Ooiwa
2009-11-09 21:49       ` Andrew Morton
2009-11-09 22:05         ` Joe Perches
2009-11-09 22:28           ` Randy Dunlap
2009-11-10  5:18           ` Ingo Molnar
2009-11-10  5:17         ` Ingo Molnar
2009-11-10  7:34           ` Peter Zijlstra
2009-11-10  7:39             ` Ingo Molnar
2009-11-10  7:54               ` Joe Perches
2009-11-10  8:21               ` Peter Zijlstra
2009-10-31  7:58   ` [PATCH] show message when exceeded rlimit of pending signals Naohiro Ooiwa
2009-10-31  8:50     ` Naohiro Ooiwa
2009-10-31  8:57       ` Andrew Morton
2009-10-31 11:05         ` Naohiro Ooiwa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF2DE2D.5060902@miraclelinux.com \
    --to=nooiwa@miraclelinux.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=h-shimamoto@ct.jp.nec.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox