Received: by 10.213.65.68 with SMTP id h4csp1827927imn; Thu, 5 Apr 2018 04:37:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/XMjptvNJCMGmD8mRzjZ5/+MBkKwj2j8J4nC4Nbnpb427eGu3E4RnDKKHxDeaX0WqXU7ly X-Received: by 10.101.92.74 with SMTP id v10mr14302179pgr.26.1522928230707; Thu, 05 Apr 2018 04:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522928230; cv=none; d=google.com; s=arc-20160816; b=rb3wrCpR+RJiaZkYgrMokdR5GyHZl9mOZkPBDOL4KIuUIo5vljMmrPefvsKYjtidu9 SV7Aqu6m9utPFqvFM5xey1wpLyTNtGCNWbQTmRz/TWzsx7WUKlY10iernC5ouv5tKJqb ZukFkCgPy6/RiXxOoHgaZFQLiNH/ox2ZDkyg9k3YQuAv7kuaO4VsuzODS6VMHLKevO4p 8srHp80yo0lEDVz88qTxamRYZZsdPoD8Kgn2HJLj/zRp5sPXSsb+9FQOpVZK4xCp9Hyi YuhhM705gHhdKMuVVLWYceOL9w5f2RPHE24EVKN9iQpnit0UApk4Zx0osc06zVlvX53y zzXg== 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:dkim-signature:arc-authentication-results; bh=ioL569NfqS9xaxg4SYGYcYRBw4LaHBsffNjAOdqimmk=; b=RmFRd6W2Or4k4eArGok8sdQoDwQaaanZ1q6doEVra9xazo+t61VaWsvRGvJwusM+tF 3acutyAx7jTAtk8fdZSGKJbT2dGfTUZNzXzVIs5e0AEecIGqp/PaBVqJ9BspN7mhxdk4 3pb+fylO/6ppOcOn4rMyYp5A8ufFjVSTDGVk56a/n7o7CUxruaapCl6pSNV4GBTfjkuB mmSzLr0W5M+ZF+tjYP6aeFdH8o2KTk/MO8oKJ/+WIMvrWMi4vN+JhVRNIZpsQiO7feBm wosM4qWKLKJx22JmPdQKAWL1TGVj9mbiOKXI8cc7TktfNpB5Fgm4vPWdOxeNy/dPa+94 A/8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MovbpzLZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p24si5789255pfh.328.2018.04.05.04.36.56; Thu, 05 Apr 2018 04:37:10 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MovbpzLZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbeDELfK (ORCPT + 99 others); Thu, 5 Apr 2018 07:35:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60844 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751470AbeDELfG (ORCPT ); Thu, 5 Apr 2018 07:35:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ioL569NfqS9xaxg4SYGYcYRBw4LaHBsffNjAOdqimmk=; b=MovbpzLZg8O+sJwniGKDmC56z 6BRnFbsslSZrdM2McadIR7jol6R3gwoD7js7iAX7QKWcUDqsec+PnBkOhs0RzbkJTRkUMybVzTe3b +vr7Sik6WR7eUhKwr/QMYLLm6SZXctzISh4vS1EeXfnLidhTToYH8vJcTJ6KiU1ngsWz7r7pb7WRJ y8pup8J2bE8GcISO3nTp4DeuDQiOJi3KnLjJAH5EMzdSqBjlqBFKtZTOgNjk81lwVxmyIRwyTt+nY BhkV/+kxXiwJ7m+yiN3dN2rdYp1ay6TxQWNWUE5nfPCyifOG1OGq4wsm2i6Zi7qo8cESsXglt4Uns vqouvfJiw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f43AC-000265-Ix; Thu, 05 Apr 2018 11:34:44 +0000 Date: Thu, 5 Apr 2018 04:34:44 -0700 From: Matthew Wilcox To: Jia He Cc: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko , Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Pavel Tatashin , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He Subject: Re: [PATCH v7 2/5] arm: arm64: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn() Message-ID: <20180405113444.GB2647@bombadil.infradead.org> References: <1522915478-5044-1-git-send-email-hejianet@gmail.com> <1522915478-5044-3-git-send-email-hejianet@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522915478-5044-3-git-send-email-hejianet@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 01:04:35AM -0700, Jia He wrote: > Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns > where possible") optimized the loop in memmap_init_zone(). But there is > still some room for improvement. E.g. if pfn and pfn+1 are in the same > memblock region, we can simply pfn++ instead of doing the binary search > in memblock_next_valid_pfn. Sure, but I bet if we are >end_pfn, we're almost certainly going to the start_pfn of the next block, so why not test that as well? > + /* fast path, return pfn+1 if next pfn is in the same region */ > + if (early_region_idx != -1) { > + start_pfn = PFN_DOWN(regions[early_region_idx].base); > + end_pfn = PFN_DOWN(regions[early_region_idx].base + > + regions[early_region_idx].size); > + > + if (pfn >= start_pfn && pfn < end_pfn) > + return pfn; early_region_idx++; start_pfn = PFN_DOWN(regions[early_region_idx].base); if (pfn >= end_pfn && pfn <= start_pfn) return start_pfn; > + }