]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Add inline next_vma_or_first for readability of mm code
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 23 Jul 2020 19:13:56 +0000 (15:13 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 23 Jul 2020 20:00:09 +0000 (16:00 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index 59a4682ebf3faedb2cd00ec39656de3a40290050..4f55bda990a3c10b02bacf0bb4c952fec0cad1ad 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -560,6 +560,25 @@ static int find_vma_links(struct mm_struct *mm, unsigned long addr,
        return 0;
 }
 
+/* Private
+ * next_vma_or_first() - Get the next vma in the list or the start of the vma
+ * list.
+ *
+ * next_vam_or_first() is in inline function for readability of the mm code.
+ *
+ * @mm: The mm_struct.
+ * @vma: The vm_area_struct to query the next entry.
+ *
+ * Returns: The next VMA after @vma, or the first vm_arear_struct this mm..
+ */
+static inline struct vm_area_struct *next_vma_or_first(struct mm_struct *mm,
+                                        struct vm_area_struct *vma)
+{
+       if (!vma)
+               return mm->mmap;
+
+       return vma->vm_next;
+}
 static unsigned long count_vma_pages_range(struct mm_struct *mm,
                unsigned long addr, unsigned long end)
 {
@@ -1131,10 +1150,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
        if (vm_flags & VM_SPECIAL)
                return NULL;
 
-       if (prev)
-               next = prev->vm_next;
-       else
-               next = mm->mmap;
+       next = next_vma_or_first(mm, prev);
        area = next;
        if (area && area->vm_end == end)                /* cases 6, 7, 8 */
                next = next->vm_next;
@@ -2604,7 +2620,7 @@ static void unmap_region(struct mm_struct *mm,
                struct vm_area_struct *vma, struct vm_area_struct *prev,
                unsigned long start, unsigned long end)
 {
-       struct vm_area_struct *next = prev ? prev->vm_next : mm->mmap;
+       struct vm_area_struct *next = next_vma_or_first(mm, prev);
        struct mmu_gather tlb;
 
        lru_add_drain();
@@ -2792,7 +2808,7 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
                if (error)
                        return error;
        }
-       vma = prev ? prev->vm_next : mm->mmap;
+       vma = next_vma_or_first(mm, prev);
 
        if (unlikely(uf)) {
                /*