From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758171AbcIQJJz (ORCPT ); Sat, 17 Sep 2016 05:09:55 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:33751 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755017AbcIQJJq (ORCPT ); Sat, 17 Sep 2016 05:09:46 -0400 Date: Sat, 17 Sep 2016 12:09:41 +0300 From: Cyrill Gorcunov To: Konstantin Khlebnikov Cc: Joe Perches , Linus Torvalds , Sam Varshavchik , Ingo Molnar , Laura Abbott , Brent , Andrew Morton , Christian Borntraeger , "linux-mm@kvack.org" , Linux Kernel Mailing List Subject: Re: [REGRESSION] RLIMIT_DATA crashes named Message-ID: <20160917090941.GB26044@uranus.lan> References: <33304dd8-8754-689d-11f3-751833b4a288@redhat.com> <1474085296.32273.95.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 17, 2016 at 11:33:56AM +0300, Konstantin Khlebnikov wrote: > > > > do_just_once just isn't a good name for a global > > rate limited mechanism that does something very > > different than the name. > > > > Maybe allow_once_per_ratelimit or the like > > > > There could be an equivalent do_once > > > > https://lkml.org/lkml/2009/5/22/3 > > > > What about this printk_reriodic() and pr_warn_once_per_minute()? > > It simply remembers next jiffies to print rather than using that > complicated ratelimiting engine. +#define printk_periodic(period, fmt, ...) \ +({ \ + static unsigned long __print_next __read_mostly = INITIAL_JIFFIES; \ + bool __do_print = time_after_eq(jiffies, __print_next); \ + \ + if (__do_print) { \ + __print_next = jiffies + (period); \ + printk(fmt, ##__VA_ARGS__); \ + } \ + unlikely(__do_print); \ +}) Seems I don't understand the bottom unlikely...