From: Maxim Levitsky <maximlevitsky@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [RFC] [PATCH] Add more info to /proc/$pid/smaps
Date: Fri, 5 Oct 2007 12:43:43 +0200 [thread overview]
Message-ID: <200710051243.43222.maximlevitsky@gmail.com> (raw)
In-Reply-To: <200710051242.41867.maximlevitsky@gmail.com>
>From 145247b8e776b32c9930018ab65bb6c5401e28ef Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <maximlevitsky@gmail.com>
Date: Fri, 5 Oct 2007 08:04:03 +0200
Subject: [PATCH] Add more statistics to /proc/$pid/smaps
Add amount of swapped memory and amount of anonymous memory
to /proc/$pid/smaps
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
fs/proc/task_mmu.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c24d81a..1c16a7e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -122,6 +122,9 @@ struct mem_size_stats
unsigned long private_clean;
unsigned long private_dirty;
unsigned long referenced;
+ unsigned long swapped;
+ unsigned long anon;
+
};
struct pmd_walker {
@@ -195,6 +198,8 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
seq_printf(m,
"Size: %8lu kB\n"
"Rss: %8lu kB\n"
+ "Swapped: %8lu kB\n"
+ "Anonymous: %8lu kB\n"
"Shared_Clean: %8lu kB\n"
"Shared_Dirty: %8lu kB\n"
"Private_Clean: %8lu kB\n"
@@ -202,6 +207,8 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
"Referenced: %8lu kB\n",
(vma->vm_end - vma->vm_start) >> 10,
mss->resident >> 10,
+ mss->swapped >> 10,
+ mss->anon >> 10,
mss->shared_clean >> 10,
mss->shared_dirty >> 10,
mss->private_clean >> 10,
@@ -230,15 +237,22 @@ static void smaps_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
for (; addr != end; pte++, addr += PAGE_SIZE) {
ptent = *pte;
- if (!pte_present(ptent))
- continue;
+ if (!pte_present(ptent)) {
+ if(pte_none(ptent) || pte_file(ptent))
+ continue;
+ mss->swapped += PAGE_SIZE;
+ continue;
+ }
mss->resident += PAGE_SIZE;
page = vm_normal_page(vma, addr, ptent);
if (!page)
continue;
+ if(PageAnon(page))
+ mss->anon += PAGE_SIZE;
+
/* Accumulate the size in pages that have been accessed. */
if (pte_young(ptent) || PageReferenced(page))
mss->referenced += PAGE_SIZE;
--
1.5.2.5
prev parent reply other threads:[~2007-10-05 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-05 10:42 [RFC] [PATCH] Add more info to /proc/$pid/smaps Maxim Levitsky
2007-10-05 10:43 ` Maxim Levitsky [this message]
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=200710051243.43222.maximlevitsky@gmail.com \
--to=maximlevitsky@gmail.com \
--cc=linux-kernel@vger.kernel.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