mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
net: Add net_ratelimited_function and net_<level>_ratelimited macros
commit 3a3bfb61e6
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: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8ba2272db8
commit
b3c463e876
1 changed files with 23 additions and 0 deletions
|
@ -265,6 +265,29 @@ do { \
|
|||
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_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, ...) \
|
||||
|
|
Loading…
Reference in a new issue