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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 F21F5C2D0E4 for ; Fri, 27 Nov 2020 09:14:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7010621D93 for ; Fri, 27 Nov 2020 09:14:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7010621D93 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9BBF66B0036; Fri, 27 Nov 2020 04:14:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9473A6B005C; Fri, 27 Nov 2020 04:14:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BDAB6B0068; Fri, 27 Nov 2020 04:14:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 636616B0036 for ; Fri, 27 Nov 2020 04:14:27 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2FB9F6D86 for ; Fri, 27 Nov 2020 09:14:27 +0000 (UTC) X-FDA: 77529637374.18.day55_1700c4427386 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 0E297100EC676 for ; Fri, 27 Nov 2020 09:14:27 +0000 (UTC) X-HE-Tag: day55_1700c4427386 X-Filterd-Recvd-Size: 8934 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 09:14:26 +0000 (UTC) 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 728C01478; Fri, 27 Nov 2020 01:14:25 -0800 (PST) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2936B3F23F; Fri, 27 Nov 2020 01:14:24 -0800 (PST) Subject: Re: [PATCH 2/2] mm/debug_vm_pgtable/basic: Iterate over entire protection_map[] To: Anshuman Khandual , linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, gerald.schaefer@linux.ibm.com, vgupta@synopsys.com, paul.walmsley@sifive.com References: <1606453584-15399-1-git-send-email-anshuman.khandual@arm.com> <1606453584-15399-3-git-send-email-anshuman.khandual@arm.com> From: Steven Price Message-ID: <4c3efec7-a454-951f-4f37-fd8ed1908b8c@arm.com> Date: Fri, 27 Nov 2020 09:14:23 +0000 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: <1606453584-15399-3-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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 27/11/2020 05:06, Anshuman Khandual wrote: > Currently the basic tests just validate various page table transformations > after starting with vm_get_page_prot(VM_READ|VM_WRITE|VM_EXEC) protection. > Instead scan over the entire protection_map[] for better coverage. It also > makes sure that all these basic page table tranformations checks hold true > irrespective of the starting protection value for the page table entry. > There is also a slight change in the debug print format for basic tests to > capture the protection value it is being tested with. The modified output > looks something like > > [pte_basic_tests ]: Validating PTE basic () > [pte_basic_tests ]: Validating PTE basic (read) > [pte_basic_tests ]: Validating PTE basic (write) > [pte_basic_tests ]: Validating PTE basic (read|write) > [pte_basic_tests ]: Validating PTE basic (exec) > [pte_basic_tests ]: Validating PTE basic (read|exec) > [pte_basic_tests ]: Validating PTE basic (write|exec) > [pte_basic_tests ]: Validating PTE basic (read|write|exec) > [pte_basic_tests ]: Validating PTE basic (shared) > [pte_basic_tests ]: Validating PTE basic (read|shared) > [pte_basic_tests ]: Validating PTE basic (write|shared) > [pte_basic_tests ]: Validating PTE basic (read|write|shared) > [pte_basic_tests ]: Validating PTE basic (exec|shared) > [pte_basic_tests ]: Validating PTE basic (read|exec|shared) > [pte_basic_tests ]: Validating PTE basic (write|exec|shared) > [pte_basic_tests ]: Validating PTE basic (read|write|exec|shared) > > This adds a missing argument 'struct mm_struct *' in pud_basic_tests() test > . This never got exposed before as PUD based THP is available only on X86 > platform where mm_pmd_folded(mm) call gets macro replaced without requiring > the mm_struct i.e __is_defined(__PAGETABLE_PMD_FOLDED). > > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > Suggested-by: Catalin Marinas > Signed-off-by: Anshuman Khandual Reviewed-by: Steven Price > --- > mm/debug_vm_pgtable.c | 47 ++++++++++++++++++++++++++++++++----------- > 1 file changed, 35 insertions(+), 12 deletions(-) > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > index a5be11210597..92b4a53d622b 100644 > --- a/mm/debug_vm_pgtable.c > +++ b/mm/debug_vm_pgtable.c > @@ -58,11 +58,13 @@ > #define RANDOM_ORVALUE (GENMASK(BITS_PER_LONG - 1, 0) & ~ARCH_SKIP_MASK) > #define RANDOM_NZVALUE GENMASK(7, 0) > > -static void __init pte_basic_tests(unsigned long pfn, pgprot_t prot) > +static void __init pte_basic_tests(unsigned long pfn, int idx) > { > + pgprot_t prot = protection_map[idx]; > pte_t pte = pfn_pte(pfn, prot); > + unsigned long val = idx, *ptr = &val; > > - pr_debug("Validating PTE basic\n"); > + pr_debug("Validating PTE basic (%pGv)\n", ptr); > WARN_ON(!pte_same(pte, pte)); > WARN_ON(!pte_young(pte_mkyoung(pte_mkold(pte)))); > WARN_ON(!pte_dirty(pte_mkdirty(pte_mkclean(pte)))); > @@ -130,14 +132,16 @@ static void __init pte_savedwrite_tests(unsigned long pfn, pgprot_t prot) > } > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > -static void __init pmd_basic_tests(unsigned long pfn, pgprot_t prot) > +static void __init pmd_basic_tests(unsigned long pfn, int idx) > { > + pgprot_t prot = protection_map[idx]; > pmd_t pmd = pfn_pmd(pfn, prot); > + unsigned long val = idx, *ptr = &val; > > if (!has_transparent_hugepage()) > return; > > - pr_debug("Validating PMD basic\n"); > + pr_debug("Validating PMD basic (%pGv)\n", ptr); > WARN_ON(!pmd_same(pmd, pmd)); > WARN_ON(!pmd_young(pmd_mkyoung(pmd_mkold(pmd)))); > WARN_ON(!pmd_dirty(pmd_mkdirty(pmd_mkclean(pmd)))); > @@ -251,14 +255,16 @@ static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot) > } > > #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD > -static void __init pud_basic_tests(unsigned long pfn, pgprot_t prot) > +static void __init pud_basic_tests(struct mm_struct *mm, unsigned long pfn, int idx) > { > + pgprot_t prot = protection_map[idx]; > pud_t pud = pfn_pud(pfn, prot); > + unsigned long val = idx, *ptr = &val; > > if (!has_transparent_hugepage()) > return; > > - pr_debug("Validating PUD basic\n"); > + pr_debug("Validating PUD basic (%pGv)\n", ptr); > WARN_ON(!pud_same(pud, pud)); > WARN_ON(!pud_young(pud_mkyoung(pud_mkold(pud)))); > WARN_ON(!pud_write(pud_mkwrite(pud_wrprotect(pud)))); > @@ -362,7 +368,7 @@ static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t prot) > #endif /* !CONFIG_HAVE_ARCH_HUGE_VMAP */ > > #else /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ > -static void __init pud_basic_tests(unsigned long pfn, pgprot_t prot) { } > +static void __init pud_basic_tests(struct mm_struct *mm, unsigned long pfn, int idx) { } > static void __init pud_advanced_tests(struct mm_struct *mm, > struct vm_area_struct *vma, pud_t *pudp, > unsigned long pfn, unsigned long vaddr, > @@ -375,8 +381,8 @@ static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t prot) > } > #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ > #else /* !CONFIG_TRANSPARENT_HUGEPAGE */ > -static void __init pmd_basic_tests(unsigned long pfn, pgprot_t prot) { } > -static void __init pud_basic_tests(unsigned long pfn, pgprot_t prot) { } > +static void __init pmd_basic_tests(unsigned long pfn, int idx) { } > +static void __init pud_basic_tests(struct mm_struct *mm, unsigned long pfn, int idx) { } > static void __init pmd_advanced_tests(struct mm_struct *mm, > struct vm_area_struct *vma, pmd_t *pmdp, > unsigned long pfn, unsigned long vaddr, > @@ -902,6 +908,7 @@ static int __init debug_vm_pgtable(void) > unsigned long vaddr, pte_aligned, pmd_aligned; > unsigned long pud_aligned, p4d_aligned, pgd_aligned; > spinlock_t *ptl = NULL; > + int idx; > > pr_info("Validating architecture page table helpers\n"); > prot = vm_get_page_prot(VMFLAGS); > @@ -966,9 +973,25 @@ static int __init debug_vm_pgtable(void) > saved_pmdp = pmd_offset(pudp, 0UL); > saved_ptep = pmd_pgtable(pmd); > > - pte_basic_tests(pte_aligned, prot); > - pmd_basic_tests(pmd_aligned, prot); > - pud_basic_tests(pud_aligned, prot); > + /* > + * Iterate over the protection_map[] to make sure that all > + * the basic page table transformation validations just hold > + * true irrespective of the starting protection value for a > + * given page table entry. > + */ > + for (idx = 0; idx < ARRAY_SIZE(protection_map); idx++) { > + pte_basic_tests(pte_aligned, idx); > + pmd_basic_tests(pmd_aligned, idx); > + pud_basic_tests(mm, pud_aligned, idx); > + } > + > + /* > + * Both P4D and PGD level tests are very basic which do not > + * involve creating page table entries from the protection > + * value and the given pfn. Hence just keep them out from > + * the above iteration for now to save some test execution > + * time. > + */ > p4d_basic_tests(p4d_aligned, prot); > pgd_basic_tests(pgd_aligned, prot); > >