From patchwork Wed Aug 15 18:49:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10566751 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 DD3611669 for ; Wed, 15 Aug 2018 18:50:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B45542AF4A for ; Wed, 15 Aug 2018 18:50:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1AC22AF30; Wed, 15 Aug 2018 18:50:31 +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 3B6CE2AF4F for ; Wed, 15 Aug 2018 18:50:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 403CA6B000A; Wed, 15 Aug 2018 14:50:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 38ACC6B000E; Wed, 15 Aug 2018 14:50:24 -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 209E46B0010; Wed, 15 Aug 2018 14:50:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id B04936B000A for ; Wed, 15 Aug 2018 14:50:23 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id d12-v6so906695pgv.12 for ; Wed, 15 Aug 2018 11:50:23 -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=g6+xXxH2+yhu7fnIgV5Oumf4ikagVDQR1nHSrpctNDk=; b=LwrHEb7zLSFOvAwG6lyOQUX0BCNaIv3VguAUhioOx7h4kWaibQybiSULMZgE5XyjDj e/rTl7G9DEA3qjDkEjlcRvtJF+ZKtbAxTq3xrQ53SokgY2GOjQBQ8Or0NX8fjUdeWMCI bhkPZ2rTrsK3RtiDEM9SZE5+Yq/VJyDcOmbZ6qSOMkVM7pdUB59iVWP1blWSzBPrcEV2 f8Nk91JN3jzM7hmTPDVfSFLoxqHrvYMOtC9Lt4g4kGYL9FJam6YO/z2Gje0AS0yujlXS F7v1CDb2iRqsVlGOmqsiVUW91KKbo/DMRUiuZWzaqJzVte2iSKXSJxv2tnZTrfy5Rqa+ FMAA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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: AOUpUlFind4c50IR+VaIgaj/47jysej1VKN9AdRWryR/NIzK8zi/VHBN j+eA1XaHgnFW2a3uNja6wL0TTui5fMHdYDIDbWA9AkQRs/5aorj9FCltwFZw9nr6IVzy7Z6CS1N TFJ5cHVZWjOWclPO1V3TpMTokFsbVaY0pWYUeedclUbmmuM/kfhMkjMnASzTE7fNVEQ== X-Received: by 2002:a62:5613:: with SMTP id k19-v6mr28966877pfb.212.1534359023394; Wed, 15 Aug 2018 11:50:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzQ61HBqsbL2qFCZj2ymlOkxixklVF1jIZnNiG/hSl5DTFwtVT79BvcaoOw8gP7PRGshYV4 X-Received: by 2002:a62:5613:: with SMTP id k19-v6mr28966835pfb.212.1534359022508; Wed, 15 Aug 2018 11:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534359022; cv=none; d=google.com; s=arc-20160816; b=jD5p+G6N5d8VWBAaox65OwHYBnmjCWB7FROooM/5A+fyTvGzYJvB8RYWsf0otaGrY4 zj2G4YruYJMtECzFSnez/e9C475z6d9HtrJzgMKQ8n//G+f/t5+XYW59STopuRBgxlRA Zuh0UI5Y6wGbqczJBFFIZlnQP++bd3RVP4z+ztgO1Ds+nMVJaFTp7A/n7CMOCXvIX/Dm kCfTM9TW+s6oZIPSZYZNWDn42ejqRDsZ2+9o8laHbk+ZQgrOXuhRozb8t6gc5ACrCAhf LW2Til/i8SsmHUJhZMytceQXJWcTXDcgZs6DaKgdD7SVKel6SrYvGDrlpvAnAM5bbNCn TWLA== 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 :arc-authentication-results; bh=g6+xXxH2+yhu7fnIgV5Oumf4ikagVDQR1nHSrpctNDk=; b=Fl+5dmS6JX5gf5UKEaeoS+xm1me8kfUosS5gSwBUdAW2eXZdi+OkYebKbYeqLB44mX mHHlMRashhINazOBmNNG/eI0xQzRg8kbKma4JXM4T6yW9J8gqe8KluRpMaP994vHhEUh YfB3ehjL75ZlydWXyJotgLu7qx7X4YKZEGOk6pzL5xCLf08mxPjGeSW3wJKlTEk2vUUr XBE9IFBDwJo6x+2pPTKOigld8KTIRGHBeusBiT1+KgN/mLD/p51jGlHsMeaF2ZLjQzwY 1hmxPBalHmQjUk68l4waLCsoDozwDAlKZtazcHf3qkoNlpL7PGV6OSx+xQt3PZhJTIl6 D/pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com. [115.124.30.130]) by mx.google.com with ESMTPS id a18-v6si20228338plm.122.2018.08.15.11.50.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 11:50:22 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 as permitted sender) client-ip=115.124.30.130; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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=01201311R391e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01353;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0T6gJtNa_1534358999; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T6gJtNa_1534358999) by smtp.aliyun-inc.com(127.0.0.1); Thu, 16 Aug 2018 02:50:08 +0800 From: Yang Shi To: mhocko@kernel.org, willy@infradead.org, ldufour@linux.vnet.ibm.com, kirill@shutemov.name, vbabka@suse.cz, akpm@linux-foundation.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v8 PATCH 5/5] mm: unmap VM_PFNMAP mappings with optimized path Date: Thu, 16 Aug 2018 02:49:50 +0800 Message-Id: <1534358990-85530-6-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534358990-85530-1-git-send-email-yang.shi@linux.alibaba.com> References: <1534358990-85530-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 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 3b9f734..0a9960d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2811,16 +2811,13 @@ static int do_munmap_zap_rlock(struct mm_struct *mm, unsigned long start, } /* - * Unmapping vmas, which have: - * VM_PFNMAP or - * uprobes - * need get done with write mmap_sem held since they may update - * vm_flags. Deal with such mappings with regular do_munmap() call. + * Unmapping vmas, which have uprobes 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_file && - has_uprobes(vma, vma->vm_start, vma->vm_end)) || - (vma->vm_flags & VM_PFNMAP)) + if (vma->vm_file && + has_uprobes(vma, vma->vm_start, vma->vm_end)) goto regular_path; }