From patchwork Wed Apr 11 07:21:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10334953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 619B86053C for ; Wed, 11 Apr 2018 07:27:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46E8F1FF83 for ; Wed, 11 Apr 2018 07:27:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A12D27480; Wed, 11 Apr 2018 07:27:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7340F1FF83 for ; Wed, 11 Apr 2018 07:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NgkGa6Zfv8YWyru5xdDxDqSAukyOgTTFc+GTTTM/AKs=; b=kYi+PU5VXvm5fm2Mb3tIE852xb qMsDvcq3LW3OuPkRAoooo1l8N9kGYnZSifc+nh/0XRbhwOQl0xaGYY0V7ILRyBQZYuGs1V29PNkeg 6Glhmb9XbxvUiW2THB9iDsbDEkrQ4/Vo+RIjUMFafYzIJQPMN615n3Zt21wDNzcQtMc8sKsU84Old NreKaUzszQMh/fZbrdSX1vKqElC/gI8LoxQHtocmhp/7e4roMRz+cBeaaaY9Yc/GI2GbFMaQA4Jcq qYiJKFLnyPjSK+X9zRmqySr/Og8JkGywBP8JAsSbeuhu4U/EWTXw/v9vLj6MnM/sK33mxyy3YTSY9 X77X4rpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6AAN-0005RE-6W; Wed, 11 Apr 2018 07:27:39 +0000 Received: from mail-pf0-f195.google.com ([209.85.192.195]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6A7F-0002Xm-9O for linux-arm-kernel@lists.infradead.org; Wed, 11 Apr 2018 07:24:47 +0000 Received: by mail-pf0-f195.google.com with SMTP id a2so508102pff.8 for ; Wed, 11 Apr 2018 00:24:14 -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=MCRSDxqii34Tpn/Lt0Gl3cTBKHT9DL9NvZuUQKn48/c=; b=Uhema1d4pCjI4KXcnBZHrpxl6TN4RktEoMuc4/gwqweX61NPwo3gQ394se2cVS0pja 1s0w8QuchmNHX4ZoT5Md86cW7NheBip+/hrLZTFK/qC8/iz9rDubh1SVv9kmCgIEpuex q5GJbgYmTd02KsGUWGKq5EBMkGiSJvvT5vmx222a/NPOdkEjkRRx31XxCX2xxHuDbZko Uqzr1ulxv8nhyx+nBcezxDsN+5T36yQ9UE+HLvJk6F/hDpYpWuH6h1xjXfl3dgoMTbPl PKe0GeiD5Rb1grg7Z4geg1njEeDmMPCpZAnd6o2C4kNQ4va93cL/FjAdC0rdrjH5sfWa 7e2Q== 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=MCRSDxqii34Tpn/Lt0Gl3cTBKHT9DL9NvZuUQKn48/c=; b=SNDLtgIOC/pzEkJEA1UDF/E3r9h7Jl0JOV/vdseXU9tXIH65j9TIOZE9QI2ixLrqw4 rAjHln9bDMqtg6TrcoRpR1Ibtbsggu42A6OuvVub2ZRvfCs98RfCDa/UiUGSc9HZGoxa 0iboUAGoSjKRX8iY0UEWCcmYKc/3vAqNKfPz75lpfd8uYfEcPRVwQ9b30lJ6OjCQML2M 9If8ULYbtI1/fojqPvpsgiMwzoZemeUXYbBS7Gu3xcpz18NaqBlfl//RpV4K7KRBDdGI jMgiRZLUlCfu9ZUUFgQfNcsJ/xpunVP3NtaXnjnLCYBcDr/I95zRJBi0UJhgvv8lZxFG 8mDA== X-Gm-Message-State: ALQs6tCVOChTy2qtHsWToSH16tbvw1ztSgW+4NEY04Egf5seqaw2vA4r UFvI16sR6olDuPuY0e1iNDI= X-Google-Smtp-Source: AIpwx49cmcwzs34KtWHMJx+5Xr6igfOarrQqes9GtSmqwAFZVW4UkFy4NIn0Dh0HDUYFwiZTJNUcrg== X-Received: by 10.99.117.79 with SMTP id f15mr2642096pgn.47.1523431454282; Wed, 11 Apr 2018 00:24:14 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id o90sm1561898pfj.102.2018.04.11.00.24.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Apr 2018 00:24:13 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v8 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Wed, 11 Apr 2018 00:21:57 -0700 Message-Id: <1523431317-30612-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523431317-30612-1-git-send-email-hejianet@gmail.com> References: <1523431317-30612-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180411_002425_380922_74AF72FD X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gioh Kim , Wei Yang , linux-mm@kvack.org, Eugeniu Rosca , Petr Tesarik , Nikolay Borisov , Jia He , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Vlastimil Babka , Andrey Ryabinin , Laura Abbott , Daniel Vacek , Mel Gorman , Vladimir Murzin , Kees Cook , Philip Derrin , YASUAKI ISHIMATSU , Jia He , Kemi Wang , linux-arm-kernel@lists.infradead.org, Steve Capper , linux-kernel@vger.kernel.org, James Morse , Johannes Weiner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 41313 us to 24345 us in my armv8a server(QDF2400 with 96G memory). 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 c40297d..426db40 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1271,11 +1271,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)