diff mbox series

mm/damon/vaddr: remove swap_ranges() and replace it with swap()

Message ID 20211111032204.3721-1-hanyihao@vivo.com (mailing list archive)
State New
Headers show
Series mm/damon/vaddr: remove swap_ranges() and replace it with swap() | expand

Commit Message

Yihao Han Nov. 11, 2021, 3:22 a.m. UTC
Remove 'swap_ranges()' and replace it with the macro 'swap()'
defined in 'include/linux/minmax.h' to simplify code and improve efficiency

Reviewed-by: SeongJae Park <sj@kernel.org>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 mm/damon/vaddr.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

Comments

Muchun Song Nov. 11, 2021, 3:37 a.m. UTC | #1
On Thu, Nov 11, 2021 at 11:22 AM Yihao Han <hanyihao@vivo.com> wrote:
>
> Remove 'swap_ranges()' and replace it with the macro 'swap()'
> defined in 'include/linux/minmax.h' to simplify code and improve efficiency
>
> Reviewed-by: SeongJae Park <sj@kernel.org>
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
> Signed-off-by: Yihao Han <hanyihao@vivo.com>

Actually, I and SeongJae didn't provide Reviewed-by in the
previous thread. But this patch looks good to me, so

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

BTW, the subject missed a "v2" tag (and changes log
should include what you have changed since v1).

Thanks.

> ---
>  mm/damon/vaddr.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 35fe49080ee9..814dc811d7c4 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -97,16 +97,6 @@ static unsigned long sz_range(struct damon_addr_range *r)
>         return r->end - r->start;
>  }
>
> -static void swap_ranges(struct damon_addr_range *r1,
> -                       struct damon_addr_range *r2)
> -{
> -       struct damon_addr_range tmp;
> -
> -       tmp = *r1;
> -       *r1 = *r2;
> -       *r2 = tmp;
> -}
> -
>  /*
>   * Find three regions separated by two biggest unmapped regions
>   *
> @@ -145,9 +135,9 @@ static int __damon_va_three_regions(struct vm_area_struct *vma,
>                 gap.start = last_vma->vm_end;
>                 gap.end = vma->vm_start;
>                 if (sz_range(&gap) > sz_range(&second_gap)) {
> -                       swap_ranges(&gap, &second_gap);
> +                       swap(gap, second_gap);
>                         if (sz_range(&second_gap) > sz_range(&first_gap))
> -                               swap_ranges(&second_gap, &first_gap);
> +                               swap(second_gap, first_gap);
>                 }
>  next:
>                 last_vma = vma;
> @@ -158,7 +148,7 @@ static int __damon_va_three_regions(struct vm_area_struct *vma,
>
>         /* Sort the two biggest gaps by address */
>         if (first_gap.start > second_gap.start)
> -               swap_ranges(&first_gap, &second_gap);
> +               swap(first_gap, second_gap);
>
>         /* Store the result */
>         regions[0].start = ALIGN(start, DAMON_MIN_REGION);
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 35fe49080ee9..814dc811d7c4 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -97,16 +97,6 @@  static unsigned long sz_range(struct damon_addr_range *r)
 	return r->end - r->start;
 }
 
-static void swap_ranges(struct damon_addr_range *r1,
-			struct damon_addr_range *r2)
-{
-	struct damon_addr_range tmp;
-
-	tmp = *r1;
-	*r1 = *r2;
-	*r2 = tmp;
-}
-
 /*
  * Find three regions separated by two biggest unmapped regions
  *
@@ -145,9 +135,9 @@  static int __damon_va_three_regions(struct vm_area_struct *vma,
 		gap.start = last_vma->vm_end;
 		gap.end = vma->vm_start;
 		if (sz_range(&gap) > sz_range(&second_gap)) {
-			swap_ranges(&gap, &second_gap);
+			swap(gap, second_gap);
 			if (sz_range(&second_gap) > sz_range(&first_gap))
-				swap_ranges(&second_gap, &first_gap);
+				swap(second_gap, first_gap);
 		}
 next:
 		last_vma = vma;
@@ -158,7 +148,7 @@  static int __damon_va_three_regions(struct vm_area_struct *vma,
 
 	/* Sort the two biggest gaps by address */
 	if (first_gap.start > second_gap.start)
-		swap_ranges(&first_gap, &second_gap);
+		swap(first_gap, second_gap);
 
 	/* Store the result */
 	regions[0].start = ALIGN(start, DAMON_MIN_REGION);