On 9/19/18 7:03 PM, Yang Shi wrote: ... > Suggested-by: Michal Hocko <mhocko@xxxxxxxxxx> > Suggested-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> > Suggested-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Reviewed-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Cc: Laurent Dufour <ldufour@xxxxxxxxxxxxxxxxxx> > Cc: Vlastimil Babka <vbabka@xxxxxxx> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> This is indeed much better code structure. Thanks for persisting with the series and following the suggestions. Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Nit: > @@ -2797,17 +2819,32 @@ int vm_munmap(unsigned long start, size_t len) > if (down_write_killable(&mm->mmap_sem)) > return -EINTR; > > - ret = do_munmap(mm, start, len, &uf); > - up_write(&mm->mmap_sem); > + ret = __do_munmap(mm, start, len, &uf, downgrade); > + /* > + * Returning 1 indicates mmap_sem is downgraded. > + * But 1 is not legal return value of vm_munmap() and munmap(), reset > + * it to 0 before return. > + */ > + if (ret == 1) { > + up_read(&mm->mmap_sem); > + ret = 0; > + } else > + up_write(&mm->mmap_sem); > + I think the else part should also have { } per the kernel style?