Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1605250ybv; Thu, 6 Feb 2020 06:51:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwwAPb1n2xr05ymBEqypfRLZIVGCJcPg6Lh3mS9K++gK7/lo77dxt247FMSjlSUEaAD4WmF X-Received: by 2002:aca:c491:: with SMTP id u139mr7198477oif.17.1581000665927; Thu, 06 Feb 2020 06:51:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581000665; cv=none; d=google.com; s=arc-20160816; b=TWSZ2slCQrU0TafonRNBEWEyeA3oxWv/eatdAbe/2MNlu50WDv1yZWRE4reUVnzjpw JHlk61jnXYmVFw7GpNYcp6JJqRerxt6PKDJsem10cAXzaN5R5yQvf9powSJ5Rdv0cMvI O6bSTw6K7gLtR2uXRsjiw1AuFkNDrTeT5rl63K874UEDNjUK+tfE6IYr5lvK+BD1KEZg gvGUxLwrqXDEEfD5eJXC3pljs0eny6+c6VBqMifJRXIeA7XJQqnzQK/AHVM8i4W6pmP7 gZPfJT3oGAjZUWzLRo3ukSohjICmM++Q5e0qXbNfenOWGuuY55f6ZyHK6T0rIrTRgDYV 2nUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :dkim-signature; bh=0bH7Q8+ZCms42huP9MeIAQx+Q6qVGMr1gRSJSDwrjGU=; b=zx5ENx13N9EsMzYlHjQcd+tTqkH2Kk/iaIBc8S5VNPm/9zEGNg/sbPHvw2DOTszyuy 5o9QvjIHu283g9c7vnIp/u7pLkMfaSqgD7r/TGecefUuyy6rVDb6t+EQ/v6y6g7PNIB4 xHCTFXDEqIFkvea7KuW8iIn43fUnOk/NVbfAKrOhNHB9KsweMvjLdXk2vH+Cidz+PwiO IFTnEbjsuMgAl0L5uI646yE3inpcRI+Nj+ObztLJbzcWUVzaVjLTsETgsAamgVbVMaUz lBMhcJ7/mNWrSX/exEtyYB31rM/J8y6f1/7pJkNyqx0y9YPSlrkhhe8xUaCxXPEtENFK EEOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=kLr9YHP0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9si2018280otk.91.2020.02.06.06.50.53; Thu, 06 Feb 2020 06:51:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=kLr9YHP0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728104AbgBFNuc (ORCPT + 99 others); Thu, 6 Feb 2020 08:50:32 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:28533 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbgBFNub (ORCPT ); Thu, 6 Feb 2020 08:50:31 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48D0F03DN3z9v995; Thu, 6 Feb 2020 14:50:28 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=kLr9YHP0; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id wtA-ON8Bgv8n; Thu, 6 Feb 2020 14:50:28 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48D0F01zYPz9v994; Thu, 6 Feb 2020 14:50:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1580997028; bh=0bH7Q8+ZCms42huP9MeIAQx+Q6qVGMr1gRSJSDwrjGU=; h=From:Subject:To:Cc:Date:From; b=kLr9YHP0JPqaJb7IyJSKyCkLltCvd/qg1dd/t8EfgAmFAVV8xI9PyWHXL1dE/AsuD wAWZaUgPeHARvDoEpGNNlBC0OKmazuQ+Yj1a2iz206hkdBY0QvpWcWXYSADydAs9ov hjWo3VqoCeglpbDRVm8IXZZSwjRniwMwpP9Pzi90= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9FBBB8B887; Thu, 6 Feb 2020 14:50:29 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id JhwneTyJXOp4; Thu, 6 Feb 2020 14:50:29 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 50AFB8B864; Thu, 6 Feb 2020 14:50:29 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id CD126652B7; Thu, 6 Feb 2020 13:50:28 +0000 (UTC) Message-Id: <90ec56a2315be602494619ed0223bba3b0b8d619.1580997007.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/hugetlb: Fix 512k hugepages on 8xx with 16k page size To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , aneesh.kumar@linux.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 6 Feb 2020 13:50:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 55c8fc3f4930 ("powerpc/8xx: reintroduce 16K pages with HW assistance") redefined pte_t as a struct of 4 pte_basic_t, because in 16K pages mode there are four identical entries in the page table. But the size of hugepage tables is calculated based of the size of (void *). Therefore, we end up with page tables of size 1k instead of 4k for 512k pages. As 512k hugepage tables are the same size as standard page tables, ie 4k, use the standard page tables instead of PGT_CACHE tables. Fixes: 3fb69c6a1a13 ("powerpc/8xx: Enable 512k hugepage support with HW assistance") Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy --- arch/powerpc/mm/hugetlbpage.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index c61032580185..edf511c2a30a 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -54,20 +54,24 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, if (pshift >= pdshift) { cachep = PGT_CACHE(PTE_T_ORDER); num_hugepd = 1 << (pshift - pdshift); + new = NULL; } else if (IS_ENABLED(CONFIG_PPC_8xx)) { - cachep = PGT_CACHE(PTE_INDEX_SIZE); + cachep = NULL; num_hugepd = 1; + new = pte_alloc_one(mm); } else { cachep = PGT_CACHE(pdshift - pshift); num_hugepd = 1; + new = NULL; } - if (!cachep) { + if (!cachep && !new) { WARN_ONCE(1, "No page table cache created for hugetlb tables"); return -ENOMEM; } - new = kmem_cache_alloc(cachep, pgtable_gfp_flags(mm, GFP_KERNEL)); + if (cachep) + new = kmem_cache_alloc(cachep, pgtable_gfp_flags(mm, GFP_KERNEL)); BUG_ON(pshift > HUGEPD_SHIFT_MASK); BUG_ON((unsigned long)new & HUGEPD_SHIFT_MASK); @@ -98,7 +102,10 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, if (i < num_hugepd) { for (i = i - 1 ; i >= 0; i--, hpdp--) *hpdp = __hugepd(0); - kmem_cache_free(cachep, new); + if (cachep) + kmem_cache_free(cachep, new); + else + pte_free(mm, new); } else { kmemleak_ignore(new); } @@ -325,8 +332,7 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif if (shift >= pdshift) hugepd_free(tlb, hugepte); else if (IS_ENABLED(CONFIG_PPC_8xx)) - pgtable_free_tlb(tlb, hugepte, - get_hugepd_cache_index(PTE_INDEX_SIZE)); + pgtable_free_tlb(tlb, hugepte, 0); else pgtable_free_tlb(tlb, hugepte, get_hugepd_cache_index(pdshift - shift)); @@ -640,12 +646,13 @@ static int __init hugetlbpage_init(void) * if we have pdshift and shift value same, we don't * use pgt cache for hugepd. */ - if (pdshift > shift && IS_ENABLED(CONFIG_PPC_8xx)) - pgtable_cache_add(PTE_INDEX_SIZE); - else if (pdshift > shift) - pgtable_cache_add(pdshift - shift); - else if (IS_ENABLED(CONFIG_PPC_FSL_BOOK3E) || IS_ENABLED(CONFIG_PPC_8xx)) + if (pdshift > shift) { + if (!IS_ENABLED(CONFIG_PPC_8xx)) + pgtable_cache_add(pdshift - shift); + } else if (IS_ENABLED(CONFIG_PPC_FSL_BOOK3E) || + IS_ENABLED(CONFIG_PPC_8xx)) { pgtable_cache_add(PTE_T_ORDER); + } configured = true; } -- 2.25.0