Received: by 10.213.65.68 with SMTP id h4csp1895704imn; Thu, 5 Apr 2018 05:45:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+e+ACQqvUByIbT9yZU9HRMKjpSqjGLktZXinlJH4BlFW5xVJY2mv1UlSDWnpQz9SlL33ZH X-Received: by 10.101.100.4 with SMTP id a4mr9170319pgv.316.1522932351721; Thu, 05 Apr 2018 05:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522932351; cv=none; d=google.com; s=arc-20160816; b=lCKwn2i8Gz0KUl7RJnUDBc67U9WeQJEMOBlEswg2ihtslDjx8gJUCOxqqS+efeD2MQ 9xPJCdlJbZGqxfDO9TQWJc1WaG3jVA43cZEInDhJ3xvpVPAj/ezy68aISHsN06+ZeGMY DJbc2hIpVvnqDLEASNDqyhniscN6sPFlt5K2JOye61VGe1ShUvOGfUAVuu3YBs21zMyt EdAvkNGnUl/w0KcPQgK7cRTPJ5IZ5iVPyrvbGuVZGEOVHCL+H+naQZYjyLkP2r/PprZn vUlFLgjIFzrqpT2yySI/ApBxessHMy+yfyKiAjOw+h/FK/7oZVezJ6mnJz9Pr5rVlhZF Gm6A== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature:arc-authentication-results; bh=rjktlTYtRpAaPA3ey7+2mhlVuXWcefo/2Jce5fZpu+M=; b=dGh9HQ5bQinwjcbrUbtNBBEHC0+UyLChzgKROS567A3r+0l+MW89venxjA8axL+pJd fjW9o4vZMg4Y5ZiXFqIWmlk/4YTeZHik2dtLXHWq4lgIbqpGCsZhi+LTZy87lPLDdlQG QwZ39gbt5rZFh/URbEAEgB1ZlceWR/cC0oWlLMql8Tf0SDpSj8e5ZEGNHgpc296yFnrQ /IiGJkhfS4cRumb9mPtuqV91B2zncLe+OYz157PnN76xs3FjO+GGNJPbhpZWUHBq/13b njaBBO2lxIEHbH9jRKzjQ6CjGuXNe9BzOThpzT27jOmz1iDxrXYe9qeAb/OOJ/d1+wTH 3JwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RQyDcK4w; 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 a33-v6si5424153plc.507.2018.04.05.05.45.36; Thu, 05 Apr 2018 05:45:51 -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=RQyDcK4w; 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 S1751284AbeDEMoc (ORCPT + 99 others); Thu, 5 Apr 2018 08:44:32 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34033 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbeDEMoa (ORCPT ); Thu, 5 Apr 2018 08:44:30 -0400 Received: by mail-pl0-f68.google.com with SMTP id z5-v6so738132pln.1 for ; Thu, 05 Apr 2018 05:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=rjktlTYtRpAaPA3ey7+2mhlVuXWcefo/2Jce5fZpu+M=; b=RQyDcK4wskf9DbDID/SZLT5QpGw97GaqfZIXyWu1DsYWntg0u9rlGvZuPbezdVwrXD zZ5ySI2w3QG4qG9iDkYV3iZbWezfvHHPP9Vf2HCWE9XseGPGadAsFxlcLkbiPVa259ml PLXEDh4SQT4bBZO1zQR1wxivgI4m6fiEymM3ORLm8nhcAxIitb6yyn6ocBi2IZ6KYYxc ezezu31yh5300UzFluYCsHTqZhT8LGGAGwreIfmfyhipeHVYB7RaOjWHOYPhYO/CgrgO wIsnEnYPzx2/vMrt0jWahXxNFgsY5P2mPcmmjQ8qcMpr6GqDfy4DuIJeror83X2qfMm/ /VaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=rjktlTYtRpAaPA3ey7+2mhlVuXWcefo/2Jce5fZpu+M=; b=LtZOnt167azXkL2Ey/Jxz7hsYd2M3oMJR+rLIOzxwYMlVxyHrB4aiZwyGz6qZkfT2y iVU/GZMldR03Vh+PSQIEHvNNjDatMpQry+9n1GVFeOa/PcRZmSwHvz2j8znmsKrGRxeN od1bUSOgYvjUj2LAxAEhTgGYALLzIa1g8ttqIfeUJJMpHgPePh26mA6L2ZivB//DTKC1 b+5Zc8eSeStDrsIUCOtrTJQamSszURMni/6Nj7AsGgxZVeqL+VZievtExz/3cFIWZ7bM igB2ddOpGxSnLqqeDLKyr9keeg33bwtBAPHfZWJXp5UP0DsAaW0hwnYjg0t5OfbEhFkA oaWg== X-Gm-Message-State: AElRT7EWfYSJzPlDvPP7ABEqiZEeGGE7h3tOVw2N7t/G9H717YLS4T4j 3unhRcl98PHtuYw20nABpL0= X-Received: by 10.101.90.68 with SMTP id z4mr14858528pgs.184.1522932270376; Thu, 05 Apr 2018 05:44:30 -0700 (PDT) Received: from [0.0.0.0] (67.216.217.169.16clouds.com. [67.216.217.169]) by smtp.gmail.com with ESMTPSA id x4sm15692843pfb.46.2018.04.05.05.44.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 05:44:29 -0700 (PDT) Subject: Re: [PATCH v7 2/5] arm: arm64: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn() To: Matthew Wilcox 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 References: <1522915478-5044-1-git-send-email-hejianet@gmail.com> <1522915478-5044-3-git-send-email-hejianet@gmail.com> <20180405113444.GB2647@bombadil.infradead.org> From: Jia He Message-ID: <1f809296-e88d-1090-0027-890782b91d6e@gmail.com> Date: Thu, 5 Apr 2018 20:44:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180405113444.GB2647@bombadil.infradead.org> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/5/2018 7:34 PM, Matthew Wilcox Wrote: > 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; Thanks, thus the binary search in next step can be discarded? -- Cheers, Jia