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=-5.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 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 BC05BC3F2D1 for ; Mon, 2 Mar 2020 19:40:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70B6324686 for ; Mon, 2 Mar 2020 19:40:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="dWCEq9Tb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70B6324686 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F9F26B0003; Mon, 2 Mar 2020 14:40:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 184366B0005; Mon, 2 Mar 2020 14:40:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 026026B0006; Mon, 2 Mar 2020 14:40:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id DC5F46B0003 for ; Mon, 2 Mar 2020 14:40:50 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9B43A181AC9CC for ; Mon, 2 Mar 2020 19:40:50 +0000 (UTC) X-FDA: 76551439860.30.peace50_74b85f9edb56 X-HE-Tag: peace50_74b85f9edb56 X-Filterd-Recvd-Size: 8896 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Mar 2020 19:40:49 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id z12so851095qkg.12 for ; Mon, 02 Mar 2020 11:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fpur9odzhdIzgZKAdXT5OufUWZiXDywyFJGHnsjLJuo=; b=dWCEq9TbdtlIn4IlSjT7wsgDMqKSoAKLzae3C569gQfG+p+Vk79gjYDp0p50OXn9hR Xm7x5cNfSGrA7pZOqbIyHB6YbB5olZ4ep8KMLse+bohRCUq99hLzFTyhfizQ0g1MVv9z PDB5fH+ahTLkKU8vUdes9sSXGelGjiIZoAKN6HTkKzUfig+h5pTHRYeWb9NP7s3wdS9t Tt4WNgQv8yFdtznernPNmQzDX+ip0C+UgbaM/+RzUP5kH1SCJgpVi8ZPrt/2QDdNj0Vc NTeqpeeYYjJCxNEWEDDoAqM078dLwnuNGGPGzRM4Bt0EmoCaK9xyew4usRNSVcQzIQqy 2SAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fpur9odzhdIzgZKAdXT5OufUWZiXDywyFJGHnsjLJuo=; b=BKeRxtjL/n8KJlh4BH6xVGRa9+VCqwrxw71ecFzZ4EYnxx91+KExYQ+nUBFBHrmrw+ 4YhP9mAv9m5Eu6VxJ6hOb4MCD07ClVCmJ6hRCCR9w4yfuwXP30QN3F2Y/AG0oONroEZj PkUBkaXNxaHEX0sWXYmex+oPdkfmTkcd1cB//71RS95zhGmfCjt2j59J/c6pgfJ8jr73 MNba6pWHCGMF9X9YA97CqG/hBIoUwyA8jyB+FYvyKJfvPeoTZ/T1dav+vP7mz6Nl0EDn 7iqQFJ1t4w+T/zxiHVNLKNurHcOVjJzugNz9siGrs7Ls2m2T1o9Qn6W0TfPGudfJI0kZ omkg== X-Gm-Message-State: ANhLgQ0A495EH+8heKBSaORoBgfn6TD84AU/+zAlVAuBsaxiRs43KIo9 7PdWndYeYwG5tca90NuwoX/wiQ== X-Google-Smtp-Source: ADFU+vvIre6Pknx1npljKo6V/87YN9X3Pm++i6mQcGcNAIn71bgolvXPcuZTIRGu9NVtwEvKfxAUQw== X-Received: by 2002:ae9:f205:: with SMTP id m5mr857097qkg.152.1583178047563; Mon, 02 Mar 2020 11:40:47 -0800 (PST) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id s139sm6748558qke.70.2020.03.02.11.40.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2020 11:40:46 -0800 (PST) Message-ID: <1583178042.7365.146.camel@lca.pw> Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers From: Qian Cai To: Christophe Leroy , Anshuman Khandual , linux-mm@kvack.org Cc: Andrew Morton , Mike Rapoport , Vineet Gupta , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "Kirill A . Shutemov" , Paul Walmsley , Palmer Dabbelt , linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 02 Mar 2020 14:40:42 -0500 In-Reply-To: <1582732318.7365.129.camel@lca.pw> References: <1581909460-19148-1-git-send-email-anshuman.khandual@arm.com> <1582726182.7365.123.camel@lca.pw> <7c707b7f-ce3d-993b-8042-44fdc1ed28bf@c-s.fr> <1582732318.7365.129.camel@lca.pw> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Wed, 2020-02-26 at 10:51 -0500, Qian Cai wrote: > On Wed, 2020-02-26 at 15:45 +0100, Christophe Leroy wrote: > >=20 > > Le 26/02/2020 =C3=A0 15:09, Qian Cai a =C3=A9crit=C2=A0: > > > On Mon, 2020-02-17 at 08:47 +0530, Anshuman Khandual wrote: > > > > This adds tests which will validate architecture page table helpe= rs and > > > > other accessors in their compliance with expected generic MM sema= ntics. > > > > This will help various architectures in validating changes to exi= sting > > > > page table helpers or addition of new ones. > > > >=20 > > > > This test covers basic page table entry transformations including= but not > > > > limited to old, young, dirty, clean, write, write protect etc at = various > > > > level along with populating intermediate entries with next page t= able page > > > > and validating them. > > > >=20 > > > > Test page table pages are allocated from system memory with requi= red size > > > > and alignments. The mapped pfns at page table levels are derived = from a > > > > real pfn representing a valid kernel text symbol. This test gets = called > > > > inside kernel_init() right after async_synchronize_full(). > > > >=20 > > > > This test gets built and run when CONFIG_DEBUG_VM_PGTABLE is sele= cted. Any > > > > architecture, which is willing to subscribe this test will need t= o select > > > > ARCH_HAS_DEBUG_VM_PGTABLE. For now this is limited to arc, arm64,= x86, s390 > > > > and ppc32 platforms where the test is known to build and run succ= essfully. > > > > Going forward, other architectures too can subscribe the test aft= er fixing > > > > any build or runtime problems with their page table helpers. Mean= while for > > > > better platform coverage, the test can also be enabled with CONFI= G_EXPERT > > > > even without ARCH_HAS_DEBUG_VM_PGTABLE. > > > >=20 > > > > Folks interested in making sure that a given platform's page tabl= e helpers > > > > conform to expected generic MM semantics should enable the above = config > > > > which will just trigger this test during boot. Any non conformity= here will > > > > be reported as an warning which would need to be fixed. This test= will help > > > > catch any changes to the agreed upon semantics expected from gene= ric MM and > > > > enable platforms to accommodate it thereafter. > > >=20 > > > How useful is this that straightly crash the powerpc? > > >=20 > > > [=C2=A0=C2=A0=C2=A023.263425][=C2=A0=C2=A0=C2=A0=C2=A0T1] debug_vm_= pgtable: debug_vm_pgtable: Validating > > > architecture page table helpers > > > [=C2=A0=C2=A0=C2=A023.263625][=C2=A0=C2=A0=C2=A0=C2=A0T1] ---------= ---[ cut here ]------------ > > > [=C2=A0=C2=A0=C2=A023.263649][=C2=A0=C2=A0=C2=A0=C2=A0T1] kernel BU= G at arch/powerpc/mm/pgtable.c:274! > >=20 > > The problem on PPC64 is known and has to be investigated and fixed. >=20 > It might be interesting to hear what powerpc64 maintainers would say ab= out it > and if it is actually worth "fixing" in the arch code, but that BUG_ON(= ) was > there since 2009 and had not been exposed until this patch comes alone? This patch below makes it works on powerpc64 in order to dodge the BUG_ON= ()s in=20 assert_pte_locked() triggered by pte_clear_tests(). diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index 96dd7d574cef..50b385233971 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -55,6 +55,8 @@ =C2=A0#define RANDOM_ORVALUE GENMASK(BITS_PER_LONG - 1, S390_MASK_BITS) =C2=A0#define RANDOM_NZVALUE GENMASK(7, 0) =C2=A0 +unsigned long vaddr; + =C2=A0static void __init pte_basic_tests(unsigned long pfn, pgprot_t prot= ) =C2=A0{ =C2=A0 pte_t pte =3D pfn_pte(pfn, prot); @@ -256,7 +258,7 @@ static void __init pte_clear_tests(struct mm_struct *= mm, pte_t *ptep) =C2=A0 =C2=A0 pte =3D __pte(pte_val(pte) | RANDOM_ORVALUE); =C2=A0 WRITE_ONCE(*ptep, pte); - pte_clear(mm, 0, ptep); + pte_clear(mm, vaddr, ptep); =C2=A0 pte =3D READ_ONCE(*ptep); =C2=A0 WARN_ON(!pte_none(pte)); =C2=A0} @@ -310,8 +312,9 @@ void __init debug_vm_pgtable(void) =C2=A0 pgtable_t saved_ptep; =C2=A0 pgprot_t prot; =C2=A0 phys_addr_t paddr; - unsigned long vaddr, pte_aligned, pmd_aligned; + unsigned long pte_aligned, pmd_aligned; =C2=A0 unsigned long pud_aligned, p4d_aligned, pgd_aligned; + spinlock_t *ptl; =C2=A0 =C2=A0 pr_info("Validating architecture page table helpers\n"); =C2=A0 prot =3D vm_get_page_prot(VMFLAGS); @@ -344,7 +347,7 @@ void __init debug_vm_pgtable(void) =C2=A0 p4dp =3D p4d_alloc(mm, pgdp, vaddr); =C2=A0 pudp =3D pud_alloc(mm, p4dp, vaddr); =C2=A0 pmdp =3D pmd_alloc(mm, pudp, vaddr); - ptep =3D pte_alloc_map(mm, pmdp, vaddr); + ptep =3D pte_alloc_map_lock(mm, pmdp, vaddr, &ptl); =C2=A0 =C2=A0 /* =C2=A0 =C2=A0* Save all the page table page addresses as the page table @@ -370,7 +373,7 @@ void __init debug_vm_pgtable(void) =C2=A0 p4d_clear_tests(mm, p4dp); =C2=A0 pgd_clear_tests(mm, pgdp); =C2=A0 - pte_unmap(ptep); + pte_unmap_unlock(ptep, ptl); =C2=A0 =C2=A0 pmd_populate_tests(mm, pmdp, saved_ptep); =C2=A0 pud_populate_tests(mm, pudp, saved_pmdp);