Skip to content

Commit a69114c

Browse files
committed
ratelimit: Use nolock_ret label to save a couple of lines of code
Create a nolock_ret label in order to start consolidating the unlocked return paths that conditionally invoke ratelimit_state_inc_miss(). 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 f2d0ea0 commit a69114c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/ratelimit.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
4343
WARN_ONCE(interval < 0 || burst < 0, "Negative interval (%d) or burst (%d): Uninitialized ratelimit_state structure?\n", interval, burst);
4444
ret = interval == 0 || burst > 0;
4545
if (!(READ_ONCE(rs->flags) & RATELIMIT_INITIALIZED) || (!interval && !burst) ||
46-
!raw_spin_trylock_irqsave(&rs->lock, flags)) {
47-
if (!ret)
48-
ratelimit_state_inc_miss(rs);
49-
return ret;
50-
}
46+
!raw_spin_trylock_irqsave(&rs->lock, flags))
47+
goto nolock_ret;
5148

5249
/* Force re-initialization once re-enabled. */
5350
rs->flags &= ~RATELIMIT_INITIALIZED;
@@ -116,6 +113,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
116113
unlock_ret:
117114
raw_spin_unlock_irqrestore(&rs->lock, flags);
118115

116+
nolock_ret:
119117
if (!ret)
120118
ratelimit_state_inc_miss(rs);
121119

0 commit comments

Comments
 (0)