Lines Matching +full:rs +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ratelimit.c - Do something with rate limit.
7 * 2008-05-01 rewrite the function and use a ratelimit_state data struct as
16 * __ratelimit - rate limiting
17 * @rs: ratelimit_state data
20 * This enforces a rate limit: not more than @rs->burst callbacks
21 * in every @rs->interval
27 int ___ratelimit(struct ratelimit_state *rs, const char *func) in ___ratelimit() argument
33 int interval = READ_ONCE(rs->interval); in ___ratelimit()
34 int burst = READ_ONCE(rs->burst); in ___ratelimit()
47 if (!raw_spin_trylock_irqsave(&rs->lock, flags)) in ___ratelimit()
50 if (!rs->begin) in ___ratelimit()
51 rs->begin = jiffies; in ___ratelimit()
53 if (time_is_before_jiffies(rs->begin + interval)) { in ___ratelimit()
54 if (rs->missed) { in ___ratelimit()
55 if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) { in ___ratelimit()
58 func, rs->missed); in ___ratelimit()
59 rs->missed = 0; in ___ratelimit()
62 rs->begin = jiffies; in ___ratelimit()
63 rs->printed = 0; in ___ratelimit()
65 if (burst && burst > rs->printed) { in ___ratelimit()
66 rs->printed++; in ___ratelimit()
69 rs->missed++; in ___ratelimit()
72 raw_spin_unlock_irqrestore(&rs->lock, flags); in ___ratelimit()