提交 4c4c402d 编写于 作者: M Martin Hicks 提交者: Linus Torvalds

[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: NMartin Hicks <mort@sgi.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 76c3073a
......@@ -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),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册