linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <righiandr@users.sourceforge.net>
To: Robin Holt <holt@sgi.com>
Cc: Rik van Riel <riel@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC] log out-of-virtual-memory events
Date: Fri, 18 May 2007 18:05:11 +0200 (MEST)	[thread overview]
Message-ID: <464DCEAB.3090905@users.sourceforge.net> (raw)
In-Reply-To: <464DCC52.7090403@users.sourceforge.net>

Andrea Righi wrote:
> Robin Holt wrote:
>> On Fri, May 18, 2007 at 09:50:03AM +0200, Andrea Righi wrote:
>>> Rik van Riel wrote:
>>>> Andrea Righi wrote:
>>>>> I'm looking for a way to keep track of the processes that fail to
>>>>> allocate new
>>>>> virtual memory. What do you think about the following approach
>>>>> (untested)?
>>>> Looks like an easy way for users to spam syslogd over and
>>>> over and over again.
>>>>
>>>> At the very least, shouldn't this be dependant on print_fatal_signals?
>>>>
>>> Anyway, with print-fatal-signals enabled a user could spam syslogd too, simply
>>> with a (char *)0 = 0 program, but we could always identify the spam attempts
>>> logging the process uid...
>>>
>>> In any case, I agree, it should depend on that patch...
>>>
>>> What about adding a simple msleep_interruptible(SOME_MSECS) at the end of
>>> log_vm_enomem() or, at least, a might_sleep() to limit the potential spam/second
>>> rate?
>> An msleep will slow down this process, but do nothing about slowing
>> down the amount of logging.  Simply fork a few more processes and all
>> you are doing with msleep is polluting the pid space.
>>
> 
> Very true.
> 
>> What about a throttling similar to what ia64 does for floating point
>> assist faults (handle_fpu_swa()).  There is a thread flag to not log
>> the events at all.  It is rate throttled globally, but uses per cpu
>> variables for early exits.  This algorithm scaled well to a thousand
>> cpus.
> 
> Actually using printk_ratelimit() should be enough... BTW print_fatal_signals()
> should use it too.
> 

I mean, something like this...

---

Limit the rate of the printk()s in print_fatal_signal() to avoid potential DoS
problems.

Signed-off-by: Andrea Righi <a.righi@cineca.it>

diff -urpN linux-2.6.22-rc1-mm1/kernel/signal.c linux-2.6.22-rc1-mm1-limit-print_fatal_signals-rate/kernel/signal.c
--- linux-2.6.22-rc1-mm1/kernel/signal.c	2007-05-18 17:48:55.000000000 +0200
+++ linux-2.6.22-rc1-mm1-limit-print_fatal_signals-rate/kernel/signal.c	2007-05-18 17:58:13.000000000 +0200
@@ -790,6 +790,9 @@ static void print_vmas(void)
 
 static void print_fatal_signal(struct pt_regs *regs, int signr)
 {
+	if (unlikely(!printk_ratelimit()))
+		return;
+
 	printk("%s/%d: potentially unexpected fatal signal %d.\n",
 		current->comm, current->pid, signr);
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-05-18 16:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-17 16:24 Andrea Righi
2007-05-17 18:22 ` Rik van Riel
2007-05-18  6:28   ` signals logged / " Jan Engelhardt
2007-05-18 11:47     ` Andi Kleen
2007-05-19  7:46       ` Jan Engelhardt
2007-05-19  9:35         ` Andrea Righi
2007-05-19 10:06           ` Jan Engelhardt
2007-05-19 10:16             ` Andrea Righi
2007-05-20  0:14         ` Folkert van Heusden
2007-05-20  3:55           ` Eric Dumazet
2007-05-20 11:21             ` Folkert van Heusden
2007-05-20 16:08               ` Stephen Hemminger
2007-05-20 16:12                 ` Folkert van Heusden
2007-05-20 20:38                   ` Jan Engelhardt
2007-05-20 20:55                     ` Folkert van Heusden
2007-05-20 21:14                       ` Andi Kleen
2007-05-20 21:20                         ` Folkert van Heusden
2007-05-20 21:23                           ` Folkert van Heusden
2007-05-20 22:24                           ` Andi Kleen
2007-05-20 22:22                             ` Jeff Dike
2007-05-21 10:45                         ` Andrea Righi
2007-05-21 11:04                           ` Folkert van Heusden
2007-05-21 12:30                             ` Jan Engelhardt
2007-05-21 12:47                               ` Folkert van Heusden
2007-05-21 13:58                                 ` Andrea Righi
2007-05-21 18:59                                   ` Folkert van Heusden
2007-05-21 22:15                                     ` Andrea Righi
2007-05-23 18:00                                 ` Satyam Sharma
2007-05-23 18:45                                   ` Folkert van Heusden
2007-06-10 19:53                                     ` Folkert van Heusden
2007-06-10 20:06                                       ` Jiri Kosina
2007-06-10 20:37                                         ` Jan Engelhardt
2007-05-18  7:50   ` Andrea Righi
2007-05-18  9:16     ` Robin Holt
2007-05-18 15:55       ` Andrea Righi
2007-05-18 16:05         ` Andrea Righi [this message]
2007-05-20  0:15     ` Folkert van Heusden

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=464DCEAB.3090905@users.sourceforge.net \
    --to=righiandr@users.sourceforge.net \
    --cc=akpm@linux-foundation.org \
    --cc=holt@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@elte.hu \
    --cc=riel@redhat.com \
    /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