lkml.org 
[lkml]   [2005]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[patch 019/198] meminfo: add Cached underflow check
From
Date

From: Martin Hicks <mort@sgi.com>

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

25-akpm/fs/proc/proc_misc.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletion(-)

diff -puN fs/proc/proc_misc.c~meminfo-add-cached-underflow-check fs/proc/proc_misc.c
--- 25/fs/proc/proc_misc.c~meminfo-add-cached-underflow-check 2005-04-12 03:21:07.910934256 -0700
+++ 25-akpm/fs/proc/proc_misc.c 2005-04-12 03:21:07.914933648 -0700
@@ -126,6 +126,7 @@ static int meminfo_read_proc(char *page,
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,
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,
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),
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-04-12 20:11    [W:1.075 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site