From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Joe Perches <joe@perches.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 3.4 5/9] net: Add net_ratelimited_function and net_<level>_ratelimited macros
Date: Fri, 16 May 2014 15:55:28 -0700 [thread overview]
Message-ID: <20140516225458.805467686@linuxfoundation.org> (raw)
In-Reply-To: <20140516225458.512693003@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Perches <joe@perches.com>
commit 3a3bfb61e64476ff1e4ac3122cb6dec9c79b795c upstream.
__ratelimit() can be considered an inverted bool test because
it returns true when not ratelimited. Several tests in the
kernel tree use this __ratelimit() function incorrectly.
No net_ratelimit uses are incorrect currently though.
Most uses of net_ratelimit are to log something via printk or
pr_<level>.
In order to minimize the uses of net_ratelimit, and to start
standardizing the code style used for __ratelimit() and net_ratelimit(),
add a net_ratelimited_function() macro and net_<level>_ratelimited()
logging macros similar to pr_<level>_ratelimited that use the global
net_ratelimit instead of a static per call site "struct ratelimit_state".
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/net.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -259,6 +259,29 @@ extern struct socket *sockfd_lookup(int
#define sockfd_put(sock) fput(sock->file)
extern int net_ratelimit(void);
+#define net_ratelimited_function(function, ...) \
+do { \
+ if (net_ratelimit()) \
+ function(__VA_ARGS__); \
+} while (0)
+
+#define net_emerg_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
+#define net_alert_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
+#define net_crit_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
+#define net_err_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
+#define net_notice_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
+#define net_warn_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
+#define net_info_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
+#define net_dbg_ratelimited(fmt, ...) \
+ net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
+
#define net_random() random32()
#define net_srandom(seed) srandom32((__force u32)seed)
next prev parent reply other threads:[~2014-05-16 22:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 22:55 [PATCH 3.4 0/9] 3.4.91-stable review Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 1/9] SCSI: megaraid: missing bounds check in mimd_to_kioc() Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 2/9] n_tty: Fix n_tty_write crash when echoing in raw mode Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 3/9] blktrace: fix accounting of partially completed requests Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 4/9] netfilter: nf_conntrack: reserve two bytes for nf_ct_ext->len Greg Kroah-Hartman
2014-05-16 22:55 ` Greg Kroah-Hartman [this message]
2014-05-16 22:55 ` [PATCH 3.4 6/9] netfilter: Cant fail and free after table replacement Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 7/9] tracepoint: Do not waste memory on mods with no tracepoints Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 8/9] powerpc: Add vr save/restore functions Greg Kroah-Hartman
2014-05-16 22:55 ` [PATCH 3.4 9/9] tgafb: fix mode setting with fbset Greg Kroah-Hartman
2014-05-17 15:44 ` [PATCH 3.4 0/9] 3.4.91-stable review Guenter Roeck
2014-05-17 17:25 ` Greg Kroah-Hartman
2014-05-18 10:09 ` Satoru Takeuchi
2014-05-18 12:23 ` Greg Kroah-Hartman
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=20140516225458.805467686@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.