Commit 6a948bc8 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 26b193e6
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment