Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1540023pxk; Sun, 13 Sep 2020 06:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPylB4MOU8KnIRFZa/+c0uebvA5S/q/Sp87kQComZjV2+RsBu/+HisC/ZE50wUlkiAI/a/ X-Received: by 2002:a05:6402:1d03:: with SMTP id dg3mr12523431edb.249.1600004326875; Sun, 13 Sep 2020 06:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600004326; cv=none; d=google.com; s=arc-20160816; b=lpXD9L78XgFjC1Jy17DfLhVXN9HwWfGF70EYAw/77RHru72UZlJWTYd9utccJO5922 YimxEC80Ik5rGmU2n6uughP4mqIG/huSa7pE5qOO5DxIRbKxPLoso+rN7vT6MD/KO/Uo PWJkvSsBy2VUb4S5rrRAiDmgVsJazZc/eEITeax7QIS1Yi4d8NG6UJtMxNEBRYUZr2xz 4XGncZnHLuivy/CqCqNkpWQEzuZFZrSLiHLdsTuo2xoYVxvgRA8iKHT+aHmEEB0DhoXZ Kc6RCOERaFODfGwoM/y8qTaz2oVknKW3cMnrdhE3Q/a9iHK7oNdORFyJi56kns5aeavE +HPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OeSYOzGXQyEmTVRHref2zmB1h5r0hCdKd0G1Tn5cgVE=; b=C2YP/Ztr+5GjLV1hCn75LkL7+QyTJcuSX3Ub+S9KIkvu9iEGDseykt5nGPrCa9ydP8 Msb4Vea5a0CqsHlwAb1Ijd15R/GLF8d2/FxUnbfpF8UDoMSRIAauNL3xT3ZKxL6VttYM x/U5asOcmJZkuOLkz3Fl89KglMSFoJRJ9C+XK+pBq1pFQTY+OdZr24GFiV0xTdohpX1t NMwQPfjdLU6TQGyxkj80eHYq7H6U6hmnXR4U2kIJG5xC4fIOBleSiPhot+WmCzMsIXpa Wz6ZzvYYP0lJOxaKBRAdwzmjcXsN/2H93fOzO+vhHADxmNzKxOX1lTTp0HWnRM2hpueh Vhjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si1229103edo.567.2020.09.13.06.38.13; Sun, 13 Sep 2020 06:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725927AbgIMNgt (ORCPT + 99 others); Sun, 13 Sep 2020 09:36:49 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:59970 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbgIMNgk (ORCPT ); Sun, 13 Sep 2020 09:36:40 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org *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) -- 2.20.1 (Apple Git-117)