All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add vmalloc instrumentation
@ 2002-08-26 15:56 Dave Hansen
  0 siblings, 0 replies; only message in thread
From: Dave Hansen @ 2002-08-26 15:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Martin J. Bligh, linux-mm

[-- Attachment #1: Type: text/plain, Size: 332 bytes --]

I run out of vmalloc space fairly often.  This patch helps me to figure
out whether I'm seeing vmalloc space fragmentation, or I've actually out
of vmalloc area.  It adds 3 fields to /proc/meminfo: total vmalloc
space, used vmalloc space, and the largest remaining chunk of free
vmalloc space.   
-- 
Dave Hansen
haveblue@us.ibm.com

[-- Attachment #2: vmalloc-stats-2.5.31+bk-1.patch --]
[-- Type: text/plain, Size: 2478 bytes --]

--- linux-2.5/fs/proc/proc_misc.c	Tue Aug 13 15:40:44 2002
+++ linux-2.5-vmalloc-stats-work/fs/proc/proc_misc.c	Mon Aug 26 08:43:17 2002
@@ -37,6 +37,7 @@
 #include <linux/smp_lock.h>
 #include <linux/seq_file.h>
 #include <linux/times.h>
+#include <linux/vmalloc.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -126,6 +127,41 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+struct vmalloc_info {
+	unsigned long used;
+	unsigned long largest_chunk;
+};
+
+static struct vmalloc_info get_vmalloc_info(void)
+{
+	unsigned long addr = VMALLOC_START;
+	struct vm_struct** p;
+	struct vm_struct* tmp;
+	struct vmalloc_info vmi;
+	vmi.used = 0;
+
+	read_lock(&vmlist_lock);
+	if( !vmlist ) {
+		vmi.largest_chunk = (unsigned long)vmlist->addr-VMALLOC_START;
+	} else {
+		vmi.largest_chunk = 0;
+	}
+	
+        for (p = &vmlist; (tmp = *p) ;p = &tmp->next) {
+		unsigned long free_area_size = 
+			(unsigned long)tmp->addr - (unsigned long)addr;
+		vmi.used += tmp->size;
+                if (vmi.largest_chunk < free_area_size ) {
+                        vmi.largest_chunk = free_area_size;
+		}
+                addr = tmp->size + (unsigned long)tmp->addr;
+        }
+	if( VMALLOC_END-addr > vmi.largest_chunk )
+		vmi.largest_chunk = (VMALLOC_END-addr);
+	read_unlock(&vmlist_lock);
+	return vmi;
+}
+
 extern atomic_t vm_committed_space;
 
 static int meminfo_read_proc(char *page, char **start, off_t off,
@@ -134,7 +170,9 @@
 	struct sysinfo i;
 	int len, committed;
 	struct page_state ps;
-
+	unsigned long vmtot;
+	struct vmalloc_info vmi;
+	
 	get_page_state(&ps);
 /*
  * display in kilobytes.
@@ -143,6 +181,11 @@
 	si_meminfo(&i);
 	si_swapinfo(&i);
 	committed = atomic_read(&vm_committed_space);
+	
+	vmtot = (VMALLOC_END-VMALLOC_START)>>10;
+	vmi = get_vmalloc_info();
+	vmi.used >>= 10;
+	vmi.largest_chunk >>= 10;
 
 	/*
 	 * Tagged format, for easy grepping and expansion.
@@ -165,7 +208,10 @@
 		"Writeback:    %8lu kB\n"
 		"Committed_AS: %8u kB\n"
 		"PageTables:   %8lu kB\n"
-		"ReverseMaps:  %8lu\n",
+		"ReverseMaps:  %8lu\n"
+		"VmalTotal:    %8lu kB\n"
+		"VmalUsed:     %8lu kB\n"
+		"VmalChunk:    %8lu kB\n",
 		K(i.totalram),
 		K(i.freeram),
 		K(i.sharedram),
@@ -183,7 +229,10 @@
 		K(ps.nr_writeback),
 		K(committed),
 		K(ps.nr_page_table_pages),
-		ps.nr_reverse_maps
+		ps.nr_reverse_maps,
+		vmtot,
+		vmi.used,
+		vmi.largest_chunk
 		);
 
 	return proc_calc_metrics(page, start, off, count, eof, len);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-26 15:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-26 15:56 [PATCH] add vmalloc instrumentation Dave Hansen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.