From patchwork Sun Sep 13 13:36:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11772333 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 0BE5D59D for ; Sun, 13 Sep 2020 13:36:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 738B221974 for ; Sun, 13 Sep 2020 13:36:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738B221974 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BEF46B0002; Sun, 13 Sep 2020 09:36:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 06EA86B0037; Sun, 13 Sep 2020 09:36:49 -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 EA0B46B0055; Sun, 13 Sep 2020 09:36:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id D15DC6B0002 for ; Sun, 13 Sep 2020 09:36:48 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 85E2218287FF6 for ; Sun, 13 Sep 2020 13:36:48 +0000 (UTC) X-FDA: 77258138496.07.fire19_2f0c71927100 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 5819F1828FDC3 for ; Sun, 13 Sep 2020 13:36:48 +0000 (UTC) X-Spam-Summary: 1,0,0,2b9f08a3389a43fa,d41d8cd98f00b204,richard.weiyang@linux.alibaba.com,,RULES_HIT:41:355:379:541:960:973:981:988:989:1260:1261:1311:1314:1345:1437:1515:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3871:3872:4321:5007:6261:10004:11026:11658:11914:12043:12296:12297:12438:12555:12895:12986:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21627:30012:30054:30065:30070,0,RBL:115.124.30.57:@linux.alibaba.com:.lbl8.mailshell.net-64.201.201.201 62.20.2.100;04yfyym84xkbsru3ixpuiygzssa4nycjw6ew76gg74xh19rdqia5w6wb85bsyrq.97xj9uobd5bg7ywe3osryu8oc3smtihxmhxz5skz8zmgss8ixrp4hxr8mi4s67m.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:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: fire19_2f0c71927100 X-Filterd-Recvd-Size: 1998 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Sun, 13 Sep 2020 13:36:45 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0U8mKYn3_1600004196; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U8mKYn3_1600004196) by smtp.aliyun-inc.com(127.0.0.1); Sun, 13 Sep 2020 21:36:37 +0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 1/2] mm/mmap: not necessary to check mapping separately Date: Sun, 13 Sep 2020 21:36:30 +0800 Message-Id: <20200913133631.37781-1-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 X-Rspamd-Queue-Id: 5819F1828FDC3 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000216, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: *root* with type of struct rb_root_cached is an element of *mapping* with type of struct address_space. This implies when we have a valid *root* it must be a part of valid *mapping*. So we can merge these two checks together to make the code more easy to read and to save some cpu cycles. Signed-off-by: Wei Yang --- mm/mmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1922e6fce9e7..30b155098606 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -895,10 +895,9 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, anon_vma_interval_tree_post_update_vma(next); anon_vma_unlock_write(anon_vma); } - if (mapping) - i_mmap_unlock_write(mapping); if (root) { + i_mmap_unlock_write(mapping); uprobe_mmap(vma); if (adjust_next) From patchwork Sun Sep 13 13:36:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11772335 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 5936D59D for ; Sun, 13 Sep 2020 13:42:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A16121974 for ; Sun, 13 Sep 2020 13:42:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A16121974 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D3706B0002; Sun, 13 Sep 2020 09:42:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2840C6B0037; Sun, 13 Sep 2020 09:42:14 -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 1C0736B0055; Sun, 13 Sep 2020 09:42:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 05C556B0002 for ; Sun, 13 Sep 2020 09:42:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B65D3808104D for ; Sun, 13 Sep 2020 13:42:13 +0000 (UTC) X-FDA: 77258152146.18.glue72_5615c1d27100 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 73A7610719E1F for ; Sun, 13 Sep 2020 13:42:13 +0000 (UTC) X-Spam-Summary: 1,0,0,85384b3e5be96bd7,d41d8cd98f00b204,richard.weiyang@linux.alibaba.com,,RULES_HIT:41:355:379:541:960:968:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:3872:4321:5007:6261:9036:10004:11026:11658:11914:12043:12296:12297:12438:12555:12895:12986:13069:13161:13184:13229:13255:13311:13357:13894:14096:14181:14384:14394:14721:21080:21627:30054:30065:30070,0,RBL:115.124.30.56:@linux.alibaba.com:.lbl8.mailshell.net-64.201.201.201 62.20.2.100;04y8dzefkx3osiiepf4kcub4wwahhyc6jbokkhrjf6h9gubx7f46mxeeb1d94ez.96f6hcy9s585tcaiik4p3tsfayabi6ekcdk6zqqtrma9kchhaku8hqfnywbrca4.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: glue72_5615c1d27100 X-Filterd-Recvd-Size: 2682 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Sun, 13 Sep 2020 13:42:09 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0U8mqL2S_1600004197; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U8mqL2S_1600004197) by smtp.aliyun-inc.com(127.0.0.1); Sun, 13 Sep 2020 21:36:37 +0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 2/2] mm/mmap: check on file instead of the rb_root_cached of its address_space Date: Sun, 13 Sep 2020 21:36:31 +0800 Message-Id: <20200913133631.37781-2-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200913133631.37781-1-richard.weiyang@linux.alibaba.com> References: <20200913133631.37781-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 73A7610719E1F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In __vma_adjust(), we do the check on *root* to decide whether to adjust the address_space. While it seems to be more meaningful to do the check on *file* itself. This means we are adjust some data because it is a file backed vma. Since we seems to assume the address_space is valid if it is a file backed vma, let's just replace *root* with *file* here. Signed-off-by: Wei Yang --- mm/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 30b155098606..829897646a9c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -823,7 +823,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, anon_vma_interval_tree_pre_update_vma(next); } - if (root) { + if (file) { flush_dcache_mmap_lock(mapping); vma_interval_tree_remove(vma, root); if (adjust_next) @@ -844,7 +844,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, next->vm_pgoff += adjust_next >> PAGE_SHIFT; } - if (root) { + if (file) { if (adjust_next) vma_interval_tree_insert(next, root); vma_interval_tree_insert(vma, root); @@ -896,7 +896,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, anon_vma_unlock_write(anon_vma); } - if (root) { + if (file) { i_mmap_unlock_write(mapping); uprobe_mmap(vma);