summaryrefslogtreecommitdiff
path: root/lib/ratelimit.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ratelimit.c')
-rw-r--r--lib/ratelimit.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 0e2c28e8a0ca..69bfcacda16d 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -28,7 +28,15 @@ int __ratelimit(struct ratelimit_state *rs)
if (!rs->interval)
return 1;
- spin_lock_irqsave(&rs->lock, flags);
+ /*
+ * If we contend on this state's lock then almost
+ * by definition we are too busy to print a message,
+ * in addition to the one that will be printed by
+ * the entity that is holding the lock already:
+ */
+ if (!spin_trylock_irqsave(&rs->lock, flags))
+ return 1;
+
if (!rs->begin)
rs->begin = jiffies;