Skip to contentSkip to conversation

riscv: Use p*d_leaf macros to define p*d_huge

PATCH In review Alexandre Ghiti 3 participants 3 messages Feb 20, 2020 – Mar 5, 2020 RISC-V

lore
Share & tools
lore

Alexandre Ghiti

author reviewer
#0 lore raw

PATCH 1/1 riscv: Use p*d_leaf macros to define p*d_huge

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.

---
 arch/riscv/mm/hugetlbpage.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/riscv/mm/hugetlbpage.c +2 -4
index 0d4747e9d5b5..a6189ed36c5f 100644
@@ -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)
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · 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.

---
 arch/riscv/mm/hugetlbpage.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/riscv/mm/hugetlbpage.c +2 -5
index 0d4747e9d5b5..a6189ed36c5f 100644
@@ -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)
--
Quoted 2 lines

2.20.1

Looks good to me.

Regards,
Anup

maintainer
#2 lore raw
In reply to Alexandre Ghiti
Quoted 22 lines · On Wed, 19 Feb 2020 22:10:23 PST (-0800), [email protected] 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.

---
 arch/riscv/mm/hugetlbpage.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/riscv/mm/hugetlbpage.c +1 -2
index 0d4747e9d5b5..a6189ed36c5f 100644
@@ -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);

arch/riscv/mm/hugetlbpage.c line 15

Quoted 10 lines
arch/riscv/mm/hugetlbpage.c +1 -2
 }
 
 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.