From: Liam R. Howlett Date: Thu, 23 Jul 2020 19:13:56 +0000 (-0400) Subject: mm/mmap: Add inline next_vma_or_first for readability of mm code X-Git-Tag: howlett/maple/20200727~10 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f655f5634d99d01d9838de54d5fc50261f7aec8d;p=users%2Fjedix%2Flinux-maple.git mm/mmap: Add inline next_vma_or_first for readability of mm code Signed-off-by: Liam R. Howlett --- diff --git a/mm/mmap.c b/mm/mmap.c index 59a4682ebf3f..4f55bda990a3 100644 --- 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)) { /*