diff options
| author | Martin Hicks <mort@sgi.com> | 2005-04-16 18:24:08 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:24:08 -0400 |
| commit | 4c4c402d6caba5d938ffbbb49961659ecac709d4 (patch) | |
| tree | 98c85314a6c8d753e27163e729a0dbc493018ce1 | |
| parent | 76c3073a888ae7f4790a146784bb5c34fc24b9d2 (diff) | |
[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.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 1d75d6ab6897..a60a3b3d8a7b 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, | |||
| 126 | unsigned long committed; | 126 | unsigned long committed; |
| 127 | unsigned long allowed; | 127 | unsigned long allowed; |
| 128 | struct vmalloc_info vmi; | 128 | struct vmalloc_info vmi; |
| 129 | long cached; | ||
| 129 | 130 | ||
| 130 | get_page_state(&ps); | 131 | get_page_state(&ps); |
| 131 | get_zone_counts(&active, &inactive, &free); | 132 | get_zone_counts(&active, &inactive, &free); |
| @@ -140,6 +141,10 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 140 | allowed = ((totalram_pages - hugetlb_total_pages()) | 141 | allowed = ((totalram_pages - hugetlb_total_pages()) |
| 141 | * sysctl_overcommit_ratio / 100) + total_swap_pages; | 142 | * sysctl_overcommit_ratio / 100) + total_swap_pages; |
| 142 | 143 | ||
| 144 | cached = get_page_cache_size() - total_swapcache_pages - i.bufferram; | ||
| 145 | if (cached < 0) | ||
| 146 | cached = 0; | ||
| 147 | |||
| 143 | get_vmalloc_info(&vmi); | 148 | get_vmalloc_info(&vmi); |
| 144 | 149 | ||
| 145 | /* | 150 | /* |
| @@ -172,7 +177,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 172 | K(i.totalram), | 177 | K(i.totalram), |
| 173 | K(i.freeram), | 178 | K(i.freeram), |
| 174 | K(i.bufferram), | 179 | K(i.bufferram), |
| 175 | K(get_page_cache_size()-total_swapcache_pages-i.bufferram), | 180 | K(cached), |
| 176 | K(total_swapcache_pages), | 181 | K(total_swapcache_pages), |
| 177 | K(active), | 182 | K(active), |
| 178 | K(inactive), | 183 | K(inactive), |
