[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALYGNiN-ELbwSV0X2_FeKvGSOfRuHMsBnBDj86NHZxQKnZgVsQ@mail.gmail.com>
Date: Sun, 18 Sep 2016 00:40:37 +0300
From: Konstantin Khlebnikov <koct9i@...il.com>
To: Cyrill Gorcunov <gorcunov@...il.com>
Cc: Joe Perches <joe@...ches.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sam Varshavchik <mrsam@...rier-mta.com>,
Ingo Molnar <mingo@...nel.org>,
Laura Abbott <labbott@...hat.com>, Brent <fix@...realm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Christian Borntraeger <borntraeger@...ibm.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [REGRESSION] RLIMIT_DATA crashes named
On Sat, Sep 17, 2016 at 3:20 PM, Cyrill Gorcunov <gorcunov@...il.com> wrote:
> On Sat, Sep 17, 2016 at 03:09:09PM +0300, Konstantin Khlebnikov wrote:
>> >
>> > Seems I don't understand the bottom unlikely...
>>
>> This is gcc extrension: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
>> Here macro works as a function which returns bool
>
> no, no, I know for what unlikely extension stand for.
> it was just hard to obtain from without the context.
> this extension implies someone calls for
> if (printk_periodic()) right?
Yep.
Here is perfect macro for that jiffies check: time_in_range_open.
/*
* Calculate whether a is in the range of [b, c).
*/
#define time_in_range_open(a,b,c) \
(time_after_eq(a,b) && \
time_before(a,c))
So... better version looks like
#define printk_periodic(period, fmt, ...)
({
static unsigned long __prev __read_mostly = INITIAL_JIFFIES - (period);
unsigned long __now = jiffies;
bool __print = !time_in_range_open(__now, __prev, __prev + (period));
if (__print) {
__prev = __now;
printk(fmt, ##__VA_ARGS__);
}
unlikely(__print);
})
Download attachment "printk-add-pr_warn_once_per_minute" of type "application/octet-stream" (2310 bytes)
Powered by blists - more mailing lists