Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1527835ybt; Mon, 15 Jun 2020 02:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVkc1IXt2S5bpwr3nVtQtopDo967VVbeCA3BqX8GxYLcCB+Xp5LVPFpX6CviH4XA4sBbO4 X-Received: by 2002:a17:906:4ecf:: with SMTP id i15mr25998621ejv.515.1592213867341; Mon, 15 Jun 2020 02:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592213867; cv=none; d=google.com; s=arc-20160816; b=JUOw7nemZ2rCfoUJH51l1j8/+8PHEj95IR9F+2z6/lslAR21uua1FMNmBOxWEpDdwY Nmp5kKWFW9MYioEzGtt7BIGTSc2PlcM8iW1qNEJqnArtFYWF4HhlEJ+evAyQeb31XpXG KQnfrmFjirL6O+kPfozRvoa9gtMuefblv17Z1a9tnKd8sWRVB/WJAD1kYr61S8FZlJBW 7gVUScNV7oiLnU8GI0P4YTdWcZ4NipbfYTXVNfE/Wrwd5FaLwDHars6iIDjlcYyadUUw JJtkJpeKIcnJ/bz+5cCvC4TpbZqNzJYoW/2wwO3p7LfO1x2xS/TZqUfOIHMafLfDhrs9 /Flg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/3RRjnmF5wRWOSrlHS8wKC+zMSREgpzRsRAxQryzxYs=; b=XYhuonr/cu4kYBXmVa3J5qy/s7ll+Bw7+t3X/ky2KbLOMdrJJXJFCoNwsQ1EAF+EVt 06/tlXiuqndAITEy162w71hXafjV0736FLctjiPrYVSKBB9nh+rLCfx9z/eoKaossB1L m7c+6y77TbVdp2uGPE7fbCCpNOoYv7823cezjr3OQNU7Njn0/thzGxxMd7lBBa3I/dO0 L0jMX5/nWvS+ZNRJPe+RwWyAROpVD2tPZUQS850qvEQ4LlMIgdvA3PLcOli3k1D4yiKJ YfPmKyY/sCkUaLAdBZI/uxkB710nrowzWsVTITAxvdq7eAsXSOiIYuO1SbQrsxOV2Hhu P35g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy15si8923761ejb.538.2020.06.15.02.37.25; Mon, 15 Jun 2020 02:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729384AbgFOJcr (ORCPT + 99 others); Mon, 15 Jun 2020 05:32:47 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:41519 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729285AbgFOJcq (ORCPT ); Mon, 15 Jun 2020 05:32:46 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 15/06/2020 à 11:22, Mike Rapoport a écrit : > From: Mike Rapoport > > 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. > > Replace explicit unfolding with pmd_off() and drop defines of pgd_index() > and pgd_offset() that are no longer needed. > > 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 > --- > > I think it's powerpc material, but I won't mind if Andrew picks it up :) > > > arch/powerpc/include/asm/nohash/32/pgtable.h | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/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 = __pmd(0); > } > > -/* 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 long 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_struct *mm, unsigned long addr, p > pte_basic_t old = pte_val(*p); > pte_basic_t new = (old & ~(pte_basic_t)clr) | set; > int num, i; > - pmd_t *pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), addr), addr); > + pmd_t *pmd = pmd_off(mm, addr); > > if (!huge) > num = PAGE_SIZE / SZ_4K; >