linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smaps should deal with huge zero page exactly same as normal zero page
@ 2014-10-09  9:19 Fengwei Yin
  2014-10-09 16:36 ` Dave Hansen
  0 siblings, 1 reply; 9+ messages in thread
From: Fengwei Yin @ 2014-10-09  9:19 UTC (permalink / raw)
  To: LKML, linux-mm; +Cc: fengguang.wu

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

Hi,
Fengguang found that the RSS/PSS shown in smaps is not correct
if the file is /dev/zero.

Example:
7bea458b3000-7fea458b3000 r--p 00000000 00:13 39989
  /dev/zero
Size:           4294967296 kB
Rss:            10612736 kB
Pss:            10612736 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:  10612736 kB
Private_Dirty:         0 kB
Referenced:     10612736 kB
Anonymous:             0 kB
AnonHugePages:  10612736 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd mr mw me

[-- Attachment #2: 0001-smaps-should-deal-with-huge-zero-page-exactly-same.patch --]
[-- Type: application/octet-stream, Size: 2225 bytes --]

From 5e861d550f851040c4d0458ebd3f0fd8fe94dadd Mon Sep 17 00:00:00 2001
From: Fengwei Yin <yfw.kernel@gmail.com>
Date: Thu, 9 Oct 2014 22:20:58 +0800
Subject: [PATCH] smaps should deal with huge zero page exactly same as normal
 zero page.

Signed-off-by: Fengwei Yin <yfw.kernel@gmail.com>
---
 fs/proc/task_mmu.c      | 5 +++--
 include/linux/huge_mm.h | 4 ++++
 mm/huge_memory.c        | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 80ca4fb..8550b27 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -476,7 +476,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
 			mss->nonlinear += ptent_size;
 	}
 
-	if (!page)
+	if (!page || is_huge_zero_page(page))
 		return;
 
 	if (PageAnon(page))
@@ -516,7 +516,8 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 	if (pmd_trans_huge_lock(pmd, vma, &ptl) == 1) {
 		smaps_pte_entry(*(pte_t *)pmd, addr, HPAGE_PMD_SIZE, walk);
 		spin_unlock(ptl);
-		mss->anonymous_thp += HPAGE_PMD_SIZE;
+		if (!is_huge_zero_pmd(*pmd))
+			mss->anonymous_thp += HPAGE_PMD_SIZE;
 		return 0;
 	}
 
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 63579cb..758f569 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -34,6 +34,10 @@ extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
 			unsigned long addr, pgprot_t newprot,
 			int prot_numa);
 
+extern bool is_huge_zero_page(struct page *page);
+
+extern bool is_huge_zero_pmd(pmd_t pmd);
+
 enum transparent_hugepage_flag {
 	TRANSPARENT_HUGEPAGE_FLAG,
 	TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index d9a21d06..bedc3ae 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -173,12 +173,12 @@ static int start_khugepaged(void)
 static atomic_t huge_zero_refcount;
 static struct page *huge_zero_page __read_mostly;
 
-static inline bool is_huge_zero_page(struct page *page)
+bool is_huge_zero_page(struct page *page)
 {
 	return ACCESS_ONCE(huge_zero_page) == page;
 }
 
-static inline bool is_huge_zero_pmd(pmd_t pmd)
+bool is_huge_zero_pmd(pmd_t pmd)
 {
 	return is_huge_zero_page(pmd_page(pmd));
 }
-- 
2.0.1


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

end of thread, other threads:[~2014-10-17  2:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-09  9:19 [PATCH] smaps should deal with huge zero page exactly same as normal zero page Fengwei Yin
2014-10-09 16:36 ` Dave Hansen
2014-10-10  9:33   ` Fengwei Yin
2014-10-10 13:21   ` Fengwei Yin
2014-10-10 14:35     ` Dave Hansen
2014-10-11 10:11       ` Fengwei Yin
2014-10-17 10:46       ` Fengwei Yin
2014-10-14 11:57     ` Kirill A. Shutemov
2014-10-15 10:30       ` Fengwei Yin

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).