]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/damon/vaddr: remove swap_ranges() and replace it with swap()
authorYihao Han <hanyihao@vivo.com>
Fri, 14 Jan 2022 22:09:47 +0000 (14:09 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Jan 2022 14:30:32 +0000 (16:30 +0200)
Remove 'swap_ranges()' and replace it with the macro 'swap()' defined in
'include/linux/minmax.h' to simplify code and improve efficiency

Link: https://lkml.kernel.org/r/20211111115355.2808-1-hanyihao@vivo.com
Signed-off-by: Yihao Han <hanyihao@vivo.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/damon/vaddr.c

index a9d3b4d96e294428af3c18818b3683ecc5cea402..78ff2bcb66eb3c7455bcc3ecebfbce26d89c4aca 100644 (file)
@@ -98,16 +98,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
  *
@@ -146,9 +136,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;
@@ -159,7 +149,7 @@ next:
 
        /* 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);