The patch titled Subject: mm/mmap.c: refine find_vma_prev() with rb_last() has been added to the -mm tree. Its filename is mm-mmapc-refine-find_vma_prev-with-rb_last.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-mmapc-refine-find_vma_prev-with-rb_last.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-mmapc-refine-find_vma_prev-with-rb_last.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx> Subject: mm/mmap.c: refine find_vma_prev() with rb_last() When addr is out of range of the whole rb_tree, pprev will point to the right-most node. rb_tree facility already provides a helper function, rb_last(), to do this task. We can leverage this instead of reimplementing it. This patch refines find_vma_prev() with rb_last() to make it a little nicer to read. Link: http://lkml.kernel.org/r/20190809001928.4950-1-richardw.yang@xxxxxxxxxxxxxxx Signed-off-by: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/mm/mmap.c~mm-mmapc-refine-find_vma_prev-with-rb_last +++ a/mm/mmap.c @@ -2285,12 +2285,9 @@ find_vma_prev(struct mm_struct *mm, unsi if (vma) { *pprev = vma->vm_prev; } else { - struct rb_node *rb_node = mm->mm_rb.rb_node; - *pprev = NULL; - while (rb_node) { - *pprev = rb_entry(rb_node, struct vm_area_struct, vm_rb); - rb_node = rb_node->rb_right; - } + struct rb_node *rb_node = rb_last(&mm->mm_rb); + *pprev = !rb_node ? NULL : + rb_entry(rb_node, struct vm_area_struct, vm_rb); } return vma; } _ Patches currently in -mm which might be from richardw.yang@xxxxxxxxxxxxxxx are mm-remove-redundant-assignment-of-entry.patch mm-sparse-use-__nr_to_sectionsection_nr-to-get-mem_section.patch mm-mmapc-refine-find_vma_prev-with-rb_last.patch