diff mbox series

[v4,36/66] um: Remove vma linked list walk

Message ID 20211201142918.921493-37-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series Introducing the Maple Tree | expand

Commit Message

Liam R. Howlett Dec. 1, 2021, 2:30 p.m. UTC
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

Use the VMA iterator instead.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 arch/um/kernel/tlb.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Comments

Vlastimil Babka Jan. 18, 2022, 6:41 p.m. UTC | #1
On 12/1/21 15:30, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> 
> Use the VMA iterator instead.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> ---
>  arch/um/kernel/tlb.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
> index bc38f79ca3a3..25f043037d76 100644
> --- a/arch/um/kernel/tlb.c
> +++ b/arch/um/kernel/tlb.c
> @@ -584,21 +584,19 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
>  
>  void flush_tlb_mm(struct mm_struct *mm)
>  {
> -	struct vm_area_struct *vma = mm->mmap;
> +	struct vm_area_struct *vma;
> +	VMA_ITERATOR(vmi, mm, 0);
>  
> -	while (vma != NULL) {
> +	for_each_vma(vmi, vma)
>  		fix_range(mm, vma->vm_start, vma->vm_end, 0);
> -		vma = vma->vm_next;
> -	}
>  }
>  
>  void force_flush_all(void)
>  {
>  	struct mm_struct *mm = current->mm;
> -	struct vm_area_struct *vma = mm->mmap;
> +	struct vm_area_struct *vma;
> +	MA_STATE(mas, &mm->mm_mt, 0, 0);
>  
> -	while (vma != NULL) {
> +	mas_for_each(&mas, vma, ULONG_MAX)

Is there a reason to use the iterator in one case and mas_for_each in the other?

>  		fix_range(mm, vma->vm_start, vma->vm_end, 1);
> -		vma = vma->vm_next;
> -	}
>  }
Liam R. Howlett Jan. 25, 2022, 4:38 p.m. UTC | #2
* Vlastimil Babka <vbabka@suse.cz> [220118 13:41]:
> On 12/1/21 15:30, Liam Howlett wrote:
> > From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> > 
> > Use the VMA iterator instead.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> > ---
> >  arch/um/kernel/tlb.c | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
> > index bc38f79ca3a3..25f043037d76 100644
> > --- a/arch/um/kernel/tlb.c
> > +++ b/arch/um/kernel/tlb.c
> > @@ -584,21 +584,19 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
> >  
> >  void flush_tlb_mm(struct mm_struct *mm)
> >  {
> > -	struct vm_area_struct *vma = mm->mmap;
> > +	struct vm_area_struct *vma;
> > +	VMA_ITERATOR(vmi, mm, 0);
> >  
> > -	while (vma != NULL) {
> > +	for_each_vma(vmi, vma)
> >  		fix_range(mm, vma->vm_start, vma->vm_end, 0);
> > -		vma = vma->vm_next;
> > -	}
> >  }
> >  
> >  void force_flush_all(void)
> >  {
> >  	struct mm_struct *mm = current->mm;
> > -	struct vm_area_struct *vma = mm->mmap;
> > +	struct vm_area_struct *vma;
> > +	MA_STATE(mas, &mm->mm_mt, 0, 0);
> >  
> > -	while (vma != NULL) {
> > +	mas_for_each(&mas, vma, ULONG_MAX)
> 
> Is there a reason to use the iterator in one case and mas_for_each in the other?

No, I will changed the second one to the vma iterator.  Thanks.

> 
> >  		fix_range(mm, vma->vm_start, vma->vm_end, 1);
> > -		vma = vma->vm_next;
> > -	}
> >  }
>
diff mbox series

Patch

diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index bc38f79ca3a3..25f043037d76 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -584,21 +584,19 @@  void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
 
 void flush_tlb_mm(struct mm_struct *mm)
 {
-	struct vm_area_struct *vma = mm->mmap;
+	struct vm_area_struct *vma;
+	VMA_ITERATOR(vmi, mm, 0);
 
-	while (vma != NULL) {
+	for_each_vma(vmi, vma)
 		fix_range(mm, vma->vm_start, vma->vm_end, 0);
-		vma = vma->vm_next;
-	}
 }
 
 void force_flush_all(void)
 {
 	struct mm_struct *mm = current->mm;
-	struct vm_area_struct *vma = mm->mmap;
+	struct vm_area_struct *vma;
+	MA_STATE(mas, &mm->mm_mt, 0, 0);
 
-	while (vma != NULL) {
+	mas_for_each(&mas, vma, ULONG_MAX)
 		fix_range(mm, vma->vm_start, vma->vm_end, 1);
-		vma = vma->vm_next;
-	}
 }