linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>
Subject: Re: [PATCH] powerpc/8xx: use pmd_off() to access a PMD entry in pte_update()
Date: Mon, 15 Jun 2020 11:32:42 +0200	[thread overview]
Message-ID: <717cb7ae-1859-8a97-281a-a6ecb68fccd0@csgroup.eu> (raw)
In-Reply-To: <20200615092229.23142-1-rppt@kernel.org>



Le 15/06/2020 à 11:22, Mike Rapoport a écrit :
> From: Mike Rapoport <rppt@linux.ibm.com>
> 
> 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 <rppt@linux.ibm.com>

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.leroy@c-s.fr>

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;
> 

  reply	other threads:[~2020-06-15  9:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15  9:22 [PATCH] powerpc/8xx: use pmd_off() to access a PMD entry in pte_update() Mike Rapoport
2020-06-15  9:32 ` Christophe Leroy [this message]
2020-06-16 19:43 ` Andrew Morton
2020-06-16 23:21   ` Michael Ellerman
2020-06-17  4:16     ` Mike Rapoport
2020-06-17 13:05       ` Michael Ellerman
2020-06-18 12:37 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=717cb7ae-1859-8a97-281a-a6ecb68fccd0@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=rppt@kernel.org \
    --cc=rppt@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).