From patchwork Sat Jun 18 08:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12886244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E1A5C43334 for ; Sat, 18 Jun 2022 08:20:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4483D6B0071; Sat, 18 Jun 2022 04:20:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D09A6B0072; Sat, 18 Jun 2022 04:20:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 271D66B0073; Sat, 18 Jun 2022 04:20:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 141176B0071 for ; Sat, 18 Jun 2022 04:20:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DDD5F20BD3 for ; Sat, 18 Jun 2022 08:20:38 +0000 (UTC) X-FDA: 79590660156.07.26CF67C Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf25.hostedemail.com (Postfix) with ESMTP id 5FF45A0014 for ; Sat, 18 Jun 2022 08:20:37 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LQ83P2j8ZzDsBK; Sat, 18 Jun 2022 16:20:01 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 18 Jun 2022 16:20:30 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region Date: Sat, 18 Jun 2022 16:20:27 +0800 Message-ID: <20220618082027.43391-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655540438; a=rsa-sha256; cv=none; b=xKLkNwA/VFgjn5uXj6c/piHgfOdR5uKkTIJz+eeRGdw/704QIAZw3hjg81qGpDX0VTXiEI zrKUw5A6h6AwFc9C1hgYTrDhsRiXbj/65JBcBTsgyaXzAqI9Z+Q6I6MGKsZCuMTLBCKD9G UI9azCkky0WgllEmztt5yoLZUqz+J+s= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655540438; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=GyIIaPS1Yb2Bg4iMoxTXA/WV9Bjg/iXwvGZJpuLqlQY=; b=GdZ6ZdYLnl1JMkSgf960zFrwUKFuM72Gn1WCuzFwdUgUk62xAX4kOET3yCqdiWQnDIA9nI i4jTUumEcBN7BNdCLzkpu7JlxrYIFvWgtfvuHe9ZvM8YJXvxrcmGAN/3aXgjgZPzKQyB3O s+eVjL34MpX1stwEQLDjBtT/8jc5RLY= X-Rspamd-Queue-Id: 5FF45A0014 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam06 X-Stat-Signature: 7benhp3y784azt7s15ppxn3ii9gyht9n X-HE-Tag: 1655540437-224067 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: From the beginning, charged is set to 0 to avoid calling vm_unacct_memory twice because vm_unacct_memory will be called by above unmap_region. But since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory anymore. So charged shouldn't be set to 0 now otherwise the calling to paired vm_unacct_memory will be missed and leads to imbalanced account. Fixes: 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces") Signed-off-by: Miaohe Lin --- mm/mmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 315c3ca118cb..b5ab522f9f2b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2806,7 +2806,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Undo any partial mapping done by a device driver. */ unmap_region(mm, mas.tree, vma, prev, next, vma->vm_start, vma->vm_end); - charged = 0; if (vm_flags & VM_SHARED) mapping_unmap_writable(file->f_mapping); free_vma: