From patchwork Tue Sep 11 20:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10596321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC190112B for ; Tue, 11 Sep 2018 20:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC5C829DCA for ; Tue, 11 Sep 2018 20:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEF8829DD2; Tue, 11 Sep 2018 20:58:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5080029DCA for ; Tue, 11 Sep 2018 20:58:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB9698E0008; Tue, 11 Sep 2018 16:58:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BF3B58E0001; Tue, 11 Sep 2018 16:58:46 -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 988288E000B; Tue, 11 Sep 2018 16:58:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 33CD08E0008 for ; Tue, 11 Sep 2018 16:58:46 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id g9-v6so12895209pgc.16 for ; Tue, 11 Sep 2018 13:58:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=ZAgZ7q1tZ0obqE6duMZeoXRUPiPQC81VXykkld63HEs=; b=TXKq54V4g++GEH4u0HQzumQjrE2YupKbdOfVQJ3XY9LNYkW38tbQHxw38sEhFyXS4+ acve0GXGu+gtEjfx1mvn2VjlLRikXRYGgwJvDfajWMCREyhQJVtzLBCFw/jCZMjmW63m TtN1xOzUo49fl+Rdmx5/SJ8f4EM9XJQVoRMOZ0knDoS0puzf7pGijIUI4Z5r/0jjONkX GLb5uU6i4hNON+gLHt4rAvXpgad0Rtjxhz63bCJtpQBMY/4EeSqtn7FjkM+o5MMdfmdx SQzDD6xx5+HEJyarW5P0+q5YBS8SBDyzAq6OFDzCI7f4Wtqkkbo2mepsXIw6JY7EzCDv zPnA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APzg51A67B+7wbn8jeE7wy5Br1bKf8Llfqm6wEyoADAhqV6AnuqBGtPw I5IqMUsoeWEAMrSBKv6Iy918oqc5rP37aIok0PBXOQE6uAhbFSCESw6fE3wJlA6H4ZoNDMZuSyN Hew7LQvrO+QNEgWUinHY6sFQTgmBFzR1LJzu0ApSVpVDbOY6eLMC6QHoCp+Cudyr3dw== X-Received: by 2002:a63:a619:: with SMTP id t25-v6mr30092742pge.288.1536699525899; Tue, 11 Sep 2018 13:58:45 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0eY7E7POgU0RfBS82w3w8GlN33zWdmofnOKOYg9v7D0OpD0drLx+p3xTCTnS66+85rGqS X-Received: by 2002:a63:a619:: with SMTP id t25-v6mr30092701pge.288.1536699524918; Tue, 11 Sep 2018 13:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536699524; cv=none; d=google.com; s=arc-20160816; b=UZjtqLiBfztgDbJdw5tx+yx8v3qO6iVA0AwuyJmzk3fcqqBpMSt3uEkBWA9CR22Hma 6cc5ZsSzM73Csxm1E1uvZFvk/ScPavGCOSnJMuJifoZm5RIzB+w8cMG1ehmM2QS/uaVN hk6RllgOhzE6es0z5VWoZ5tFGgPD59Z3a8NQrr9yaULhAYdb8s+C/cPLNsOFgVSbCJvl 3sLHbbz1RDdfJ8HFDUBESrkmVy91hHs90Sdxpr15rjLdzQUwDsIdOE1uzskzrTGa06OG Y84XPVcHGjlt5y0f7/l8cDz6rXIRa5N6gyMIBEXLo+wmduic6XliLCMrXm40acaCG46H vPIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZAgZ7q1tZ0obqE6duMZeoXRUPiPQC81VXykkld63HEs=; b=THK6BXk+lM2H7HHKfj1lx5cKPLtN0GVdzkUtmcw+tZLI8YoRpcbZ7HvEpkilwgX8QY BtLkq3Jaky1ZXLIiY/GTdfH+pHhJmUpk6op8boK5iDUt1gGmVvirfQwNK/EzAZFe+pmu 2o758IK9OtmIK/si4CtpRt5ad84Unzl3m5caz7Ug5DqOB9z41WKUIV1WQJUekAze5sr2 pHQC09yHFDkzGtlORg8pTIFAoi7UqT2OFvIJ0a1DEszvl6DK8s7uChRKuZ56Dy1+78jM mALKHD3Qss0am1B9Mh84XJalGqDyZtlMtvC4u4yRhMFMgw67mAsrFP6FSwpFjA08dSAF dhlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com. [115.124.30.131]) by mx.google.com with ESMTPS id e21-v6si20832405pgb.131.2018.09.11.13.58.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 13:58:44 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) client-ip=115.124.30.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04452;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0T8Sg6Yy_1536699501; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T8Sg6Yy_1536699501) by smtp.aliyun-inc.com(127.0.0.1); Wed, 12 Sep 2018 04:58:30 +0800 From: Yang Shi To: mhocko@kernel.org, willy@infradead.org, ldufour@linux.vnet.ibm.com, vbabka@suse.cz, akpm@linux-foundation.org, dave.hansen@intel.com, oleg@redhat.com, srikar@linux.vnet.ibm.com Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v9 PATCH 4/4] mm: unmap VM_PFNMAP mappings with optimized path Date: Wed, 12 Sep 2018 04:58:13 +0800 Message-Id: <1536699493-69195-5-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536699493-69195-1-git-send-email-yang.shi@linux.alibaba.com> References: <1536699493-69195-1-git-send-email-yang.shi@linux.alibaba.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP When unmapping VM_PFNMAP mappings, vm flags need to be updated. Since the vmas have been detached, so it sounds safe to update vm flags with read mmap_sem. Cc: Michal Hocko Cc: Vlastimil Babka Signed-off-by: Yang Shi --- mm/mmap.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 086f8b5..0b6b231 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2778,7 +2778,7 @@ static int do_munmap_zap_rlock(struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf) { unsigned long end; - struct vm_area_struct *start_vma, *prev, *vma; + struct vm_area_struct *start_vma, *prev; int ret = 0; if (!addr_ok(start, len)) @@ -2811,16 +2811,6 @@ static int do_munmap_zap_rlock(struct mm_struct *mm, unsigned long start, goto out; } - /* - * Unmapping vmas, which have VM_PFNMAP - * need get done with write mmap_sem held since they may update - * vm_flags. Deal with such mappings with regular do_munmap() call. - */ - for (vma = start_vma; vma && vma->vm_start < end; vma = vma->vm_next) { - if (vma->vm_flags & VM_PFNMAP) - goto regular_path; - } - /* Handle mlocked vmas */ if (mm->locked_vm) munlock_vmas(start_vma, end); @@ -2844,9 +2834,6 @@ static int do_munmap_zap_rlock(struct mm_struct *mm, unsigned long start, return 0; -regular_path: - ret = do_munmap(mm, start, len, uf); - out: up_write(&mm->mmap_sem); return ret;