summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-06-23 18:55:44 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-06-23 18:55:44 -0700
commit6a948bc8ac0d7b3c4bf1a46838fb3786ecffbd93 (patch)
tree77b1a49078e399ce48764873e47a7a06a96a7e7a /include
parent26b193e6bf56a27bc9ffe759f1c3b384c309a0a6 (diff)
[PATCH] nr_pagecache can go negative
We use per-cpu counters for the system-wide pagecache accounting. The counters spill into the global nr_pagecache atomic_t when they underflow or overflow. Hence it is possible, under weird circumstances, for nr_pagecache to go negative. Anton says he has hit this. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/pagemap.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 427b696f484b..4da205f3cb26 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -8,6 +8,7 @@
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/highmem.h>
+#include <linux/compiler.h>
#include <asm/uaccess.h>
#include <linux/gfp.h>
@@ -136,7 +137,10 @@ static inline void pagecache_acct(int count)
static inline unsigned long get_page_cache_size(void)
{
- return atomic_read(&nr_pagecache);
+ int ret = atomic_read(&nr_pagecache);
+ if (unlikely(ret < 0))
+ ret = 0;
+ return ret;
}
static inline pgoff_t linear_page_index(struct vm_area_struct *vma,