[PATCH] add CommitLimit, Committed_AS to 2.4 strict VM overcommit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds two more lines of output to /proc/meminfo, CommitLimit
and Committed_AS. On a system running the strict VM overcommit patch,
these are useful bits of information (especially Committed_AS, which
lets you know how close you are to full committment).

This particular patch is part of a patch from the Red Hat Enterprise
Linux 3 kernel, rediffed against 2.4.33-pre1 + the strict VM overcommit
patch I posted earlier. However, the 2.6 kernel contains very similar
code that provides the same output in /proc/meminfo.

Signed-off-by: Barry K. Nathan <[email protected]>

diff -ruN linux-2.4.33-pre1-memA/Documentation/vm/overcommit-accounting linux-2.4.33-pre1-memB/Documentation/vm/overcommit-accounting
--- linux-2.4.33-pre1-memA/Documentation/vm/overcommit-accounting	Thu Dec 29 20:39:30 2005
+++ linux-2.4.33-pre1-memB/Documentation/vm/overcommit-accounting	Thu Dec 29 20:41:05 2005
@@ -22,6 +22,13 @@
 		will never kill a process accessing pages it has mapped
 		except due to a bug (ie report it!)
 
+The overcommit policy is set via the sysctl `vm.overcommit_memory'.
+
+The overcommit percentage is set via `vm.overcommit_ratio'.
+
+The current overcommit limit and amount committed are viewable in
+/proc/meminfo as CommitLimit and Committed_AS respectively.
+
 Gotchas
 -------
 
diff -ruN linux-2.4.33-pre1-memA/fs/proc/proc_misc.c linux-2.4.33-pre1-memB/fs/proc/proc_misc.c
--- linux-2.4.33-pre1-memA/fs/proc/proc_misc.c	Thu Dec 29 20:39:30 2005
+++ linux-2.4.33-pre1-memB/fs/proc/proc_misc.c	Thu Dec 29 20:41:05 2005
@@ -158,11 +158,9 @@
 	struct sysinfo i;
 	int len;
 	int pg_size ;
-	int committed;
+	unsigned long committed;
+	unsigned long allowed;
 
-	/* FIXME: needs to be in headers */
-	extern atomic_t vm_committed_space;
-	
 /*
  * display in kilobytes.
  */
@@ -172,6 +170,8 @@
 	si_swapinfo(&i);
 	pg_size = page_cache_size - i.bufferram;
 	committed = atomic_read(&vm_committed_space);
+	allowed = (i.totalram * sysctl_overcommit_ratio / 100)
+		  + total_swap_pages;
 
 	len = sprintf(page, "        total:    used:    free:  shared: buffers:  cached:\n"
 		"Mem:  %8Lu %8Lu %8Lu %8Lu %8Lu %8Lu\n"
@@ -199,7 +199,9 @@
 		"LowTotal:     %8lu kB\n"
 		"LowFree:      %8lu kB\n"
 		"SwapTotal:    %8lu kB\n"
-		"SwapFree:     %8lu kB\n",
+		"SwapFree:     %8lu kB\n"
+		"CommitLimit:  %8lu kB\n"
+		"Committed_AS: %8lu kB\n",
 		K(i.totalram),
 		K(i.freeram),
 		K(i.sharedram),
@@ -213,7 +215,9 @@
 		K(i.totalram-i.totalhigh),
 		K(i.freeram-i.freehigh),
 		K(i.totalswap),
-		K(i.freeswap));
+		K(i.freeswap),
+		K(allowed),
+		K(committed));
 
 	return proc_calc_metrics(page, start, off, count, eof, len);
 #undef B
diff -ruN linux-2.4.33-pre1-memA/include/linux/mman.h linux-2.4.33-pre1-memB/include/linux/mman.h
--- linux-2.4.33-pre1-memA/include/linux/mman.h	Thu Dec 29 20:39:30 2005
+++ linux-2.4.33-pre1-memB/include/linux/mman.h	Thu Dec 29 20:41:05 2005
@@ -9,5 +9,7 @@
 extern int vm_enough_memory(long pages);
 extern void vm_unacct_memory(long pages);
 extern void vm_validate_enough(char *x);
+extern atomic_t vm_committed_space;
+extern int sysctl_overcommit_ratio;
 
 #endif /* _LINUX_MMAN_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux