aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Hicks <mort@sgi.com>2005-04-16 15:24:08 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:24:08 -0700
commit4c4c402d6caba5d938ffbbb49961659ecac709d4 (patch)
tree98c85314a6c8d753e27163e729a0dbc493018ce1
parent76c3073a888ae7f4790a146784bb5c34fc24b9d2 (diff)
downloadkernel_samsung_aries-4c4c402d6caba5d938ffbbb49961659ecac709d4.zip
kernel_samsung_aries-4c4c402d6caba5d938ffbbb49961659ecac709d4.tar.gz
kernel_samsung_aries-4c4c402d6caba5d938ffbbb49961659ecac709d4.tar.bz2
[PATCH] meminfo: add Cached underflow check
Working on some code lately I've been getting huge values for "Cached". The cause is that get_page_cache_size() is an approximate value, and for a sufficiently small returned value of get_page_cache_size() the value underflows. Signed-off-by: Martin Hicks <mort@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/proc/proc_misc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 1d75d6a..a60a3b3 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -126,6 +126,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
unsigned long committed;
unsigned long allowed;
struct vmalloc_info vmi;
+ long cached;
get_page_state(&ps);
get_zone_counts(&active, &inactive, &free);
@@ -140,6 +141,10 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
allowed = ((totalram_pages - hugetlb_total_pages())
* sysctl_overcommit_ratio / 100) + total_swap_pages;
+ cached = get_page_cache_size() - total_swapcache_pages - i.bufferram;
+ if (cached < 0)
+ cached = 0;
+
get_vmalloc_info(&vmi);
/*
@@ -172,7 +177,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
K(i.totalram),
K(i.freeram),
K(i.bufferram),
- K(get_page_cache_size()-total_swapcache_pages-i.bufferram),
+ K(cached),
K(total_swapcache_pages),
K(active),
K(inactive),