Received: by 10.213.65.68 with SMTP id h4csp1652388imn; Thu, 5 Apr 2018 01:08:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+AHwmm3Yb50XPVzMW+M3YAexi8pKYwZUYL47GMOrQmIA+yxNNrYDuQIAoUA+E6WXC+p906 X-Received: by 10.99.97.203 with SMTP id v194mr14025830pgb.373.1522915686717; Thu, 05 Apr 2018 01:08:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522915686; cv=none; d=google.com; s=arc-20160816; b=oKaEtwwpAJ+T3gCi4WJKH9fPyzUKqEvPskNBejhScXHGhWanhzOHT1G/ELHS9RlL1q Jtaxt/BDXeXY8l15sUalhv2S97HLmvIeLUshzRM8uchzNj5lI8ERSLg2D5CJQ7gMp4Ek vA5Kmg/CyoBhSA4sAYIG+nYYmLTvzvyJf6i6GmY1lG90YOZj9URnacBKxhBkD82yBloj kEcFReqzJBQNvf4+0NB5CAGo7IuyDWWKpEro8RcGtam3l7yj81b/urkF2HEpRsL1Y4mW 1NYQ7sxD5I8HgU83hvimAqUmlNX/nQs7Tz0EffAgwVfdprKDOH/TXRX9M4Zr3lY7nuq0 UwzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QJXDDCrlH3e6N/V1L5PQV9swiVxzm05L4qgriULRyL0=; b=vrayHg8dRFR+IiAh2Sa0P+PBQkmHau9Kh5uMSYlSCKYAKm5zzLvZnsxU74cOrOfBSz LxA9pe4auU5DWxG0mo1dbwXxKRJ/+xz/Jj6UQ2Y1IjKSVDHcDTgaKfWHh42ATOEt9LJR UEkVLqJ7HDLFwnHPmitnrlCBPTmtrJfQiHXmNrarVygCGf30bSbrsH3Zl3Hnv6myZzjS zB6imcg+LIJwq5TM1VaJJegWsP2SaQWltEstSq7mBArOX2ewFsfQB/hvSNAK58bjxgQU k2qyDZais/vQnzvgAlBoavo1rVf+zHV6OMOZaOjEf45tr3t726odotucr6p2y64eIrGI lK1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R0BcRXOo; 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 g16si4941412pgn.813.2018.04.05.01.07.52; Thu, 05 Apr 2018 01:08:06 -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=R0BcRXOo; 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 S1751906AbeDEIFx (ORCPT + 99 others); Thu, 5 Apr 2018 04:05:53 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37290 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbeDEIFu (ORCPT ); Thu, 5 Apr 2018 04:05:50 -0400 Received: by mail-pl0-f68.google.com with SMTP id v5-v6so16077804plo.4 for ; Thu, 05 Apr 2018 01:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QJXDDCrlH3e6N/V1L5PQV9swiVxzm05L4qgriULRyL0=; b=R0BcRXOo+2itK3FsIE+gOpcbCt+6htLuvSNu03LI6pXbXIuppBlIPObjAWbaAasITj lo0dn9v4jeXSLtADVKwdklROyo23L4881mOF9O02g7GilXu1DxFfMpeuFs0txjBzYax2 Cp3B8o5IALxm2YEUVpLoknqFBP8+bHU/f8XnD3d1syzDQ61QTGMcntJV9W7wMwQLfBAw 0ir4QaZ/v32TVnsjaTmQ1BDUMVnjELmooYm4KiR8kbWvKhgLC1xhXIbnkQgDfm+IpNEr jMClVxe02tjow5doOmCTjtLV/5Dpr/3OJzKL5qmKRuf9b2kaTHEeBiR7xNoVe2/zMvwM ro+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QJXDDCrlH3e6N/V1L5PQV9swiVxzm05L4qgriULRyL0=; b=i6d3ij1dGLo5GQw+uvPQg0wcutZA79g7K9g7GWXlS0RNUURnLbFuHsB5FwBCAaIS8G rC8cTJuYJiq7mxB/BajeDi6kYcbvjT6UqBBQOL+P2Lti6YNVOQq7qDIRAdn32xrl5C93 lpzl40gPWXts18Tc8azHFCTxgoAgJ0Q4MsVD7EdEk7UyhN/niTrwbminlTOZlFNAYcHW cSv4igGmZbXOV0XNq3zeN1m2vYjB2OJgj+aw/T9YLGRkPorcjB6CGqaOo6SnzD69MhLj rzXJw540v6SeJL9ARTyj4fqKJjOzUbt5PY23jtrBYV19CfjTQQUtxnhvPf2LjvLSFZsJ AC+Q== X-Gm-Message-State: AElRT7EatN0wJLkArImRgdDHUNSTf0E6+ccEGGtCs80nhqn85oR9FsxU QOmDev7iJbQ4kcaRNXqr97c= X-Received: by 2002:a17:902:7295:: with SMTP id d21-v6mr21460977pll.130.1522915549952; Thu, 05 Apr 2018 01:05:49 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id 2sm14983690pft.33.2018.04.05.01.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 01:05:49 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: 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 , Jia He Subject: [PATCH v7 4/5] arm: arm64: introduce pfn_valid_region() Date: Thu, 5 Apr 2018 01:04:37 -0700 Message-Id: <1522915478-5044-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522915478-5044-1-git-send-email-hejianet@gmail.com> References: <1522915478-5044-1-git-send-email-hejianet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. in early_pfn_valid(), we can record the last returned memblock region. If current pfn and last pfn are in the same memory region, we needn't do the unnecessary binary searches because memblock_is_nomap is the same result for whole memory region. Signed-off-by: Jia He --- include/linux/arm96_common.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/arm96_common.h b/include/linux/arm96_common.h index 2f4dea4..bb86bd3 100644 --- a/include/linux/arm96_common.h +++ b/include/linux/arm96_common.h @@ -48,5 +48,29 @@ ulong __init_memblock memblock_next_valid_pfn(ulong pfn) return PHYS_PFN(regions[early_region_idx].base); } EXPORT_SYMBOL(memblock_next_valid_pfn); + +int pfn_valid_region(ulong pfn) +{ + ulong start_pfn, end_pfn; + struct memblock_type *type = &memblock.memory; + struct memblock_region *regions = type->regions; + + 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 !memblock_is_nomap( + ®ions[early_region_idx]); + } + + early_region_idx = memblock_search_pfn_regions(pfn); + if (early_region_idx == -1) + return false; + + return !memblock_is_nomap(®ions[early_region_idx]); +} +EXPORT_SYMBOL(pfn_valid_region); #endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ #endif /*__ARM96_COMMON_H*/ -- 2.7.4