mm/memory.c: use helper macro min and max in unmap_mapping_range_tree()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 22 Mar 2022 21:42:33 +0000 (14:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:05 +0000 (15:57 -0700)
Use helper macro min and max to help simplify the code logic.  Minor
readability improvement.

Link: https://lkml.kernel.org/r/20220224121134.35068-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory.c

index 3cbcf3a..c962814 100644 (file)
@@ -3350,12 +3350,8 @@ static inline void unmap_mapping_range_tree(struct rb_root_cached *root,
        vma_interval_tree_foreach(vma, root, first_index, last_index) {
                vba = vma->vm_pgoff;
                vea = vba + vma_pages(vma) - 1;
-               zba = first_index;
-               if (zba < vba)
-                       zba = vba;
-               zea = last_index;
-               if (zea > vea)
-                       zea = vea;
+               zba = max(first_index, vba);
+               zea = min(last_index, vea);
 
                unmap_mapping_range_vma(vma,
                        ((zba - vba) << PAGE_SHIFT) + vma->vm_start,