Skip to content

Commit d343732

Browse files
committed
ratelimit: Count misses due to lock contention
The ___ratelimit() function simply returns zero ("do ratelimiting") if the trylock fails, but does not adjust the ->missed field. This means that the resulting dropped printk()s are dropped silently, which could seriously confuse people trying to do console-log-based debugging. Therefore, increment the ->missed field upon trylock failure. Link: https://lore.kernel.org/all/fbe93a52-365e-47fe-93a4-44a44547d601@paulmck-laptop/ Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Kuniyuki Iwashima <[email protected]> Cc: Mateusz Guzik <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: John Ogness <[email protected]> Cc: Sergey Senozhatsky <[email protected]>
1 parent 78bf44d commit d343732

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ratelimit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
4444
* in addition to the one that will be printed by
4545
* the entity that is holding the lock already:
4646
*/
47-
if (!raw_spin_trylock_irqsave(&rs->lock, flags))
47+
if (!raw_spin_trylock_irqsave(&rs->lock, flags)) {
48+
ratelimit_state_inc_miss(rs);
4849
return 0;
50+
}
4951

5052
if (!rs->begin)
5153
rs->begin = jiffies;

0 commit comments

Comments
 (0)