[PATCH 2/5] pagemap: Change kpagecount to return the map count, not the reference count, of a page.

From: Thomas Tuttle
Date: Thu Jun 05 2008 - 11:04:58 EST


When trying to use pagemap to calculate the "proportional set size"
[1] of a process, I discovered that there were often references to
pages that could not be discovered by kpagecount. I changed
kpagecount to return the number of times a page is mapped, rather than
referenced, so kpagecount is more useful for determining how many
processes are using a page.


[1] PSS is the amount of memory used by a process, weighted by 1 / the
number of processes sharing the memory -- so a 128K library shared by
2 processes counts as 64K PSS for each of them.
From ff2e2842b7662322068e5602afc82d5ad2ee827f Mon Sep 17 00:00:00 2001
From: Thomas Tuttle <ttuttle@xxxxxxxxxx>
Date: Thu, 5 Jun 2008 09:39:12 -0400
Subject: [PATCH] Changed kpagecount to return the map count, not the reference count, of a page.
This ensures that, if you read the pagemap of every process, and tally the
number of references to a page, it matches what is in kpagecount.

---
fs/proc/proc_misc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 32dc14c..5a16090 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -726,7 +726,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
if (!ppage)
pcount = 0;
else
- pcount = atomic_read(&ppage->_count);
+ pcount = page_mapcount(ppage);

if (put_user(pcount, out++)) {
ret = -EFAULT;
--
1.5.3.6