pagemap: Change kpagecount to return the map count, not the reference count, of a page.
PATCH 2/5 pagemap: Change kpagecount to return the map count, not the reference count, of a page.
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 <[email protected]>
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(-)
fs/proc/proc_misc.c +1 -1
@@ -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 ;
Signature · 1 line
1.5.3.6
Quoted 6 lines · Thomas Tuttle
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.
I'm pretty sure this has been suggested before and I was just too thick-skulled to get it. Yes, the reference count is less useful.
ps: It's much prefered to send patches inline.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 9 lines · Matt Mackall
Quoted 6 lines · Thomas Tuttle
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.
Quoted 6 lines
I'm pretty sure this has been suggested before and I was just too thick-skulled to get it. Yes, the reference count is less useful.
Acked-by Matt Mackall <[email protected]>ps: It's much prefered to send patches inline.
Oh. Sorry about that. (It's been a while since I sent patches to LKML.)
--ttuttle