From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE32C43461 for ; Thu, 17 Sep 2020 11:29:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D8A521734 for ; Thu, 17 Sep 2020 11:29:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D8A521734 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F29B56B0055; Thu, 17 Sep 2020 07:29:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED90A6B005A; Thu, 17 Sep 2020 07:29:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E16656B005C; Thu, 17 Sep 2020 07:29:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id CC2456B0055 for ; Thu, 17 Sep 2020 07:29:05 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 82C0E180AD822 for ; Thu, 17 Sep 2020 11:29:05 +0000 (UTC) X-FDA: 77272331850.01.man09_08011bb27122 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 62E0A1004B371 for ; Thu, 17 Sep 2020 11:29:05 +0000 (UTC) X-HE-Tag: man09_08011bb27122 X-Filterd-Recvd-Size: 2756 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 11:29:04 +0000 (UTC) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 36996BE1C8DBDD309115; Thu, 17 Sep 2020 19:29:01 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Thu, 17 Sep 2020 19:28:53 +0800 From: Miaohe Lin To: , , , , , , , , , , CC: , , Subject: [PATCH] mm: Use helper function mapping_allow_writable() Date: Thu, 17 Sep 2020 07:27:36 -0400 Message-ID: <20200917112736.7789-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable 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: Commit 4bb5f5d9395b ("mm: allow drivers to prevent new writable mappings"= ) changed i_mmap_writable from unsigned int to atomic_t and add the helper function mapping_allow_writable() to atomic_inc i_mmap_writable. But it forgot to use this helper function in dup_mmap() and __vma_link_file(). Signed-off-by: Miaohe Lin --- kernel/fork.c | 2 +- mm/mmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 11ed5ac35caf..b9164b75b20c 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -558,7 +558,7 @@ static __latent_entropy int dup_mmap(struct mm_struct= *mm, atomic_dec(&inode->i_writecount); i_mmap_lock_write(mapping); if (tmp->vm_flags & VM_SHARED) - atomic_inc(&mapping->i_mmap_writable); + mapping_allow_writable(mapping); flush_dcache_mmap_lock(mapping); /* insert tmp into the share list, just after mpnt */ vma_interval_tree_insert_after(tmp, mpnt, diff --git a/mm/mmap.c b/mm/mmap.c index e3a1c1b48909..ae9ef433f830 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -665,7 +665,7 @@ static void __vma_link_file(struct vm_area_struct *vm= a) if (vma->vm_flags & VM_DENYWRITE) atomic_dec(&file_inode(file)->i_writecount); if (vma->vm_flags & VM_SHARED) - atomic_inc(&mapping->i_mmap_writable); + mapping_allow_writable(mapping); =20 flush_dcache_mmap_lock(mapping); vma_interval_tree_insert(vma, &mapping->i_mmap); --=20 2.19.1