lkml.org 
[lkml]   [2012]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[34-longterm 099/179] bug.h: Add WARN_RATELIMIT
    Date
    From: Joe Perches <joe@perches.com>

    -------------------
    This is a commit scheduled for the next v2.6.34 longterm release.
    http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
    If you see a problem with using this for longterm, please comment.
    -------------------

    commit b3eec79b0776e5340a3db75b34953977c7e5086e upstream.

    Add a generic mechanism to ratelimit WARN(foo, fmt, ...) messages
    using a hidden per call site static struct ratelimit_state.

    Also add an __WARN_RATELIMIT variant to be able to use a specific
    struct ratelimit_state.

    Signed-off-by: Joe Perches <joe@perches.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
    ---
    include/asm-generic/bug.h | 16 ++++++++++++++++
    1 file changed, 16 insertions(+)

    diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
    index 18c435d..bf58d4c 100644
    --- a/include/asm-generic/bug.h
    +++ b/include/asm-generic/bug.h
    @@ -135,6 +135,22 @@ extern void warn_slowpath_null(const char *file, const int line);
    #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); \
    +})
    +
    #ifdef CONFIG_SMP
    # define WARN_ON_SMP(x) WARN_ON(x)
    #else
    --
    1.7.9.6


    \
     
     \ /
      Last update: 2012-05-15 05:41    [W:4.210 / U:0.784 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site