mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/5] pagemap: Change kpagecount to return the map count, not the reference count, of a page.
@ 2008-06-05 15:04 Thomas Tuttle
  2008-06-05 16:01 ` Matt Mackall
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Tuttle @ 2008-06-05 15:04 UTC (permalink / raw)
  To: mpm, akpm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Changed-kpagecount-to-return-the-map-count-not-the.patch --]
[-- Type: text/x-patch; name=0002-Changed-kpagecount-to-return-the-map-count-not-the.patch, Size: 885 bytes --]

From ff2e2842b7662322068e5602afc82d5ad2ee827f Mon Sep 17 00:00:00 2001
From: Thomas Tuttle <ttuttle@google.com>
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-05 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-05 15:04 [PATCH 2/5] pagemap: Change kpagecount to return the map count, not the reference count, of a page Thomas Tuttle
2008-06-05 16:01 ` Matt Mackall
2008-06-05 16:03   ` Thomas Tuttle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®