Messages in this thread | | | Subject | Re: [PATCHv3] lib/ratelimit: Lockless ratelimiting | From | Dmitry Safonov <> | Date | Thu, 02 Aug 2018 16:19:15 +0100 |
| |
Hi Steven, Thanks for your reply,
On Wed, 2018-08-01 at 21:48 -0400, Steven Rostedt wrote: > I'm just catching up from my vacation. What about making rs->missed > into an atomic, and have: > > if (!raw_spin_trylock_irqsave(&rs->lock, flags)) { > atomic_inc(&rs->missed); > return 0; > } > > ?
Uhm. Do you mean as a preparation patch to split this on two patches? Because it will not solve the issue where one CPU has taken rs->lock, and is updating rs->printed, checking burst and whatnot; while the second CPU will loose the message which was even *under* burst limit.
I.e.: there are enough of printk_ratelimit() users in tree and a message from one can be suppressed, while shouldn't.
> You would also need to do: > > if (time_is_before_jiffies(rs->begin + rs->interval)) { > int missed = atomic_xchg(&rs->missed, 0); > if (missed) { > > So that you don't have a race between checking rs->missed and setting > it > to zero.
-- Thanks, Dmitry
| |