linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events)
       [not found] <E1Hp5RZ-0001CF-00@calista.eckenfels.net>
@ 2007-05-19 10:34 ` Andrea Righi
  2007-05-21  3:32   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Righi @ 2007-05-19 10:34 UTC (permalink / raw)
  To: Bernd Eckenfels
  Cc: linux-kernel, Rik van Riel, linux-mm, Ingo Molnar, Andrew Morton

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;
 } 

--
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events)
  2007-05-19 10:34 ` [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events) Andrea Righi
@ 2007-05-21  3:32   ` Andrew Morton
  2007-05-21 10:48     ` [PATCH 2/2] log out-of-virtual-memory events Andrea Righi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-05-21  3:32 UTC (permalink / raw)
  To: righiandr
  Cc: Bernd Eckenfels, linux-kernel, Rik van Riel, linux-mm, Ingo Molnar

On Sat, 19 May 2007 12:34:01 +0200 (MEST) Andrea Righi <righiandr@users.sourceforge.net> wrote:

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

Why is this useful?

--
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] log out-of-virtual-memory events
  2007-05-21  3:32   ` Andrew Morton
@ 2007-05-21 10:48     ` Andrea Righi
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Righi @ 2007-05-21 10:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Bernd Eckenfels, linux-kernel, Rik van Riel, linux-mm, Ingo Molnar

Andrew Morton wrote:
> On Sat, 19 May 2007 12:34:01 +0200 (MEST) Andrea Righi <righiandr@users.sourceforge.net> wrote:
> 
>> Print informations about userspace processes that fail to allocate new virtual
>> memory.
> 
> Why is this useful?
> 

Well... in strict overcommit mode (overcommit_memory=2) this is the only way to
track down problems of the (bad-designed) user applications that exit when they
receive a -ENOMEM without logging anything... and, anyway, it could be an
additional aid in figuring out what is going wrong on inside a system. BTW, I
don't think it should be enabled by default, so this is the reason why it should
depend on print_fatal_signals patch.

-Andrea

--
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-21 10:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1Hp5RZ-0001CF-00@calista.eckenfels.net>
2007-05-19 10:34 ` [PATCH 2/2] log out-of-virtual-memory events (was: [RFC] log out-of-virtual-memory events) Andrea Righi
2007-05-21  3:32   ` Andrew Morton
2007-05-21 10:48     ` [PATCH 2/2] log out-of-virtual-memory events Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox