Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: <stable@vger.kernel.org> [4.3+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Michael Holzheu and committed by
Linus Torvalds
5c2ff95e 0bb181c7

+4 -3
+4 -3
fs/proc/task_mmu.c
··· 1552 1552 static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, 1553 1553 unsigned long addr, unsigned long end, struct mm_walk *walk) 1554 1554 { 1555 + pte_t huge_pte = huge_ptep_get(pte); 1555 1556 struct numa_maps *md; 1556 1557 struct page *page; 1557 1558 1558 - if (!pte_present(*pte)) 1559 + if (!pte_present(huge_pte)) 1559 1560 return 0; 1560 1561 1561 - page = pte_page(*pte); 1562 + page = pte_page(huge_pte); 1562 1563 if (!page) 1563 1564 return 0; 1564 1565 1565 1566 md = walk->private; 1566 - gather_stats(page, md, pte_dirty(*pte), 1); 1567 + gather_stats(page, md, pte_dirty(huge_pte), 1); 1567 1568 return 0; 1568 1569 } 1569 1570