linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] log out-of-virtual-memory events
@ 2007-05-17 16:24 Andrea Righi
  2007-05-17 18:22 ` Rik van Riel
  0 siblings, 1 reply; 37+ messages in thread
From: Andrea Righi @ 2007-05-17 16:24 UTC (permalink / raw)
  To: LKML, linux-mm

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

--

Print informations about the processes that fail to allocate virtual memory.

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

diff -urpN linux-2.6.21/mm/mmap.c linux-2.6.21-vm-log-enomem/mm/mmap.c
--- linux-2.6.21/mm/mmap.c	2007-04-26 05:08:32.000000000 +0200
+++ linux-2.6.21-vm-log-enomem/mm/mmap.c	2007-05-17 18:05:39.000000000 +0200
@@ -77,6 +77,26 @@ int sysctl_max_map_count __read_mostly =
 atomic_t vm_committed_space = ATOMIC_INIT(0);
 
 /*
+ * 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;
+
+	task_lock(current);
+	mm = current->mm;
+	if (mm)
+		total_vm = mm->total_vm;
+	task_unlock(current);
+
+	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);
+}
+
+/*
  * Check that a process has enough memory to allocate a new virtual
  * mapping. 0 means there is enough memory for the allocation to
  * succeed and -ENOMEM implies there is not.
@@ -175,6 +195,7 @@ int __vm_enough_memory(long pages, int c
 		return 0;
 error:
 	vm_unacct_memory(pages);
+	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] 37+ messages in thread

end of thread, other threads:[~2007-06-10 20:37 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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-20  0:15     ` Folkert van Heusden

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