All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20141015102959.GA14583@gmail.com>

diff --git a/a/2.txt b/N1/2.txt
index 8b13789..6a292ba 100644
--- a/a/2.txt
+++ b/N1/2.txt
@@ -1 +1,115 @@
+>From 3c3553bba1b4f713f2bbfadc952964905527d677 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.
 
+We could see following memory info in /proc/xxxx/smaps with THP enabled.
+  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
+which is wrong becuase just huge_zero_page/normal_zero_page is used for
+/dev/zero. Most of the value should be 0.
+
+This patch detects huge_zero_page (original implementation just detect
+normal_zero_page) and avoids to update the wrong value for huge_zero_page.
+
+Signed-off-by: Fengwei Yin <yfw.kernel@gmail.com>
+---
+ fs/proc/task_mmu.c      | 6 ++++--
+ include/linux/huge_mm.h | 2 ++
+ mm/huge_memory.c        | 5 +++++
+ mm/memory.c             | 4 ++++
+ 4 files changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
+index 4e0388c..735b389 100644
+--- a/fs/proc/task_mmu.c
++++ b/fs/proc/task_mmu.c
+@@ -474,8 +474,11 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
+ 	if (!page)
+ 		return;
+ 
+-	if (PageAnon(page))
++	if (PageAnon(page)) {
+ 		mss->anonymous += ptent_size;
++		if (PageTransHuge(page))
++			mss->anonymous_thp += HPAGE_PMD_SIZE;
++	}
+ 
+ 	if (page->index != pgoff)
+ 		mss->nonlinear += ptent_size;
+@@ -511,7 +514,6 @@ 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;
+ 		return 0;
+ 	}
+ 
+diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
+index ad9051b..7080aa1 100644
+--- a/include/linux/huge_mm.h
++++ b/include/linux/huge_mm.h
+@@ -34,6 +34,8 @@ 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_pfn(unsigned long pfn);
++
+ 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 74c78aa..7e7880c 100644
+--- a/mm/huge_memory.c
++++ b/mm/huge_memory.c
+@@ -183,6 +183,11 @@ static inline bool is_huge_zero_pmd(pmd_t pmd)
+ 	return is_huge_zero_page(pmd_page(pmd));
+ }
+ 
++bool is_huge_zero_pfn(unsigned long pfn)
++{
++	return is_huge_zero_page(pfn_to_page(pfn));
++}
++
+ static struct page *get_huge_zero_page(void)
+ {
+ 	struct page *zero_page;
+diff --git a/mm/memory.c b/mm/memory.c
+index 1cc6bfb..eebb6c5 100644
+--- a/mm/memory.c
++++ b/mm/memory.c
+@@ -41,6 +41,7 @@
+ #include <linux/kernel_stat.h>
+ #include <linux/mm.h>
+ #include <linux/hugetlb.h>
++#include <linux/huge_mm.h>
+ #include <linux/mman.h>
+ #include <linux/swap.h>
+ #include <linux/highmem.h>
+@@ -787,6 +788,9 @@ check_pfn:
+ 		return NULL;
+ 	}
+ 
++	if (is_huge_zero_pfn(pfn))
++		return NULL;
++
+ 	/*
+ 	 * NOTE! We still have PageReserved() pages in the page tables.
+ 	 * eg. VDSO mappings can cause them to exist.
+-- 
+2.0.1
diff --git a/a/content_digest b/N1/content_digest
index 8d42b2c..6f75d0d 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -193,5 +193,120 @@
  "\01:2\0"
  "fn\00001-smaps-should-deal-with-huge-zero-page-exactly-same-a.patch\0"
  "b\0"
+ ">From 3c3553bba1b4f713f2bbfadc952964905527d677 Mon Sep 17 00:00:00 2001\n"
+ "From: Fengwei Yin <yfw.kernel@gmail.com>\n"
+ "Date: Thu, 9 Oct 2014 22:20:58 +0800\n"
+ "Subject: [PATCH] smaps should deal with huge zero page exactly same as normal\n"
+ " zero page.\n"
+ "\n"
+ "We could see following memory info in /proc/xxxx/smaps with THP enabled.\n"
+ "  7bea458b3000-7fea458b3000 r--p 00000000 00:13 39989  /dev/zero\n"
+ "  Size:           4294967296 kB\n"
+ "  Rss:            10612736 kB\n"
+ "  Pss:            10612736 kB\n"
+ "  Shared_Clean:          0 kB\n"
+ "  Shared_Dirty:          0 kB\n"
+ "  Private_Clean:  10612736 kB\n"
+ "  Private_Dirty:         0 kB\n"
+ "  Referenced:     10612736 kB\n"
+ "  Anonymous:             0 kB\n"
+ "  AnonHugePages:  10612736 kB\n"
+ "  Swap:                  0 kB\n"
+ "  KernelPageSize:        4 kB\n"
+ "  MMUPageSize:           4 kB\n"
+ "  Locked:                0 kB\n"
+ "  VmFlags: rd mr mw me\n"
+ "which is wrong becuase just huge_zero_page/normal_zero_page is used for\n"
+ "/dev/zero. Most of the value should be 0.\n"
+ "\n"
+ "This patch detects huge_zero_page (original implementation just detect\n"
+ "normal_zero_page) and avoids to update the wrong value for huge_zero_page.\n"
+ "\n"
+ "Signed-off-by: Fengwei Yin <yfw.kernel@gmail.com>\n"
+ "---\n"
+ " fs/proc/task_mmu.c      | 6 ++++--\n"
+ " include/linux/huge_mm.h | 2 ++\n"
+ " mm/huge_memory.c        | 5 +++++\n"
+ " mm/memory.c             | 4 ++++\n"
+ " 4 files changed, 15 insertions(+), 2 deletions(-)\n"
+ "\n"
+ "diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c\n"
+ "index 4e0388c..735b389 100644\n"
+ "--- a/fs/proc/task_mmu.c\n"
+ "+++ b/fs/proc/task_mmu.c\n"
+ "@@ -474,8 +474,11 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,\n"
+ " \tif (!page)\n"
+ " \t\treturn;\n"
+ " \n"
+ "-\tif (PageAnon(page))\n"
+ "+\tif (PageAnon(page)) {\n"
+ " \t\tmss->anonymous += ptent_size;\n"
+ "+\t\tif (PageTransHuge(page))\n"
+ "+\t\t\tmss->anonymous_thp += HPAGE_PMD_SIZE;\n"
+ "+\t}\n"
+ " \n"
+ " \tif (page->index != pgoff)\n"
+ " \t\tmss->nonlinear += ptent_size;\n"
+ "@@ -511,7 +514,6 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,\n"
+ " \tif (pmd_trans_huge_lock(pmd, vma, &ptl) == 1) {\n"
+ " \t\tsmaps_pte_entry(*(pte_t *)pmd, addr, HPAGE_PMD_SIZE, walk);\n"
+ " \t\tspin_unlock(ptl);\n"
+ "-\t\tmss->anonymous_thp += HPAGE_PMD_SIZE;\n"
+ " \t\treturn 0;\n"
+ " \t}\n"
+ " \n"
+ "diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h\n"
+ "index ad9051b..7080aa1 100644\n"
+ "--- a/include/linux/huge_mm.h\n"
+ "+++ b/include/linux/huge_mm.h\n"
+ "@@ -34,6 +34,8 @@ extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,\n"
+ " \t\t\tunsigned long addr, pgprot_t newprot,\n"
+ " \t\t\tint prot_numa);\n"
+ " \n"
+ "+extern bool is_huge_zero_pfn(unsigned long pfn);\n"
+ "+\n"
+ " enum transparent_hugepage_flag {\n"
+ " \tTRANSPARENT_HUGEPAGE_FLAG,\n"
+ " \tTRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,\n"
+ "diff --git a/mm/huge_memory.c b/mm/huge_memory.c\n"
+ "index 74c78aa..7e7880c 100644\n"
+ "--- a/mm/huge_memory.c\n"
+ "+++ b/mm/huge_memory.c\n"
+ "@@ -183,6 +183,11 @@ static inline bool is_huge_zero_pmd(pmd_t pmd)\n"
+ " \treturn is_huge_zero_page(pmd_page(pmd));\n"
+ " }\n"
+ " \n"
+ "+bool is_huge_zero_pfn(unsigned long pfn)\n"
+ "+{\n"
+ "+\treturn is_huge_zero_page(pfn_to_page(pfn));\n"
+ "+}\n"
+ "+\n"
+ " static struct page *get_huge_zero_page(void)\n"
+ " {\n"
+ " \tstruct page *zero_page;\n"
+ "diff --git a/mm/memory.c b/mm/memory.c\n"
+ "index 1cc6bfb..eebb6c5 100644\n"
+ "--- a/mm/memory.c\n"
+ "+++ b/mm/memory.c\n"
+ "@@ -41,6 +41,7 @@\n"
+ " #include <linux/kernel_stat.h>\n"
+ " #include <linux/mm.h>\n"
+ " #include <linux/hugetlb.h>\n"
+ "+#include <linux/huge_mm.h>\n"
+ " #include <linux/mman.h>\n"
+ " #include <linux/swap.h>\n"
+ " #include <linux/highmem.h>\n"
+ "@@ -787,6 +788,9 @@ check_pfn:\n"
+ " \t\treturn NULL;\n"
+ " \t}\n"
+ " \n"
+ "+\tif (is_huge_zero_pfn(pfn))\n"
+ "+\t\treturn NULL;\n"
+ "+\n"
+ " \t/*\n"
+ " \t * NOTE! We still have PageReserved() pages in the page tables.\n"
+ " \t * eg. VDSO mappings can cause them to exist.\n"
+ "-- \n"
+ 2.0.1
 
-694e69ce867aee9299559060935a7cbc75728e094290e83358c083a28cc2fd53
+26efae328ddfdc1901af164d811859a2a319196e69a1554ad4a486a1963b4750

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.