From: Paul E. McKenney Date: Thu, 24 Apr 2025 19:36:19 +0000 (-0700) Subject: ratelimit: Drop redundant accesses to burst X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=ba575cea29fd82a0e6836fefcd51db36f1ff8a92;p=linux-2.6-microblaze.git ratelimit: Drop redundant accesses to burst Now that there is the "burst <= 0" fastpath, for all later code, burst must be strictly greater than zero. Therefore, drop the redundant checks of this local variable. 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 Reviewed-by: Petr Mladek Cc: Andrew Morton Cc: Kuniyuki Iwashima Cc: Mateusz Guzik Cc: Steven Rostedt Cc: John Ogness Cc: Sergey Senozhatsky --- diff --git a/lib/ratelimit.c b/lib/ratelimit.c index dcc063af195e..859c251b23ce 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c @@ -58,7 +58,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func) * the current lock owner is just about to reset it. */ if (!raw_spin_trylock_irqsave(&rs->lock, flags)) { - if (READ_ONCE(rs->flags) & RATELIMIT_INITIALIZED && burst && + if (READ_ONCE(rs->flags) & RATELIMIT_INITIALIZED && atomic_read(&rs->rs_n_left) > 0 && atomic_dec_return(&rs->rs_n_left) >= 0) ret = 1; goto nolock_ret; @@ -90,7 +90,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func) } /* Note that the burst might be taken by a parallel call. */ - if (burst && atomic_read(&rs->rs_n_left) > 0 && atomic_dec_return(&rs->rs_n_left) >= 0) + if (atomic_read(&rs->rs_n_left) > 0 && atomic_dec_return(&rs->rs_n_left) >= 0) ret = 1; unlock_ret: