Re: [PATCH 08/12] parisc: use pgtable-nopXd instead of 4level-fixup

From: Mike Rapoport
Date: Thu Oct 24 2019 - 12:00:16 EST


On Thu, Oct 24, 2019 at 02:02:08PM +0200, Helge Deller wrote:
> * Mike Rapoport <rppt@xxxxxxxxxx>:
> > From: Mike Rapoport <rppt@xxxxxxxxxxxxx>
> >
> > parisc has two or three levels of page tables and can use appropriate
> > pgtable-nopXd and folding of the upper layers.
> >
> > Replace usage of include/asm-generic/4level-fixup.h and explicit
> > definitions of __PAGETABLE_PxD_FOLDED in parisc with
> > include/asm-generic/pgtable-nopmd.h for two-level configurations and with
> > include/asm-generic/pgtable-nopmd.h for three-lelve configurations and
> > adjust page table manipulation macros and functions accordingly.
> >
> > Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
> > ---
> > arch/parisc/include/asm/page.h | 30 +++++++++++++---------
> > arch/parisc/include/asm/pgalloc.h | 41 +++++++++++-------------------
> > arch/parisc/include/asm/pgtable.h | 52 +++++++++++++++++++--------------------
> > arch/parisc/include/asm/tlb.h | 2 ++
> > arch/parisc/kernel/cache.c | 13 ++++++----
> > arch/parisc/kernel/pci-dma.c | 9 +++++--
> > arch/parisc/mm/fixmap.c | 10 +++++---
> > 7 files changed, 81 insertions(+), 76 deletions(-)
>
> Mike, thanks for this clean-up!
>
> Your patch is functional OK. I successfully tested it with a 32-bit
> kernel in qemu, and with a 64-bit kernel on a physical box.
> For 64-bit you missed to adapt the parisc hugetlb code, so maybe you
> can add the patch below to your series?

Sure.

> Other than that (and the lexical corrections which other already mentioned):
> Acked-by: Helge Deller <deller@xxxxxx>

Thanks!

> Thanks!
> Helge
>
> ----------------
> parisc/hugetlb: use pgtable-nopXd instead of 4level-fixup
>
> Signed-off-by: Helge Deller <deller@xxxxxx>
>
> diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c
> index d578809e55cf..0e1e212f1c96 100644
> --- a/arch/parisc/mm/hugetlbpage.c
> +++ b/arch/parisc/mm/hugetlbpage.c
> @@ -49,6 +49,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
> unsigned long addr, unsigned long sz)
> {
> pgd_t *pgd;
> + p4d_t *p4d;
> pud_t *pud;
> pmd_t *pmd;
> pte_t *pte = NULL;
> @@ -61,7 +62,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
> addr &= HPAGE_MASK;
>
> pgd = pgd_offset(mm, addr);
> - pud = pud_alloc(mm, pgd, addr);
> + p4d = p4d_offset(pgd, addr);
> + pud = pud_alloc(mm, p4d, addr);
> if (pud) {
> pmd = pmd_alloc(mm, pud, addr);
> if (pmd)
> @@ -74,6 +76,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
> unsigned long addr, unsigned long sz)
> {
> pgd_t *pgd;
> + p4d_t *p4d;
> pud_t *pud;
> pmd_t *pmd;
> pte_t *pte = NULL;
> @@ -82,11 +85,14 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
>
> pgd = pgd_offset(mm, addr);
> if (!pgd_none(*pgd)) {
> - pud = pud_offset(pgd, addr);
> - if (!pud_none(*pud)) {
> - pmd = pmd_offset(pud, addr);
> - if (!pmd_none(*pmd))
> - pte = pte_offset_map(pmd, addr);
> + p4d = p4d_offset(pgd, addr);
> + if (!p4d_none(*p4d)) {
> + pud = pud_offset(p4d, addr);
> + if (!pud_none(*pud)) {
> + pmd = pmd_offset(pud, addr);
> + if (!pmd_none(*pmd))
> + pte = pte_offset_map(pmd, addr);
> + }
> }
> }
> return pte;
>
>
>
>
>

--
Sincerely yours,
Mike.