mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + proc-mm-export-pte-sizes-directly-in-smaps-v3.patch added to -mm tree
@ 2016-11-30 21:42 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2016-11-30 21:42 UTC (permalink / raw)
  To: dave.hansen, dan.j.williams, hch, khandual, vbabka, mm-commits


The patch titled
     Subject: proc-mm-export-pte-sizes-directly-in-smaps-v3
has been added to the -mm tree.  Its filename is
     proc-mm-export-pte-sizes-directly-in-smaps-v3.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/proc-mm-export-pte-sizes-directly-in-smaps-v3.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/proc-mm-export-pte-sizes-directly-in-smaps-v3.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Dave Hansen <dave.hansen@linux.intel.com>
Subject: proc-mm-export-pte-sizes-directly-in-smaps-v3

Changes from v2:
 * Do not assume (wrongly) that smaps_hugetlb_range() always uses
   PUDs.  (Thanks for pointing this out, Vlastimil).  Also handle
   hstates that are not exactly at PMD/PUD sizes.

Link: http://lkml.kernel.org/r/20161129201703.CE9D5054@viggo.jf.intel.com
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/task_mmu.c |   27 ++++++++++++++++++++++++++-
 mm/hugetlb.c       |   11 +++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff -puN fs/proc/task_mmu.c~proc-mm-export-pte-sizes-directly-in-smaps-v3 fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c~proc-mm-export-pte-sizes-directly-in-smaps-v3
+++ a/fs/proc/task_mmu.c
@@ -689,6 +689,30 @@ static void show_smap_vma_flags(struct s
 }
 
 #ifdef CONFIG_HUGETLB_PAGE
+/*
+ * Most architectures have a 1:1 mapping of PTEs to hugetlb page
+ * sizes, but there are some outliers like arm64 that use
+ * multiple hardware PTEs to make a hugetlb "page".  Do not
+ * assume that all 'hpage_size's are not exactly at a page table
+ * size boundary.  Instead, accept arbitrary 'hpage_size's and
+ * assume they are made up of the next-smallest size.  We do not
+ * handle PGD-sized hpages and hugetlb_add_hstate() will WARN()
+ * if it sees one.
+ *
+ * Note also that the page walker code only calls us once per
+ * huge 'struct page', *not* once per PTE in the page tables.
+ */
+static void smaps_hugetlb_present_hpage(struct mem_size_stats *mss,
+					unsigned long hpage_size)
+{
+	if (hpage_size >= PUD_SIZE)
+		mss->rss_pud += hpage_size;
+	else if (hpage_size >= PMD_SIZE)
+		mss->rss_pmd += hpage_size;
+	else
+		mss->rss_pte += hpage_size;
+}
+
 static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask,
 				 unsigned long addr, unsigned long end,
 				 struct mm_walk *walk)
@@ -709,7 +733,8 @@ static int smaps_hugetlb_range(pte_t *pt
 		int mapcount = page_mapcount(page);
 		unsigned long hpage_size = huge_page_size(hstate_vma(vma));
 
-		mss->rss_pud += hpage_size;
+		smaps_hugetlb_present_hpage(mss, hpage_size);
+
 		if (mapcount >= 2)
 			mss->shared_hugetlb += hpage_size;
 		else
diff -puN mm/hugetlb.c~proc-mm-export-pte-sizes-directly-in-smaps-v3 mm/hugetlb.c
--- a/mm/hugetlb.c~proc-mm-export-pte-sizes-directly-in-smaps-v3
+++ a/mm/hugetlb.c
@@ -2905,6 +2905,17 @@ void __init hugetlb_add_hstate(unsigned
 					huge_page_size(h)/1024);
 
 	parsed_hstate = h;
+
+	/*
+	 * PGD_SIZE isn't widely made available by architecures,
+	 * so use PUD_SIZE*PTRS_PER_PUD as a substitute.
+	 *
+	 * Check for sizes that might be mapped by a PGD.  There
+	 * are none of these known today, but be on the lookout.
+	 * If this trips, we will need to update the mss->rss_*
+	 * code in fs/proc/task_mmu.c.
+	 */
+	WARN_ON_ONCE((PAGE_SIZE << order) >= PUD_SIZE * PTRS_PER_PUD);
 }
 
 static int __init hugetlb_nrpages_setup(char *s)
_

Patches currently in -mm which might be from dave.hansen@linux.intel.com are

proc-mm-export-pte-sizes-directly-in-smaps-v2.patch
proc-mm-export-pte-sizes-directly-in-smaps-v3.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-30 21:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-30 21:42 + proc-mm-export-pte-sizes-directly-in-smaps-v3.patch added to -mm tree akpm

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