diff mbox series

[v12,12/22] mm: pagewalk: Allow walking without vma

Message ID 20191018101248.33727-13-steven.price@arm.com (mailing list archive)
State New, archived
Headers show
Series Generic page walk and ptdump | expand

Commit Message

Steven Price Oct. 18, 2019, 10:12 a.m. UTC
Since 48684a65b4e3: "mm: pagewalk: fix misbehavior of walk_page_range
for vma(VM_PFNMAP)", page_table_walk() will report any kernel area as
a hole, because it lacks a vma.

This means each arch has re-implemented page table walking when needed,
for example in the per-arch ptdump walker.

Remove the requirement to have a vma except when trying to split huge
pages.

Signed-off-by: Steven Price <steven.price@arm.com>
---
 mm/pagewalk.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Comments

Zong Li Oct. 24, 2019, 1:05 p.m. UTC | #1
Steven Price <steven.price@arm.com> 於 2019年10月19日 週六 下午4:12寫道:

>
> Since 48684a65b4e3: "mm: pagewalk: fix misbehavior of walk_page_range
> for vma(VM_PFNMAP)", page_table_walk() will report any kernel area as
> a hole, because it lacks a vma.
>
> This means each arch has re-implemented page table walking when needed,
> for example in the per-arch ptdump walker.
>
> Remove the requirement to have a vma except when trying to split huge
> pages.
>
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>  mm/pagewalk.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/mm/pagewalk.c b/mm/pagewalk.c
> index fc4d98a3a5a0..4139e9163aee 100644
> --- a/mm/pagewalk.c
> +++ b/mm/pagewalk.c
> @@ -38,7 +38,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
>         do {
>  again:
>                 next = pmd_addr_end(addr, end);
> -               if (pmd_none(*pmd) || !walk->vma) {
> +               if (pmd_none(*pmd)) {
>                         if (ops->pte_hole)
>                                 err = ops->pte_hole(addr, next, walk);
>                         if (err)
> @@ -61,9 +61,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
>                 if (!ops->pte_entry)
>                         continue;
>
> -               split_huge_pmd(walk->vma, pmd, addr);
> -               if (pmd_trans_unstable(pmd))
> -                       goto again;
> +               if (walk->vma) {
> +                       split_huge_pmd(walk->vma, pmd, addr);
> +                       if (pmd_trans_unstable(pmd))
> +                               goto again;
> +               } else if (pmd_leaf(*pmd)) {
> +                       continue;
> +               }
> +
>                 err = walk_pte_range(pmd, addr, next, walk);
>                 if (err)
>                         break;
> @@ -84,7 +89,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
>         do {
>   again:
>                 next = pud_addr_end(addr, end);
> -               if (pud_none(*pud) || !walk->vma) {
> +               if (pud_none(*pud)) {
>                         if (ops->pte_hole)
>                                 err = ops->pte_hole(addr, next, walk);
>                         if (err)
> @@ -98,9 +103,13 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
>                                 break;
>                 }
>
> -               split_huge_pud(walk->vma, pud, addr);
> -               if (pud_none(*pud))
> -                       goto again;
> +               if (walk->vma) {
> +                       split_huge_pud(walk->vma, pud, addr);
> +                       if (pud_none(*pud))
> +                               goto again;
> +               } else if (pud_leaf(*pud)) {
> +                       continue;
> +               }
>
>                 if (ops->pmd_entry || ops->pte_entry)
>                         err = walk_pmd_range(pud, addr, next, walk);
> --
> 2.20.1
>

It's good to me.

Tested-by: Zong Li <zong.li@sifive.com>
diff mbox series

Patch

diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index fc4d98a3a5a0..4139e9163aee 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -38,7 +38,7 @@  static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 	do {
 again:
 		next = pmd_addr_end(addr, end);
-		if (pmd_none(*pmd) || !walk->vma) {
+		if (pmd_none(*pmd)) {
 			if (ops->pte_hole)
 				err = ops->pte_hole(addr, next, walk);
 			if (err)
@@ -61,9 +61,14 @@  static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 		if (!ops->pte_entry)
 			continue;
 
-		split_huge_pmd(walk->vma, pmd, addr);
-		if (pmd_trans_unstable(pmd))
-			goto again;
+		if (walk->vma) {
+			split_huge_pmd(walk->vma, pmd, addr);
+			if (pmd_trans_unstable(pmd))
+				goto again;
+		} else if (pmd_leaf(*pmd)) {
+			continue;
+		}
+
 		err = walk_pte_range(pmd, addr, next, walk);
 		if (err)
 			break;
@@ -84,7 +89,7 @@  static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
 	do {
  again:
 		next = pud_addr_end(addr, end);
-		if (pud_none(*pud) || !walk->vma) {
+		if (pud_none(*pud)) {
 			if (ops->pte_hole)
 				err = ops->pte_hole(addr, next, walk);
 			if (err)
@@ -98,9 +103,13 @@  static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
 				break;
 		}
 
-		split_huge_pud(walk->vma, pud, addr);
-		if (pud_none(*pud))
-			goto again;
+		if (walk->vma) {
+			split_huge_pud(walk->vma, pud, addr);
+			if (pud_none(*pud))
+				goto again;
+		} else if (pud_leaf(*pud)) {
+			continue;
+		}
 
 		if (ops->pmd_entry || ops->pte_entry)
 			err = walk_pmd_range(pud, addr, next, walk);