lkml.org 
[lkml]   [2018]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCHv3] lib/ratelimit: Lockless ratelimiting
From
Date
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

\
 
 \ /
  Last update: 2018-08-02 17:20    [W:0.662 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site