linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <righiandr@users.sourceforge.net>
To: Bernd Eckenfels <ecki@lina.inka.de>
Cc: linux-kernel@vger.kernel.org, Rik van Riel <riel@redhat.com>,
	linux-mm@kvack.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events)
Date: Sat, 19 May 2007 12:34:01 +0200 (MEST)	[thread overview]
Message-ID: <464ED292.8020202@users.sourceforge.net> (raw)
In-Reply-To: <E1Hp5RZ-0001CF-00@calista.eckenfels.net>

Bernd Eckenfels wrote:
> In article <464DCC52.7090403@users.sourceforge.net> you wrote:
>> +       printk(KERN_INFO
>> +              "out of virtual memory for process %d (%s): total_vm=%lu, uid=%d\n",
>> +               current->pid, current->comm, total_vm, current->uid);
> 
> And align this one with the print_fatal layout:
> 
>        printk(KERN_WARNING
>               "%s/%d process cannot request more virtual memory: total_vm=%lu, uid=%d\n",
>                current->comm, current->pid, total_vm, current->uid);
> 

Depends on print_fatal_signals patch.

---

Print informations about userspace processes that fail to allocate new virtual
memory.

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

diff -urpN linux-2.6.22-rc1-mm1/mm/mmap.c linux-2.6.22-rc1-mm1-vm-log-enomem/mm/mmap.c
--- linux-2.6.22-rc1-mm1/mm/mmap.c	2007-05-19 11:25:24.000000000 +0200
+++ linux-2.6.22-rc1-mm1-vm-log-enomem/mm/mmap.c	2007-05-19 11:55:05.000000000 +0200
@@ -77,6 +77,31 @@ int sysctl_overcommit_ratio = 50;	/* def
 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
 atomic_t vm_committed_space = ATOMIC_INIT(0);
 
+extern int print_fatal_signals;
+
+/*
+ * Print current process informations when it fails to allocate new virtual
+ * memory.
+ */
+static inline void log_vm_enomem(void)
+{
+	unsigned long total_vm = 0;
+	struct mm_struct *mm;
+
+	if (unlikely(!printk_ratelimit()))
+		return;
+
+	task_lock(current);
+	mm = current->mm;
+	if (mm)
+		total_vm = mm->total_vm;
+	task_unlock(current);
+
+	printk(KERN_WARNING
+	       "%s/%d process cannot request more virtual memory: total_vm=%lu, uid=%d\n",
+	       current->comm, current->pid, total_vm, current->uid);
+}
+
 /*
  * Check that a process has enough memory to allocate a new virtual
  * mapping. 0 means there is enough memory for the allocation to
@@ -177,6 +202,9 @@ int __vm_enough_memory(long pages, int c
 error:
 	vm_unacct_memory(pages);
 
+	if (print_fatal_signals)
+		log_vm_enomem();
+
 	return -ENOMEM;
 } 

  reply	other threads:[~2007-05-19 10:34 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-17 16:24 [RFC] log out-of-virtual-memory events 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 11:26                           ` Gábor Lénárt
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
2007-05-18 16:34           ` Bernd Eckenfels
2007-05-19 10:33             ` [PATCH 1/2] limit print_fatal_signal() rate (was: [RFC] log out-of-virtual-memory events) Andrea Righi
2007-05-21  3:31               ` Andrew Morton
2007-05-21 10:44                 ` [PATCH 1/2] limit print_fatal_signal() rate Andrea Righi
2007-05-24  7:58                 ` [PATCH 1/2] limit print_fatal_signal() rate (was: [RFC] log out-of-virtual-memory events) Ingo Molnar
2007-05-24  8:15                   ` Andrew Morton
2007-05-24  9:55                     ` Ingo Molnar
2007-05-24 16:23                       ` Andrew Morton
2007-05-24  8:50                   ` [PATCH 1/2] limit print_fatal_signal() rate Andrea Righi
2007-05-24  9:58                     ` Ingo Molnar
2007-05-24  9:57                   ` [PATCH 1/2] limit print_fatal_signal() rate (was: [RFC] log out-of-virtual-memory events) Ingo Molnar
2007-05-18 16:36         ` [RFC] log out-of-virtual-memory events Bernd Eckenfels
2007-05-19 10:34           ` Andrea Righi [this message]
2007-05-21  3:32             ` [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events) Andrew Morton
2007-05-21 10:48               ` [PATCH 2/2] log out-of-virtual-memory events Andrea Righi
2007-05-20  0:15     ` [RFC] " 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=464ED292.8020202@users.sourceforge.net \
    --to=righiandr@users.sourceforge.net \
    --cc=akpm@linux-foundation.org \
    --cc=ecki@lina.inka.de \
    --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;
as well as URLs for NNTP newsgroup(s).