From: Konstantin Khlebnikov <koct9i@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Sam Varshavchik <mrsam@courier-mta.com>,
Ingo Molnar <mingo@kernel.org>, Laura Abbott <labbott@redhat.com>,
Brent <fix@bitrealm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [REGRESSION] RLIMIT_DATA crashes named
Date: Sat, 17 Sep 2016 11:33:56 +0300 [thread overview]
Message-ID: <CALYGNiNuF1Ggy=DyYG32HXbnJp3Q0cX9ekQ5w2jR1M9rkKaX9A@mail.gmail.com> (raw)
In-Reply-To: <1474085296.32273.95.camel@perches.com>
[-- Attachment #1: Type: text/plain, Size: 959 bytes --]
On Sat, Sep 17, 2016 at 7:08 AM, Joe Perches <joe@perches.com> wrote:
> On Fri, 2016-09-16 at 17:040700, Linus Torvalds wrote:
>> On Fri, Sep 16, 2016 at 4:58 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>> > Here's a totally untested patch. What do people say?
>> Heh. It looks like "pr_xyz_once()" is used in places that haven't
>> included "ratelimit.h", so this doesn't actually build for everything.
>> But I guess as a concept patch it's not hard to understand, even if
>> the implementation needs a bit of tweaking.
>
> 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.
[-- Attachment #2: printk-add-pr_warn_once_per_minute --]
[-- Type: application/octet-stream, Size: 2273 bytes --]
printk: add pr_warn_once_per_minute
From: Konstantin Khlebnikov <koct9i@gmail.com>
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
include/linux/printk.h | 16 ++++++++++++++++
mm/mmap.c | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 696a56be7d3e..af1646483dbb 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -341,11 +341,24 @@ extern asmlinkage void dump_stack(void) __cold;
} \
unlikely(__ret_print_once); \
})
+#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); \
+})
#else
#define printk_once(fmt, ...) \
no_printk(fmt, ##__VA_ARGS__)
#define printk_deferred_once(fmt, ...) \
no_printk(fmt, ##__VA_ARGS__)
+#define printk_periodic(period, fmt, ...) \
+ no_printk(fmt, ##__VA_ARGS__)
#endif
#define pr_emerg_once(fmt, ...) \
@@ -365,6 +378,9 @@ extern asmlinkage void dump_stack(void) __cold;
#define pr_cont_once(fmt, ...) \
printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn_once_per_minute(fmt, ...) \
+ printk_periodic(HZ * 60, KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+
#if defined(DEBUG)
#define pr_devel_once(fmt, ...) \
printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
diff --git a/mm/mmap.c b/mm/mmap.c
index ca9d91bca0d6..34f9fb2adcab 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2935,7 +2935,7 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages)
mm->data_vm + npages <= rlimit_max(RLIMIT_DATA) >> PAGE_SHIFT)
return true;
if (!ignore_rlimit_data) {
- pr_warn_once("%s (%d): VmData %lu exceed data ulimit %lu. Update limits or use boot option ignore_rlimit_data.\n",
+ pr_warn_once_per_minute("%s (%d): VmData %lu exceed data ulimit %lu. Update limits or use boot option ignore_rlimit_data.\n",
current->comm, current->pid,
(mm->data_vm + npages) << PAGE_SHIFT,
rlimit(RLIMIT_DATA));
next prev parent reply other threads:[~2016-09-17 8:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 15:16 Laura Abbott
2016-09-16 17:46 ` Linus Torvalds
2016-09-16 20:10 ` Laura Abbott
2016-09-16 20:32 ` Linus Torvalds
2016-09-16 22:30 ` Sam Varshavchik
2016-09-16 23:58 ` Linus Torvalds
2016-09-17 0:04 ` Linus Torvalds
2016-09-17 4:08 ` Joe Perches
2016-09-17 8:33 ` Konstantin Khlebnikov [this message]
2016-09-17 9:09 ` Cyrill Gorcunov
2016-09-17 12:09 ` Konstantin Khlebnikov
2016-09-17 12:20 ` Cyrill Gorcunov
2016-09-17 21:40 ` Konstantin Khlebnikov
2016-09-17 21:52 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALYGNiNuF1Ggy=DyYG32HXbnJp3Q0cX9ekQ5w2jR1M9rkKaX9A@mail.gmail.com' \
--to=koct9i@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=borntraeger@de.ibm.com \
--cc=fix@bitrealm.com \
--cc=gorcunov@openvz.org \
--cc=joe@perches.com \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@kernel.org \
--cc=mrsam@courier-mta.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox