Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6915325ybh; Thu, 8 Aug 2019 07:35:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzd6QT1XR7WnpLX+Ov75bgpxbvg9BIzO24B3t49Ih4dCLmcMatvST9nwxAfySI9yoUBTN26 X-Received: by 2002:a17:902:30d:: with SMTP id 13mr3995828pld.284.1565274941231; Thu, 08 Aug 2019 07:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565274941; cv=none; d=google.com; s=arc-20160816; b=DSsVuAnihkw6pbYtbSGEgBcsVaihPPd3XS7doVE8ft8fUj1pom8G4YdENQYdgd2MBT SwoOhlVzBe9s98R8IQQ5kwmm3iJ+eboDDDSKcHW3c9nM0vOEIOUkX2UVRC0FcahVXrSS dYU3xDW83eFI0DQR5KPKngpGleDMDCt67i50mkpNFnP9cz9dgemnGA23Y0liNjPZ7vVI 1uGVyADRjAYpGwdCIvZarM1Q5EogfaTRF5C6CcZPjkulGsxYDVPOd5Kr48CdiAxxYnBa Gdcn9l/0AGs3Y3vlGAbWOabC59kPo6/4ErFjqo0upDnlyubr47S0yJJ34BLFfZ3kW8/T R2SA== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=1+hRXOJC+ZDM/4/kVVufU5PRo9dpiWo2Z8YGtmpPW2I=; b=UOVHP3fLO8WXL4Rmgj5rlIrXGdaw9MHTvKFvLwgYbp+4lGW0WUJ5mJfQRBRJwop708 QqGiEdOt/C6AMKBx/f0N/1BpEjnGpmy+btvTm4mb6X78QGS0pYpdi5FPWkEvEWRXBbad jTrhk4iwy6V5woOCRs4FcoJZb1P4cxxwEEyihwWVdFZv2jCL7QCzR+cwyqc6aRZUPZOH lCqnkfutrXT+MM6VnllWFCJB41QR4r69uPiyHSplen8UHxnfMV0ZlGx8cDiGtR1Rn9kZ SlZU0VIzxAnztT/SD3Cbr9IeTRagiJ233uWaWO+gHGRNdc6RbG494U5HeI4+S4/htjvp B5bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cCOBoICU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m63si2090840pjb.8.2019.08.08.07.35.23; Thu, 08 Aug 2019 07:35:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cCOBoICU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732775AbfHHOdk (ORCPT + 99 others); Thu, 8 Aug 2019 10:33:40 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41890 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732741AbfHHOdj (ORCPT ); Thu, 8 Aug 2019 10:33:39 -0400 Received: by mail-ed1-f65.google.com with SMTP id w5so2448565edl.8 for ; Thu, 08 Aug 2019 07:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1+hRXOJC+ZDM/4/kVVufU5PRo9dpiWo2Z8YGtmpPW2I=; b=cCOBoICU8CNt81EgZopFsi62bJmq0dCGhRRyOBZrHz6x4zgZMVW0I0qIH4tqKn99Ch KCuglEQChTF0oNH1RULG7gBFl9ROMSdkWPvDjWYgtyOrwC7lBeww1a4RHafAsavxSbuz Fm5M+8QkjJbkTLchwoDqDiNyYbvLWr++v5jvUHZn519FGt5V8pAxBJ4xQpWhD/gIuloD XKVlh5ov7P2gm1HzEQ48jtXVuZeHjUX32eyJr6Bqts2hiTE9KbIsnJiV+CpxXmKThH2e wmRBJg1RkKYjzuvNjK7zAtt1JAO3piFKSeZxcWyHrAMwdAXPw6YlB+ETRwL/ZUXfkWia 2s4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=1+hRXOJC+ZDM/4/kVVufU5PRo9dpiWo2Z8YGtmpPW2I=; b=qgyiQnj9YDMvD3ggUrdJ2lhNsj3M6OSr1hutHK6Aw1eNvSTbFEQS4mX80MlPr9UpjB OL/wJgGKNbx6q5tDREkJI7FKSPSBuWPKqoIQq0mbhLpHe0qrmSdkFugmmS3750Jf2Uyi C/ShSfl6OR8Ozm4P/ltkvf6d4tl2B0vw7GUgCcj3mJcZKSLGTQYa402GAhoBZmBltG6p BQ7uCmL+49gE9gQhc7oNPmAt7a436Rd6BB9GdrilzGt4ajyJIOHvtK1kZ0k/GaljE5jZ kq6sC8llPduDWeZNHM2RbQvgMO+tjEy13CDDFn4NWVZnKUlfS9ZVPIakC+lstpl46xWC hnmQ== X-Gm-Message-State: APjAAAUfSdp2FoKPTwzQCfUfEXIK9TiQpkpOH8LB2c7aoq6uYfG/8zKW gtaarzETyuifPM32seEHjd0= X-Received: by 2002:a17:906:4354:: with SMTP id z20mr13315954ejm.163.1565274817932; Thu, 08 Aug 2019 07:33:37 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id m17sm255658ejc.91.2019.08.08.07.33.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Aug 2019 07:33:37 -0700 (PDT) Date: Thu, 8 Aug 2019 14:33:36 +0000 From: Wei Yang To: Vlastimil Babka Cc: Wei Yang , Michal Hocko , akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mmap.c: refine data locality of find_vma_prev Message-ID: <20190808143336.kgq4f6j5gfixtcb4@master> Reply-To: Wei Yang References: <20190806081123.22334-1-richardw.yang@linux.intel.com> <3e57ba64-732b-d5be-1ad6-eecc731ef405@suse.cz> <20190807003109.GB24750@richard> <20190807075101.GN11812@dhcp22.suse.cz> <20190808032638.GA28138@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 08, 2019 at 10:49:29AM +0200, Vlastimil Babka wrote: >On 8/8/19 5:26 AM, Wei Yang wrote: >> >> @@ -2270,12 +2270,9 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr, >> if (vma) { >> *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); >> - rb_node = rb_node->rb_right; >> - } >> + struct rb_node *rb_node = rb_last(&mm->mm_rb); >> + *pprev = !rb_node ? NULL : >> + rb_entry(rb_node, struct vm_area_struct, vm_rb); >> } >> return vma; >> >> Not sure this style would help a little in understanding the code? > >Yeah using rb_last() would be nicer than basically repeating its >implementation, so it's fine as a cleanup without performance implications. > Thanks, I would send this version with proper change log. >>> -- >>> Michal Hocko >>> SUSE Labs >> -- Wei Yang Help you, Help me