linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc/smaps: add proportional size of anonymous page
@ 2014-11-07  8:31 Xiaokang Qin
  2014-11-07 21:34 ` Dave Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Xiaokang Qin @ 2014-11-07  8:31 UTC (permalink / raw)
  To: linux-mm; +Cc: fengwei.yin, Xiaokang Qin

Anonymous page could be shared if allocated before process fork. On Android, all
applications are forked from Zygote and it makes shared anonymous page common in
Android. Currently, the "Anonymous" in smaps doesn't reflect the shared count.
A proportional anonymous page size is better to understand the anonymous page
that the applications really using.
The "proportional anonymous page size" (PropAnonymous) of a process is the count of
anonymous pages it has in memory, where each anonymous page is devided by the number
of processes sharing it.

Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
---
 fs/proc/task_mmu.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index cfa63ee..74a4f42 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -442,6 +442,7 @@ struct mem_size_stats {
 	unsigned long swap;
 	unsigned long nonlinear;
 	u64 pss;
+	u64 panon;
 };
 
 
@@ -488,12 +489,16 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
 		else
 			mss->shared_clean += ptent_size;
 		mss->pss += (ptent_size << PSS_SHIFT) / mapcount;
+		if (PageAnon(page))
+			mss->panon += (ptent_size << PSS_SHIFT) / mapcount;
 	} else {
 		if (pte_dirty(ptent) || PageDirty(page))
 			mss->private_dirty += ptent_size;
 		else
 			mss->private_clean += ptent_size;
 		mss->pss += (ptent_size << PSS_SHIFT);
+		if (PageAnon(page))
+			mss->panon += (ptent_size << PSS_SHIFT);
 	}
 }
 
@@ -611,6 +616,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 		   "Private_Dirty:  %8lu kB\n"
 		   "Referenced:     %8lu kB\n"
 		   "Anonymous:      %8lu kB\n"
+		   "PropAnonymous:  %8lu kB\n"
 		   "AnonHugePages:  %8lu kB\n"
 		   "Swap:           %8lu kB\n"
 		   "KernelPageSize: %8lu kB\n"
@@ -625,6 +631,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 		   mss.private_dirty >> 10,
 		   mss.referenced >> 10,
 		   mss.anonymous >> 10,
+		   (unsigned long)(mss.panon >> (10 + PSS_SHIFT)),
 		   mss.anonymous_thp >> 10,
 		   mss.swap >> 10,
 		   vma_kernel_pagesize(vma) >> 10,
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2014-11-11 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07  8:31 [PATCH] proc/smaps: add proportional size of anonymous page Xiaokang Qin
2014-11-07 21:34 ` Dave Hansen
2014-11-10  8:48   ` Qin, Xiaokang
2014-11-10 17:03     ` Dave Hansen
2014-11-11 14:40       ` Xiaokang
2014-11-11 15:22         ` Dave Hansen
2014-11-10  9:29   ` Xiaokang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).