From: Joe Perches <joe@perches.com>
To: Ben Greear <greearb@candelatech.com>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] bug.h: Add WARN_RATELIMIT
Date: Sat, 21 May 2011 10:48:39 -0700 [thread overview]
Message-ID: <2dfb6f4e8110e5b09dbf4c8a1502bdf8955bb6ff.1305999731.git.joe@perches.com> (raw)
In-Reply-To: <1305666832.1722.62.camel@Joe-Laptop>
In-Reply-To: <cover.1305999731.git.joe@perches.com>
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>
---
include/asm-generic/bug.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index e5a3f58..12b250c 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -165,6 +165,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); \
+})
+
/*
* WARN_ON_SMP() is for cases that the warning is either
* meaningless for !SMP or may even cause failures.
--
1.7.5.rc3.dirty
next prev parent reply other threads:[~2011-05-21 17:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1305657014-32736-1-git-send-email-greearb@candelatech.com>
[not found] ` <1305658349.1722.30.camel@Joe-Laptop>
[not found] ` <20110517.152357.85105240786269960.davem@davemloft.net>
[not found] ` <4DD2CDA9.7000009@candelatech.com>
[not found] ` <1305662020.1722.42.camel@Joe-Laptop>
[not found] ` <4DD2DB9D.6050306@candelatech.com>
2011-05-17 21:13 ` RFC: Add WARN_RATELIMIT to bug.h (was: Re: [PATCH] sk-filter: Rate-limit WARNing, print dbg info.) Joe Perches
2011-05-21 17:48 ` [PATCH 0/2] Add and use WARN_RATELIMIT Joe Perches
2011-05-21 17:48 ` Joe Perches [this message]
2011-05-21 17:48 ` [PATCH 2/2] net: filter: Use WARN_RATELIMIT Joe Perches
2011-05-26 12:31 ` [patch] net/core/filter.c: Fix build error Ingo Molnar
2011-05-26 15:31 ` Joe Perches
2011-05-26 18:38 ` David Miller
2011-05-26 18:57 ` Randy Dunlap
2011-05-26 19:00 ` David Miller
2011-05-26 19:07 ` Joe Perches
2011-05-26 19:09 ` Ingo Molnar
2011-05-26 19:12 ` Ingo Molnar
2011-05-23 21:38 ` [PATCH 0/2] Add and use WARN_RATELIMIT David Miller
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=2dfb6f4e8110e5b09dbf4c8a1502bdf8955bb6ff.1305999731.git.joe@perches.com \
--to=joe@perches.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=greearb@candelatech.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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
Powered by JetHome