linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Xiaokang Qin <xiaokang.qin@intel.com>
To: linux-mm@kvack.org
Cc: fengwei.yin@intel.com, Xiaokang Qin <xiaokang.qin@intel.com>
Subject: [PATCH] proc/smaps: add proportional size of anonymous page
Date: Fri,  7 Nov 2014 16:31:28 +0800	[thread overview]
Message-ID: <1415349088-24078-1-git-send-email-xiaokang.qin@intel.com> (raw)

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>

             reply	other threads:[~2014-11-07  8:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07  8:31 Xiaokang Qin [this message]
2014-11-07 21:34 ` [PATCH] proc/smaps: add proportional size of anonymous page 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415349088-24078-1-git-send-email-xiaokang.qin@intel.com \
    --to=xiaokang.qin@intel.com \
    --cc=fengwei.yin@intel.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).