Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1316972 > unrolled thread

[PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390

Started byMichael Holzheu <holzheu@linux.vnet.ibm.com>
First post2016-01-25 17:40 +0100
Last post2016-01-26 12:00 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390 Michael Holzheu <holzheu@linux.vnet.ibm.com> - 2016-01-25 17:40 +0100
    Re: [PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390 Andrew Morton <akpm@linux-foundation.org> - 2016-01-26 00:00 +0100
      Re: [PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390 Michael Holzheu <holzheu@linux.vnet.ibm.com> - 2016-01-26 12:00 +0100

#1316972 — [PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390

FromMichael Holzheu <holzheu@linux.vnet.ibm.com>
Date2016-01-25 17:40 +0100
Subject[PATCH] numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390
Message-ID<qUSlk-6Ia-25@gated-at.bofh.it>
When working with hugetlbfs ptes (which are actually pmds) is not
valid to directly use pte functions like pte_present() because the
hardware bit layout of pmds and ptes can be different. This is the
case on s390. Therefore we have to convert the hugetlbfs ptes first
into a valid pte encoding with huge_ptep_get().

Currently the /proc/<pid>/numa_maps code uses hugetlbfs ptes without
huge_ptep_get(). On s390 this leads to the following two problems:

1) The pte_present() function returns false (instead of true) for
   PROT_NONE hugetlb ptes. Therefore PROT_NONE vmas are missing
   completely in the "numa_maps" output.

2) The pte_dirty() function always returns false for all hugetlb ptes.
   Therefore these pages are reported as "mapped=xxx" instead of
   "dirty=xxx".

Therefore use huge_ptep_get() to correctly convert the hugetlb ptes.

Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 fs/proc/task_mmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 85d16c6..4a0c31f 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1552,18 +1552,19 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
 static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask,
 		unsigned long addr, unsigned long end, struct mm_walk *walk)
 {
+	pte_t huge_pte = huge_ptep_get(pte);
 	struct numa_maps *md;
 	struct page *page;
 
-	if (!pte_present(*pte))
+	if (!pte_present(huge_pte))
 		return 0;
 
-	page = pte_page(*pte);
+	page = pte_page(huge_pte);
 	if (!page)
 		return 0;
 
 	md = walk->private;
-	gather_stats(page, md, pte_dirty(*pte), 1);
+	gather_stats(page, md, pte_dirty(huge_pte), 1);
 	return 0;
 }
 
-- 
2.3.9

[toc] | [next] | [standalone]


#1317386

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-01-26 00:00 +0100
Message-ID<qUYh4-2r5-1@gated-at.bofh.it>
In reply to#1316972
On Mon, 25 Jan 2016 17:30:42 +0100 Michael Holzheu <holzheu@linux.vnet.ibm.com> wrote:

> When working with hugetlbfs ptes (which are actually pmds) is not
> valid to directly use pte functions like pte_present() because the
> hardware bit layout of pmds and ptes can be different. This is the
> case on s390. Therefore we have to convert the hugetlbfs ptes first
> into a valid pte encoding with huge_ptep_get().
> 
> Currently the /proc/<pid>/numa_maps code uses hugetlbfs ptes without
> huge_ptep_get(). On s390 this leads to the following two problems:
> 
> 1) The pte_present() function returns false (instead of true) for
>    PROT_NONE hugetlb ptes. Therefore PROT_NONE vmas are missing
>    completely in the "numa_maps" output.
> 
> 2) The pte_dirty() function always returns false for all hugetlb ptes.
>    Therefore these pages are reported as "mapped=xxx" instead of
>    "dirty=xxx".
> 
> Therefore use huge_ptep_get() to correctly convert the hugetlb ptes.

I'm aiming this at 4.5 only.  Please let me know if you think that a
-stable backport is warranted.

[toc] | [prev] | [next] | [standalone]


#1317737

FromMichael Holzheu <holzheu@linux.vnet.ibm.com>
Date2016-01-26 12:00 +0100
Message-ID<qV9vR-2Vi-35@gated-at.bofh.it>
In reply to#1317386
On Mon, 25 Jan 2016 14:51:16 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Mon, 25 Jan 2016 17:30:42 +0100 Michael Holzheu <holzheu@linux.vnet.ibm.com> wrote:
> 
> > When working with hugetlbfs ptes (which are actually pmds) is not
> > valid to directly use pte functions like pte_present() because the
> > hardware bit layout of pmds and ptes can be different. This is the
> > case on s390. Therefore we have to convert the hugetlbfs ptes first
> > into a valid pte encoding with huge_ptep_get().
> > 
> > Currently the /proc/<pid>/numa_maps code uses hugetlbfs ptes without
> > huge_ptep_get(). On s390 this leads to the following two problems:
> > 
> > 1) The pte_present() function returns false (instead of true) for
> >    PROT_NONE hugetlb ptes. Therefore PROT_NONE vmas are missing
> >    completely in the "numa_maps" output.
> > 
> > 2) The pte_dirty() function always returns false for all hugetlb ptes.
> >    Therefore these pages are reported as "mapped=xxx" instead of
> >    "dirty=xxx".
> > 
> > Therefore use huge_ptep_get() to correctly convert the hugetlb ptes.
> 
> I'm aiming this at 4.5 only.  Please let me know if you think that a
> -stable backport is warranted.

S390 has NUMA support since kernel 4.3, therefore:

Cc: stable@vger.kernel.org # v4.3+ 

Michael

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web