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/20250423115409.3425-1-spasswolf@web.de/ Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Kuniyuki Iwashima <kuniyu@amazon.com> Cc: Mateusz Guzik <mjguzik@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: John Ogness <john.ogness@linutronix.de> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
1 parent f2d0ea0 commit a69114c

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

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)