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 X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33DDCC433DF for ; Thu, 16 Jul 2020 14:47:01 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FE79206F5 for ; Thu, 16 Jul 2020 14:47:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FE79206F5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B6xst24jkzDqrT for ; Fri, 17 Jul 2020 00:46:58 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=steven.price@arm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4B6x8t3Xg5zDr6t for ; Fri, 17 Jul 2020 00:14:46 +1000 (AEST) 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 AA8F331B; Thu, 16 Jul 2020 07:14:43 -0700 (PDT) Received: from [192.168.1.84] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 00B4B3F66E; Thu, 16 Jul 2020 07:14:38 -0700 (PDT) Subject: Re: [PATCH V5 1/4] mm/debug_vm_pgtable: Add tests validating arch helpers for core MM features To: Anshuman Khandual , linux-mm@kvack.org References: <1594610587-4172-1-git-send-email-anshuman.khandual@arm.com> <1594610587-4172-2-git-send-email-anshuman.khandual@arm.com> From: Steven Price Message-ID: <2ff756c5-28e2-b64a-3788-260ba30c6409@arm.com> Date: Thu, 16 Jul 2020 15:14:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1594610587-4172-2-git-send-email-anshuman.khandual@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Carstens , Paul Mackerras , "H. Peter Anvin" , agordeev@linux.ibm.com, Will Deacon , linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, x86@kernel.org, Mike Rapoport , Christian Borntraeger , Ingo Molnar , gerald.schaefer@de.ibm.com, ziy@nvidia.com, Catalin Marinas , linux-snps-arc@lists.infradead.org, Vasily Gorbik , cai@lca.pw, Paul Walmsley , "Kirill A . Shutemov" , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, christophe.leroy@c-s.fr, Vineet Gupta , linux-kernel@vger.kernel.org, Palmer Dabbelt , aneesh.kumar@linux.ibm.com, Borislav Petkov , Andrew Morton , linuxppc-dev@lists.ozlabs.org, rppt@kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 13/07/2020 04:23, Anshuman Khandual wrote: > This adds new tests validating arch page table helpers for these following > core memory features. These tests create and test specific mapping types at > various page table levels. > > 1. SPECIAL mapping > 2. PROTNONE mapping > 3. DEVMAP mapping > 4. SOFTDIRTY mapping > 5. SWAP mapping > 6. MIGRATION mapping > 7. HUGETLB mapping > 8. THP mapping > > Cc: Andrew Morton > Cc: Gerald Schaefer > Cc: Christophe Leroy > Cc: Mike Rapoport > Cc: Vineet Gupta > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Heiko Carstens > Cc: Vasily Gorbik > Cc: Christian Borntraeger > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: Kirill A. Shutemov > Cc: Paul Walmsley > Cc: Palmer Dabbelt > Cc: linux-snps-arc@lists.infradead.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linuxppc-dev@lists.ozlabs.org > Cc: linux-s390@vger.kernel.org > Cc: linux-riscv@lists.infradead.org > Cc: x86@kernel.org > Cc: linux-mm@kvack.org > Cc: linux-arch@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Tested-by: Vineet Gupta #arc > Reviewed-by: Zi Yan > Suggested-by: Catalin Marinas > Signed-off-by: Anshuman Khandual > --- > mm/debug_vm_pgtable.c | 302 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 301 insertions(+), 1 deletion(-) > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > index 61ab16fb2e36..2fac47db3eb7 100644 > --- a/mm/debug_vm_pgtable.c > +++ b/mm/debug_vm_pgtable.c [...] > + > +static void __init pte_swap_tests(unsigned long pfn, pgprot_t prot) > +{ > + swp_entry_t swp; > + pte_t pte; > + > + pte = pfn_pte(pfn, prot); > + swp = __pte_to_swp_entry(pte); Minor issue: this doesn't look necessarily valid - there's no reason a normal PTE can be turned into a swp_entry. In practise this is likely to work on all architectures because there's no reason not to use (at least) all the PFN bits for the swap entry, but it doesn't exactly seem correct. Can we start with a swp_entry_t (from __swp_entry()) and check the round trip of that? It would also seem sensible to have a check that is_swap_pte(__swp_entry_to_pte(__swp_entry(x,y))) is true. > + pte = __swp_entry_to_pte(swp); > + WARN_ON(pfn != pte_pfn(pte)); > +} > + > +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION > +static void __init pmd_swap_tests(unsigned long pfn, pgprot_t prot) > +{ > + swp_entry_t swp; > + pmd_t pmd; > + > + pmd = pfn_pmd(pfn, prot); > + swp = __pmd_to_swp_entry(pmd); > + pmd = __swp_entry_to_pmd(swp); > + WARN_ON(pfn != pmd_pfn(pmd)); > +} > +#else /* !CONFIG_ARCH_ENABLE_THP_MIGRATION */ > +static void __init pmd_swap_tests(unsigned long pfn, pgprot_t prot) { } > +#endif /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ > + > +static void __init swap_migration_tests(void) > +{ > + struct page *page; > + swp_entry_t swp; > + > + if (!IS_ENABLED(CONFIG_MIGRATION)) > + return; > + /* > + * swap_migration_tests() requires a dedicated page as it needs to > + * be locked before creating a migration entry from it. Locking the > + * page that actually maps kernel text ('start_kernel') can be real > + * problematic. Lets allocate a dedicated page explicitly for this NIT: s/Lets/Let's Otherwise looks good to me. Steve