lkml.org 
[lkml]   [2011]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: linux-next: Tree for May 24 (ratelimits, CONFIG_PRINTK not enabled)
From
Date
On Tue, 2011-05-24 at 15:32 -0400, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Tue, 24 May 2011 11:49:48 -0700
> > On Tue, 2011-05-24 at 11:33 -0700, Randy Dunlap wrote:
> >> Adding <linux/ratelimit.h> to <asm-generic/bug.h> causes other problems:
> > Yup, that's not a good solution.
> Please come up with a fix or I'll have to revert, thanks Joe.

I have some errands to run for awhile.

Probably a revert today and another patch set tomorrow
might be best.

This seems to work and doesn't cause any extra state to be
instantiated when !CONFIG_PRINTK. What do you think?

#ifdef CONFIG_PRINTK

#define WARN_ON_RATELIMIT(condition, state) \
WARN_ON((condition) && __ratelimit(state))

#define __WARN_RATELIMIT(condition, state, format...) \
({ \
int rtn = 0; \
if (unlikely(__ratelimit(state))) \
rtn = WARN(condition, format); \
rtn; \
})

#define WARN_RATELIMIT(condition, format...) \
({ \
static DEFINE_RATELIMIT_STATE(_rs, \
DEFAULT_RATELIMIT_INTERVAL, \
DEFAULT_RATELIMIT_BURST); \
__WARN_RATELIMIT(condition, &_rs, format); \
})

#else

#define WARN_ON_RATELIMIT(condition, state) \
WARN_ON(condition)

#define __WARN_RATELIMIT(condition, state, format...) \
({ \
int rtn = WARN(condition, format); \
rtn; \
})

#define WARN_RATELIMIT(condition, format...) \
({ \
int rtn = WARN(condition, format); \
rtn; \
})

#endif




\
 
 \ /
  Last update: 2011-05-24 21:51    [W:0.047 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site