From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A671C4332F for ; Fri, 18 Nov 2022 11:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241892AbiKRLLA (ORCPT ); Fri, 18 Nov 2022 06:11:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241869AbiKRLK2 (ORCPT ); Fri, 18 Nov 2022 06:10:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA8F18C4A5 for ; Fri, 18 Nov 2022 03:10:23 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8120223A; Fri, 18 Nov 2022 03:10:29 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.6.127]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0BB883F587; Fri, 18 Nov 2022 03:10:21 -0800 (PST) Date: Fri, 18 Nov 2022 11:10:16 +0000 From: Mark Rutland To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64/mm: Drop redundant BUG_ON(!pgtable_alloc) Message-ID: References: <20221118053102.500216-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221118053102.500216-1-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 18, 2022 at 11:01:02AM +0530, Anshuman Khandual wrote: > __create_pgd_mapping_locked() expects a page allocator used while mapping a > virtual range. This page allocator function propagates down the call chain, > while building intermediate levels in the page table. Passed page allocator > is a necessary ingredient required to build the page table but its presence > can be asserted just once in the very beginning rather than in all the down > stream functions. This consolidates BUG_ON(!pgtable_alloc) checks just in a > single place i.e __create_pgd_mapping_locked(). > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: Andrew Morton > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual I don't have strong feelings either way, so FWIW: Acked-by: Mark Rutland Thanks, Mark. > --- > This applies on v6.1-rc5 > > arch/arm64/mm/mmu.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 5a19950e7289..97ca82001089 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -207,7 +207,6 @@ static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, > > if (flags & NO_EXEC_MAPPINGS) > pmdval |= PMD_TABLE_PXN; > - BUG_ON(!pgtable_alloc); > pte_phys = pgtable_alloc(PAGE_SHIFT); > __pmd_populate(pmdp, pte_phys, pmdval); > pmd = READ_ONCE(*pmdp); > @@ -285,7 +284,6 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr, > > if (flags & NO_EXEC_MAPPINGS) > pudval |= PUD_TABLE_PXN; > - BUG_ON(!pgtable_alloc); > pmd_phys = pgtable_alloc(PMD_SHIFT); > __pud_populate(pudp, pmd_phys, pudval); > pud = READ_ONCE(*pudp); > @@ -324,7 +322,6 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, > > if (flags & NO_EXEC_MAPPINGS) > p4dval |= P4D_TABLE_PXN; > - BUG_ON(!pgtable_alloc); > pud_phys = pgtable_alloc(PUD_SHIFT); > __p4d_populate(p4dp, pud_phys, p4dval); > p4d = READ_ONCE(*p4dp); > @@ -383,6 +380,7 @@ static void __create_pgd_mapping_locked(pgd_t *pgdir, phys_addr_t phys, > phys &= PAGE_MASK; > addr = virt & PAGE_MASK; > end = PAGE_ALIGN(virt + size); > + BUG_ON(!pgtable_alloc); > > do { > next = pgd_addr_end(addr, end); > -- > 2.25.1 >