Re: [PATCH] show message when exceeded rlimit of pending signals

From: Joe Perches
Date: Fri Oct 30 2009 - 17:46:12 EST


On Fri, 2009-10-30 at 14:33 -0700, Andrew Morton wrote:
> On Fri, 30 Oct 2009 20:36:31 +0900
> Naohiro Ooiwa <nooiwa@xxxxxxxxxxxxxxxx> wrote:
> > +static void show_reach_rlimit_sigpending(void)
> > + if (!printk_ratelimit())
> > + return;
>
> printk_ratelimit() is a bad thing and we should be working toward
> removing it altogether, not adding new callers.
>
> Because it uses global state. So if subsystem A is trying to generate
> lots of printk's, subsystem B's important message might get
> accidentally suppressed.

http://lkml.org/lkml/2009/9/21/323

I think there should be a generic kernel.h macro for this.
Something like:

#define printk_ratelimited(fmt, arg...) \
({ static struct ratelimit_state _rs = { \
.interval = DEFAULT_RATELIMIT_INTERVAL, \
.burst = DEFAULT_RATELIMIT_BURST, \
}; \
int rtn; \
\
if (!__ratelimit(&_rs)) \
rtn = printk(fmt, ##arg); \
else \
rtn = 0; \
rtn; \
})
#define pr_info_rl(fmt, arg) \
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##arg)
etc...



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/