linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: Use p*d_leaf macros to define p*d_huge
@ 2020-02-20  6:10 Alexandre Ghiti
  2020-02-20  6:12 ` Anup Patel
  2020-03-05 21:15 ` Palmer Dabbelt
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2020-02-20  6:10 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, linux-riscv, linux-kernel; +Cc: Alexandre Ghiti

The newly introduced p*d_leaf macros allow to check if an entry of the
page table map to a physical page instead of the next level. To avoid
duplication of code, use those macros to determine if a page table entry
points to a hugepage.

Suggested-by: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
 arch/riscv/mm/hugetlbpage.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c
index 0d4747e9d5b5..a6189ed36c5f 100644
--- a/arch/riscv/mm/hugetlbpage.c
+++ b/arch/riscv/mm/hugetlbpage.c
@@ -4,14 +4,12 @@
 
 int pud_huge(pud_t pud)
 {
-	return pud_present(pud) &&
-		(pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
+	return pud_leaf(pud);
 }
 
 int pmd_huge(pmd_t pmd)
 {
-	return pmd_present(pmd) &&
-		(pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
+	return pmd_leaf(pmd);
 }
 
 static __init int setup_hugepagesz(char *opt)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Use p*d_leaf macros to define p*d_huge
  2020-02-20  6:10 [PATCH] riscv: Use p*d_leaf macros to define p*d_huge Alexandre Ghiti
@ 2020-02-20  6:12 ` Anup Patel
  2020-03-05 21:15 ` Palmer Dabbelt
  1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2020-02-20  6:12 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: linux-riscv, Palmer Dabbelt, linux-kernel@vger.kernel.org List,
	Paul Walmsley

On Thu, Feb 20, 2020 at 11:41 AM Alexandre Ghiti <alex@ghiti.fr> wrote:
>
> The newly introduced p*d_leaf macros allow to check if an entry of the
> page table map to a physical page instead of the next level. To avoid
> duplication of code, use those macros to determine if a page table entry
> points to a hugepage.
>
> Suggested-by: Paul Walmsley <paul.walmsley@sifive.com>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
>  arch/riscv/mm/hugetlbpage.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c
> index 0d4747e9d5b5..a6189ed36c5f 100644
> --- a/arch/riscv/mm/hugetlbpage.c
> +++ b/arch/riscv/mm/hugetlbpage.c
> @@ -4,14 +4,12 @@
>
>  int pud_huge(pud_t pud)
>  {
> -       return pud_present(pud) &&
> -               (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
> +       return pud_leaf(pud);
>  }
>
>  int pmd_huge(pmd_t pmd)
>  {
> -       return pmd_present(pmd) &&
> -               (pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
> +       return pmd_leaf(pmd);
>  }
>
>  static __init int setup_hugepagesz(char *opt)
> --
> 2.20.1
>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Use p*d_leaf macros to define p*d_huge
  2020-02-20  6:10 [PATCH] riscv: Use p*d_leaf macros to define p*d_huge Alexandre Ghiti
  2020-02-20  6:12 ` Anup Patel
@ 2020-03-05 21:15 ` Palmer Dabbelt
  1 sibling, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2020-03-05 21:15 UTC (permalink / raw)
  To: alex; +Cc: linux-riscv, linux-kernel, alex, Paul Walmsley

On Wed, 19 Feb 2020 22:10:23 PST (-0800), alex@ghiti.fr wrote:
> The newly introduced p*d_leaf macros allow to check if an entry of the
> page table map to a physical page instead of the next level. To avoid
> duplication of code, use those macros to determine if a page table entry
> points to a hugepage.
>
> Suggested-by: Paul Walmsley <paul.walmsley@sifive.com>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
>  arch/riscv/mm/hugetlbpage.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c
> index 0d4747e9d5b5..a6189ed36c5f 100644
> --- a/arch/riscv/mm/hugetlbpage.c
> +++ b/arch/riscv/mm/hugetlbpage.c
> @@ -4,14 +4,12 @@
>
>  int pud_huge(pud_t pud)
>  {
> -	return pud_present(pud) &&
> -		(pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
> +	return pud_leaf(pud);
>  }
>
>  int pmd_huge(pmd_t pmd)
>  {
> -	return pmd_present(pmd) &&
> -		(pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
> +	return pmd_leaf(pmd);
>  }
>
>  static __init int setup_hugepagesz(char *opt)

Thanks, this is on for-next.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-05 21:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20  6:10 [PATCH] riscv: Use p*d_leaf macros to define p*d_huge Alexandre Ghiti
2020-02-20  6:12 ` Anup Patel
2020-03-05 21:15 ` Palmer Dabbelt

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).