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=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 CDB79C2D0B1 for ; Thu, 6 Feb 2020 06:18:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EC51206CC for ; Thu, 6 Feb 2020 06:18:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=c-s.fr header.i=@c-s.fr header.b="IJc3jder" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EC51206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=c-s.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 179436B000A; Thu, 6 Feb 2020 01:18:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1507C6B000C; Thu, 6 Feb 2020 01:18:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 041A26B000D; Thu, 6 Feb 2020 01:18:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id DF06A6B000A for ; Thu, 6 Feb 2020 01:18:07 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8D7DD824805A for ; Thu, 6 Feb 2020 06:18:07 +0000 (UTC) X-FDA: 76458697014.01.plant65_81142c4d14c1f X-HE-Tag: plant65_81142c4d14c1f X-Filterd-Recvd-Size: 6065 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 06:18:06 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48CpC01NgvzB09bJ; Thu, 6 Feb 2020 07:18:04 +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=IJc3jder; 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 Ff_laLB1i3Yt; Thu, 6 Feb 2020 07:18:04 +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 48CpC008FQzB09bG; Thu, 6 Feb 2020 07:18:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1580969884; bh=/zXspG1kSDBchHeXMPNEW4CMohV4cfmd+YhDCREVeRU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=IJc3jderGna62CaEbuKOvFjwfgtAoqVWDE/KIjuvt5lVBel/amt4R+kH9JR8F0zKw WAex/t5oBpzyaF9Z2SiGAv2B3XAU6NFAGf9SqVrv+8Utda7pe6bWVzA08BRFijg6AW z6fcy7RHCPd0QkreMH9zr+46SWRtxYBXVtnBy+Ug= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CCBF78B85E; Thu, 6 Feb 2020 07:18:04 +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 JUidJKGusZ7Y; Thu, 6 Feb 2020 07:18:04 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 289C18B776; Thu, 6 Feb 2020 07:18:03 +0100 (CET) Subject: Re: [PATCH v6 07/11] powerpc/kvm/e500: Use functions to track lockless pgtbl walks To: Leonardo Bras , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Arnd Bergmann , Andrew Morton , "Aneesh Kumar K.V" , Nicholas Piggin , Steven Price , Robin Murphy , Mahesh Salgaonkar , Balbir Singh , Reza Arbab , Thomas Gleixner , Allison Randal , Greg Kroah-Hartman , Mike Rapoport , Michal Suchanek Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org References: <20200206030900.147032-1-leonardo@linux.ibm.com> <20200206030900.147032-8-leonardo@linux.ibm.com> From: Christophe Leroy Message-ID: Date: Thu, 6 Feb 2020 07:18:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200206030900.147032-8-leonardo@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr 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: Le 06/02/2020 =C3=A0 04:08, Leonardo Bras a =C3=A9crit=C2=A0: > Applies the new functions used for tracking lockless pgtable walks on > kvmppc_e500_shadow_map(). >=20 > Fixes the place where local_irq_restore() is called: previously, if pte= p > was NULL, local_irq_restore() would never be called. >=20 > local_irq_{save,restore} is already inside {begin,end}_lockless_pgtbl_w= alk, > so there is no need to repeat it here. >=20 > Variable that saves the irq mask was renamed from flags to irq_mask so = it > doesn't lose meaning now it's not directly passed to local_irq_* functi= ons. >=20 > Signed-off-by: Leonardo Bras > --- > arch/powerpc/kvm/e500_mmu_host.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_m= mu_host.c > index 425d13806645..3dcf11f77256 100644 > --- a/arch/powerpc/kvm/e500_mmu_host.c > +++ b/arch/powerpc/kvm/e500_mmu_host.c > @@ -336,7 +336,7 @@ static inline int kvmppc_e500_shadow_map(struct kvm= ppc_vcpu_e500 *vcpu_e500, > pte_t *ptep; > unsigned int wimg =3D 0; > pgd_t *pgdir; > - unsigned long flags; > + unsigned long irq_mask; > =20 > /* used to check for invalidations in progress */ > mmu_seq =3D kvm->mmu_notifier_seq; > @@ -473,7 +473,7 @@ static inline int kvmppc_e500_shadow_map(struct kvm= ppc_vcpu_e500 *vcpu_e500, > * We are holding kvm->mmu_lock so a notifier invalidate > * can't run hence pfn won't change. > */ > - local_irq_save(flags); > + irq_mask =3D begin_lockless_pgtbl_walk(); > ptep =3D find_linux_pte(pgdir, hva, NULL, NULL); > if (ptep) { > pte_t pte =3D READ_ONCE(*ptep); > @@ -481,15 +481,16 @@ static inline int kvmppc_e500_shadow_map(struct k= vmppc_vcpu_e500 *vcpu_e500, > if (pte_present(pte)) { > wimg =3D (pte_val(pte) >> PTE_WIMGE_SHIFT) & > MAS2_WIMGE_MASK; > - local_irq_restore(flags); > } else { > - local_irq_restore(flags); > + end_lockless_pgtbl_walk(irq_mask); > pr_err_ratelimited("%s: pte not present: gfn %lx,pfn %lx\n", > __func__, (long)gfn, pfn); > ret =3D -EINVAL; > goto out; > } > } > + end_lockless_pgtbl_walk(irq_mask); > + I don't really like unbalanced begin/end. Something like the following would be cleaner: begin_lockless_pgtbl_walk() ptep =3D find() if (ptep) { pte =3D READ_ONCE() if (pte_present(pte)) wing=3D else ret =3D -EINVAL; } end_lockless_pgtbl_walk() if (ret) { pr_err_rate...() goto out; } > kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); > =20 > kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, >=20 Christophe