From: Dmitry Safonov Date: Tue, 15 Dec 2020 03:08:05 +0000 (-0800) Subject: mm/mremap: account memory on do_munmap() failure X-Git-Tag: v5.15~2223^2~116 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51df7bcb61518d933beb5c2dfe8251d651ca4259;p=platform%2Fkernel%2Flinux-starfive.git mm/mremap: account memory on do_munmap() failure Patch series "mremap: move_vma() fixes". This patch (of 6): move_vma() copies VMA without adding it to account, then unmaps old part of VMA. On failure it unmaps the new VMA. With hacks accounting in munmap is disabled as it's a copy of existing VMA. Account the memory on munmap() failure which was previously copied into a new VMA. Link: https://lkml.kernel.org/r/20201013013416.390574-1-dima@arista.com Link: https://lkml.kernel.org/r/20201013013416.390574-2-dima@arista.com Fixes: commit e2ea83742133 ("[PATCH] mremap: move_vma fixes and cleanup") Signed-off-by: Dmitry Safonov Cc: Alexander Viro Cc: Andy Lutomirski Cc: Brian Geffon Cc: Catalin Marinas Cc: Dan Williams Cc: Dave Jiang Cc: Hugh Dickins Cc: Ingo Molnar Cc: "Kirill A. Shutemov" Cc: Mike Kravetz Cc: Minchan Kim Cc: Russell King Cc: Thomas Bogendoerfer Cc: Thomas Gleixner Cc: Vishal Verma Cc: Vlastimil Babka Cc: Will Deacon Cc: Dan Carpenter Cc: John Hubbard Cc: Jason Gunthorpe Cc: Ralph Campbell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/mremap.c b/mm/mremap.c index 078f731..975a14c 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -600,7 +600,8 @@ static unsigned long move_vma(struct vm_area_struct *vma, if (do_munmap(mm, old_addr, old_len, uf_unmap) < 0) { /* OOM: unable to split vma, just get accounts right */ - vm_unacct_memory(excess >> PAGE_SHIFT); + if (vm_flags & VM_ACCOUNT) + vm_acct_memory(new_len >> PAGE_SHIFT); excess = 0; }