From patchwork Tue Oct 13 01:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11834687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF774697 for ; Tue, 13 Oct 2020 01:34:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D53120870 for ; Tue, 13 Oct 2020 01:34:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="J2rOTWZ8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D53120870 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3E017900003; Mon, 12 Oct 2020 21:34:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 34269940007; Mon, 12 Oct 2020 21:34:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B9D2900003; Mon, 12 Oct 2020 21:34:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id D4DAD940007 for ; Mon, 12 Oct 2020 21:34:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 77FA51EF1 for ; Tue, 13 Oct 2020 01:34:22 +0000 (UTC) X-FDA: 77365181964.07.need50_370b2a5271ff Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 596E41803F9A4 for ; Tue, 13 Oct 2020 01:34:22 +0000 (UTC) X-Spam-Summary: 1,0,0,885fc17e0ee643d4,d41d8cd98f00b204,dima@arista.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:2890:2899:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:4042:4250:4321:5007:6261:6653:6742:6743:9036:10004:11026:11658:11914:12297:12517:12519:12555:12679:12895:12986:13069:13227:13229:13311:13357:13894:14181:14384:14394:14721:21080:21444:21450:21451:21627:21660:21966:30001:30054:30079,0,RBL:209.85.128.65:@arista.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04yfwo7c5yrkct45zfkrjne7du7wjyp34ond6uebxbac66brcmsyej7zzfteair.6u16q485cf6q3utrcsgrgxku886n4rcw3x9xsgwp5619wm8tumhqh9hwdn5nahf.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: need50_370b2a5271ff X-Filterd-Recvd-Size: 4668 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Tue, 13 Oct 2020 01:34:21 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id a72so8673179wme.5 for ; Mon, 12 Oct 2020 18:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DaxIr5597WF0kxpEElTZVLTN61vAhnpO/2r1W4YxrO0=; b=J2rOTWZ8Lr5Wf2QMpwxeIwTk31F0CcPsxAE+ecneTuceI94efNcmEIgFo7sgQ5lmkn zLqcJTHbLpzPMw8OtVmyeRDaSk7WV69pJ35WU8S/Ni5BQSLXCGOMFKIr7yCZ95uiklXu AhGmVvlhf//oWpBLnP9Pbi9S9Pwm1hZ5YPKuv0zyUoCV3Fn+Aha/78ZfCxKT06boM6hV CEQgE4qDGlvBcUzSZvJQRXYHTypYqNFf9/hCzW4zFumXGHjPHoQ4nsxJGEqUsifC9zB+ ggvSzmzm+sUfR8KHUE7y6WLZ12vUAGmWR+1sz/qeHvP3y5XGFPLwNBoyR9cfLfWhG3fx qTYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DaxIr5597WF0kxpEElTZVLTN61vAhnpO/2r1W4YxrO0=; b=OIzG7/Zhcra5CUjYFg35+/6QN4NZ3sMK/FluNBi3JAkNMXnCvU0PYCfXJfO2pS1kRM fA+aDP5Z/6+qmEtkMVGAth2xHxzq3TdaQPOOfSOip0SaSH4oD6FnQu3NzPCnrhZL5l23 hpmb8OJGSQO1gccYCrXTpSHAvVk8GLVp74ERcpywNjezJESGFd20HZDbcpjekxFwqjDQ zD0+86D9a1jH2exzAgljomiOxzIP204CNRgIo//4dMYGnQmE2940zUxBQG4qCJfBfaWc P2DD73UCzTu1vK77nRiG8udo9vaTBVzcHM+4ElzM0Jy6sUrSCvW46CEqL0ko8whOo+qo 3VAw== X-Gm-Message-State: AOAM530fBq+4t5yaKMDAEAN2oBeOVYvjLyQvCrjludtDh5GbEXIN6/KR G0MxJWjygSbuQi2x7LnghewxHg== X-Google-Smtp-Source: ABdhPJwGpJy4DdZ/eC/fCwJjqmeUbVJXNMLzWnkwR0hTzvknEAdfYsGaIbJtZWKk1I+xy8WZjoA44w== X-Received: by 2002:a1c:48d4:: with SMTP id v203mr10067253wma.122.1602552860468; Mon, 12 Oct 2020 18:34:20 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id d23sm24825325wmb.6.2020.10.12.18.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 18:34:19 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Alexander Viro , Andrew Morton , Andy Lutomirski , Brian Geffon , Catalin Marinas , Dan Williams , Dave Jiang , Hugh Dickins , Ingo Molnar , "Kirill A. Shutemov" , Mike Kravetz , Minchan Kim , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Vishal Verma , Vlastimil Babka , Will Deacon , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/6] mm/mremap: Account memory on do_munmap() failure Date: Tue, 13 Oct 2020 02:34:11 +0100 Message-Id: <20201013013416.390574-2-dima@arista.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201013013416.390574-1-dima@arista.com> References: <20201013013416.390574-1-dima@arista.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Fixes: commit e2ea83742133 ("[PATCH] mremap: move_vma fixes and cleanup") Signed-off-by: Dmitry Safonov --- mm/mremap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mremap.c b/mm/mremap.c index 138abbae4f75..03d31a0d4c67 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -450,7 +450,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; }