From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id CCC516B026B for ; Thu, 28 Jun 2018 22:31:10 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id d64-v6so7807450qkb.23 for ; Thu, 28 Jun 2018 19:31:10 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 9-v6sor4314705qkn.40.2018.06.28.19.31.10 for (Google Transport Security); Thu, 28 Jun 2018 19:31:10 -0700 (PDT) From: Jia He Subject: [PATCH v9 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 29 Jun 2018 10:29:23 +0800 Message-Id: <1530239363-2356-7-git-send-email-hejianet@gmail.com> In-Reply-To: <1530239363-2356-1-git-send-email-hejianet@gmail.com> References: <1530239363-2356-1-git-send-email-hejianet@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: Russell King , Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , "H. Peter Anvin" Cc: Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Daniel Vacek , Eugeniu Rosca , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Ard Biesheuvel , Steve Capper , Thomas Gleixner , Ingo Molnar , Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , richard.weiyang@gmail.com, Jia He , Jia He 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(), if pfn and pfn+1 are in the same memblock region, we can record the last returned memblock region index and check whether pfn++ is still in the same region. Currently it only improve the performance on arm/arm64 and will have no impact on other arches. For the performance improvement, after this set, I can see the time overhead of memmap_init() is reduced from 27956us to 13537us in my armv8a server(QDF2400 with 96G memory, pagesize 64k). Signed-off-by: Jia He --- include/linux/mmzone.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 57cdc42..ac34238 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1267,11 +1267,16 @@ static inline int pfn_present(unsigned long pfn) #define pfn_to_nid(pfn) (0) #endif -#define early_pfn_valid(pfn) pfn_valid(pfn) #ifdef CONFIG_HAVE_MEMBLOCK_PFN_VALID extern ulong memblock_next_valid_pfn(ulong pfn); #define next_valid_pfn(pfn) memblock_next_valid_pfn(pfn) -#endif + +extern int pfn_valid_region(ulong pfn); +#define early_pfn_valid(pfn) pfn_valid_region(pfn) +#else +#define early_pfn_valid(pfn) pfn_valid(pfn) +#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ + void sparse_init(void); #else #define sparse_init() do {} while (0) -- 1.8.3.1