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.2 required=3.0 tests=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 2DD02C433E0 for ; Mon, 15 Jun 2020 09:32:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C7023206B7 for ; Mon, 15 Jun 2020 09:32:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7023206B7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 353F36B0002; Mon, 15 Jun 2020 05:32:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 304EC6B0003; Mon, 15 Jun 2020 05:32:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F3A86B0005; Mon, 15 Jun 2020 05:32:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 03DB86B0002 for ; Mon, 15 Jun 2020 05:32:46 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8073C181AC9C6 for ; Mon, 15 Jun 2020 09:32:46 +0000 (UTC) X-FDA: 76930931532.20.shop94_050828626df5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 471DF180C08F2 for ; Mon, 15 Jun 2020 09:32:46 +0000 (UTC) X-HE-Tag: shop94_050828626df5 X-Filterd-Recvd-Size: 4683 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Mon, 15 Jun 2020 09:32:45 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 49lmMb4rPNz9vBKc; Mon, 15 Jun 2020 11:32:43 +0200 (CEST) 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 bMRFmJQeXFz6; Mon, 15 Jun 2020 11:32:43 +0200 (CEST) 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 49lmMb29yWz9vBKb; Mon, 15 Jun 2020 11:32:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DAE318B786; Mon, 15 Jun 2020 11:32:41 +0200 (CEST) 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 ykKpLC_cKaHk; Mon, 15 Jun 2020 11:32:41 +0200 (CEST) Received: from [172.25.101.66] (po15451.idsi0.si.c-s.fr [172.25.101.66]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AA3248B75F; Mon, 15 Jun 2020 11:32:41 +0200 (CEST) Subject: Re: [PATCH] powerpc/8xx: use pmd_off() to access a PMD entry in pte_update() To: Mike Rapoport , Andrew Morton , Michael Ellerman Cc: Christophe Leroy , linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport References: <20200615092229.23142-1-rppt@kernel.org> From: Christophe Leroy Message-ID: <717cb7ae-1859-8a97-281a-a6ecb68fccd0@csgroup.eu> Date: Mon, 15 Jun 2020 11:32:42 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200615092229.23142-1-rppt@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr X-Rspamd-Queue-Id: 471DF180C08F2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 15/06/2020 =C3=A0 11:22, Mike Rapoport a =C3=A9crit=C2=A0: > From: Mike Rapoport >=20 > The pte_update() implementation for PPC_8xx unfolds page table from the= PGD > level to access a PMD entry. Since 8xx has only 2-level page table this= can > be simplified with pmd_off() shortcut. >=20 > Replace explicit unfolding with pmd_off() and drop defines of pgd_index= () > and pgd_offset() that are no longer needed. >=20 > Signed-off-by: Mike Rapoport Nice. When I implemented this function, I was not able to use pmd_ptr() due to some circular header inclusion (See comment in commit log). Looks like since the replacement of pmd_ptr() by pmd_off(), it works. Reviewed-by: Christophe Leroy Christophe > --- >=20 > I think it's powerpc material, but I won't mind if Andrew picks it up := ) >=20 >=20 > arch/powerpc/include/asm/nohash/32/pgtable.h | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) >=20 > diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerp= c/include/asm/nohash/32/pgtable.h > index b56f14160ae5..5a590ceaec14 100644 > --- a/arch/powerpc/include/asm/nohash/32/pgtable.h > +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h > @@ -205,10 +205,6 @@ static inline void pmd_clear(pmd_t *pmdp) > *pmdp =3D __pmd(0); > } > =20 > -/* to find an entry in a page-table-directory */ > -#define pgd_index(address) ((address) >> PGDIR_SHIFT) > -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address)) > - > /* > * PTE updates. This function is called whenever an existing > * valid PTE is updated. This does -not- include set_pte_at() > @@ -230,6 +226,8 @@ static inline void pmd_clear(pmd_t *pmdp) > * For other page sizes, we have a single entry in the table. > */ > #ifdef CONFIG_PPC_8xx > +static pmd_t *pmd_off(struct mm_struct *mm, unsigned long addr); > + > static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned l= ong addr, pte_t *p, > unsigned long clr, unsigned long set, int huge) > { > @@ -237,7 +235,7 @@ static inline pte_basic_t pte_update(struct mm_stru= ct *mm, unsigned long addr, p > pte_basic_t old =3D pte_val(*p); > pte_basic_t new =3D (old & ~(pte_basic_t)clr) | set; > int num, i; > - pmd_t *pmd =3D pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr),= addr), addr), addr); > + pmd_t *pmd =3D pmd_off(mm, addr); > =20 > if (!huge) > num =3D PAGE_SIZE / SZ_4K; >=20