linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <bsingharora@gmail.com>
To: jglisse@redhat.com
Cc: linux-mm@kvack.org, mhocko@suse.com,
	Balbir Singh <bsingharora@gmail.com>
Subject: [rfc 2/2] smaps: Show zone device memory used
Date: Wed, 18 Oct 2017 17:31:23 +1100	[thread overview]
Message-ID: <20171018063123.21983-2-bsingharora@gmail.com> (raw)
In-Reply-To: <20171018063123.21983-1-bsingharora@gmail.com>

With HMM, we can have either public or private zone
device pages. With private zone device pages, they should
show up as swapped entities. For public zone device pages
the smaps output can be confusing and incomplete.

This patch adds a new attribute to just smaps to show
device memory usage.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
---
 fs/proc/task_mmu.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 9f1e2b2b5f5a..b7f32f42ee93 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -451,6 +451,7 @@ struct mem_size_stats {
 	unsigned long shared_hugetlb;
 	unsigned long private_hugetlb;
 	unsigned long first_vma_start;
+	unsigned long device_memory;
 	u64 pss;
 	u64 pss_locked;
 	u64 swap_pss;
@@ -463,12 +464,22 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page,
 	int i, nr = compound ? 1 << compound_order(page) : 1;
 	unsigned long size = nr * PAGE_SIZE;
 
+	/*
+	 * We don't want to process public zone device pages further
+	 * than just showing how much device memory we have
+	 */
+	if (is_zone_device_page(page)) {
+		mss->device_memory += size;
+		return;
+	}
+
 	if (PageAnon(page)) {
 		mss->anonymous += size;
 		if (!PageSwapBacked(page) && !dirty && !PageDirty(page))
 			mss->lazyfree += size;
 	}
 
+
 	mss->resident += size;
 	/* Accumulate the size in pages that have been accessed. */
 	if (young || page_is_young(page) || PageReferenced(page))
@@ -833,7 +844,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 			   "Private_Hugetlb: %7lu kB\n"
 			   "Swap:           %8lu kB\n"
 			   "SwapPss:        %8lu kB\n"
-			   "Locked:         %8lu kB\n",
+			   "Locked:         %8lu kB\n"
+			   "DeviceMem:      %8lu kB\n",
 			   mss->resident >> 10,
 			   (unsigned long)(mss->pss >> (10 + PSS_SHIFT)),
 			   mss->shared_clean  >> 10,
@@ -849,7 +861,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 			   mss->private_hugetlb >> 10,
 			   mss->swap >> 10,
 			   (unsigned long)(mss->swap_pss >> (10 + PSS_SHIFT)),
-			   (unsigned long)(mss->pss >> (10 + PSS_SHIFT)));
+			   (unsigned long)(mss->pss >> (10 + PSS_SHIFT)),
+			   mss->device_memory >> 10);
 
 	if (!rollup_mode) {
 		arch_show_smap(m, vma);
-- 
2.13.6

--
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:[~2017-10-18  6:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18  6:31 [rfc 1/2] mm/hmm: Allow smaps to see zone device public pages Balbir Singh
2017-10-18  6:31 ` Balbir Singh [this message]
2017-10-18  7:10   ` [rfc 2/2] smaps: Show zone device memory used Anshuman Khandual
2017-10-18 19:48     ` Balbir Singh
2017-10-19 17:02       ` Jerome Glisse
2017-10-21  1:23         ` Balbir Singh
2017-10-20 13:08   ` Michal Hocko
2017-10-20 21:55     ` Balbir Singh
2017-10-23  8:49       ` Michal Hocko
2017-10-23  9:32         ` Balbir Singh
2017-10-23  9:36           ` Michal Hocko
2017-10-23  9:37             ` Balbir Singh
2017-10-18  6:56 ` [rfc 1/2] mm/hmm: Allow smaps to see zone device public pages Anshuman Khandual
2017-10-18 19:36   ` Balbir Singh
2017-10-20 13:11 ` Michal Hocko
2017-10-20 21:52   ` Balbir Singh
2017-10-23  8:52     ` Michal Hocko

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=20171018063123.21983-2-bsingharora@gmail.com \
    --to=bsingharora@gmail.com \
    --cc=jglisse@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    /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).