Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3944182ybh; Tue, 6 Aug 2019 03:59:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd1v0uXlV6M3jyCpHOGrx14Zfq/d4QjTiXY0sf+vOUS9WmDyEKk6JtEf4LE4AKP8RZpbnW X-Received: by 2002:a62:6dc2:: with SMTP id i185mr3132969pfc.40.1565089183844; Tue, 06 Aug 2019 03:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565089183; cv=none; d=google.com; s=arc-20160816; b=ZIBKvcemgLJcOM+TFJFpzCvS5HGPM6Uny1cT0LKh1ChTTQjJZFXfIQ38/bgaeYCibD cbSeML/w4Szd7YfiCQzTvKFyDNaqdNkPdiy2HXWA6a5zdhemYMxArxD6soxs0UCaQVxj dUvY9hzXRcdH+tLjns2nF2fwGQGUIMgeu8ojpG4hxRdE86ZwNYCTB1Y3CjTrkP9ErUYm iCtwN0iEZ4js4cbuKkAbs4lZBMtPpkVCbd5dhKQLEBdqvWG1TGBEMo5Y+IPbrqH8oEEh RMAzt27fMYegt6RwJB6u2G2ackuVxT/4sQ2XKwiY8oeoCeF46trzbY0iF98g+A8k4aO8 QIyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KByFyY8Nu0xmGzscsk8mLuSGQZQbwYNExSEpDy0pBks=; b=wS8qpMPE7420rNCIhE6hFRPcflY/vBvRHFkMXz6VTJh5UtIeq1qOS41bQWLPmigRvb Ljgnq/2Ce7hv77nUAkZHJjuo5z54IK2Q60n5kfCQnjVH7idoI8RBJGHSHSli/ve/bD9l qoTVACXAFPAiN8u7NMi0UhTThytXjbnAha375eME6Hh1C0iRmcDYdQrqlxkcBK2Onvbd SD4LCN2zylhy+tVHZImYWLMyZbnmdInnFjgeoFd8z2JqXIQ8jXTaDzcsCPihh7TPAFFe QrEoIL1pwf8C6LttG8MwWSGBjfXamb+qGWKMXtEVKv4fLL+zL+Fa2iv8o/MLqUayAVYb 5LBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amzn.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r41si15553384pjb.11.2019.08.06.03.59.28; Tue, 06 Aug 2019 03:59:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amzn.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732620AbfHFK61 (ORCPT + 99 others); Tue, 6 Aug 2019 06:58:27 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:5385 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730877AbfHFK61 (ORCPT ); Tue, 6 Aug 2019 06:58:27 -0400 X-IronPort-AV: E=Sophos;i="5.64,353,1559520000"; d="scan'208";a="691286792" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2b-4ff6265a.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 06 Aug 2019 10:58:23 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-4ff6265a.us-west-2.amazon.com (Postfix) with ESMTPS id 6EC1FA27C0; Tue, 6 Aug 2019 10:58:23 +0000 (UTC) Received: from EX13D16UEA003.ant.amazon.com (10.43.61.183) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 6 Aug 2019 10:58:23 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D16UEA003.ant.amazon.com (10.43.61.183) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 6 Aug 2019 10:58:22 +0000 Received: from localhost (172.23.204.141) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 6 Aug 2019 10:58:22 +0000 Date: Tue, 6 Aug 2019 10:58:22 +0000 From: Balbir Singh To: Wei Yang CC: , , , , , Subject: Re: [PATCH] mm/mmap.c: refine data locality of find_vma_prev Message-ID: <20190806105822.GA25354@dev-dsk-sblbir-2a-88e651b2.us-west-2.amazon.com> References: <20190806081123.22334-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190806081123.22334-1-richardw.yang@linux.intel.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 06, 2019 at 04:11:23PM +0800, Wei Yang wrote: > When addr is out of the range of the whole rb_tree, pprev will points to > the biggest node. find_vma_prev gets is by going through the right most > node of the tree. > > Since only the last node is the one it is looking for, it is not > necessary to assign pprev to those middle stage nodes. By assigning > pprev to the last node directly, it tries to improve the function > locality a little. > > Signed-off-by: Wei Yang > --- > mm/mmap.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index 7e8c3e8ae75f..284bc7e51f9c 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -2271,11 +2271,10 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr, > *pprev = vma->vm_prev; > } else { > struct rb_node *rb_node = mm->mm_rb.rb_node; > - *pprev = NULL; > - while (rb_node) { > - *pprev = rb_entry(rb_node, struct vm_area_struct, vm_rb); > + while (rb_node && rb_node->rb_right) > rb_node = rb_node->rb_right; > - } > + *pprev = rb_node ? NULL > + : rb_entry(rb_node, struct vm_area_struct, vm_rb); Can rb_node ever be NULL? assuming mm->mm_rb.rb_node is not NULL when we enter here Balbir Singh