Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipoib: Make ipoib_warn ratelimited

In certain cases it's possible to be flooded by warning messages. To
cope with such situations make the ipoib_warn macro be ratelimited.
To prevent accidental limiting of legitimate, bursty messages make
the limit fairly liberal by allowing up to 100 messages in 10 seconds.

Signed-off-by: Nikolay Borisov <kernel@kyup.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

kernel@kyup.com and committed by
Doug Ledford
32f7451d fb6375d7

+7 -1
+7 -1
drivers/infiniband/ulp/ipoib/ipoib.h
··· 771 771 #define ipoib_printk(level, priv, format, arg...) \ 772 772 printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg) 773 773 #define ipoib_warn(priv, format, arg...) \ 774 - ipoib_printk(KERN_WARNING, priv, format , ## arg) 774 + do { \ 775 + static DEFINE_RATELIMIT_STATE(_rs, \ 776 + 10 * HZ /*10 seconds */, \ 777 + 100); \ 778 + if (__ratelimit(&_rs)) \ 779 + ipoib_printk(KERN_WARNING, priv, format , ## arg);\ 780 + } while (0) 775 781 776 782 extern int ipoib_sendq_size; 777 783 extern int ipoib_recvq_size;